Advertisement
Voltonik

Untitled

Aug 13th, 2019
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Photon.Pun;
  5.  
  6. public class Pawn : Chessman {
  7. public Chessman c, c2;
  8. public override bool[,] PossibleMove () {
  9. bool[,] r = new bool[8, 8];
  10. //White team move
  11. if (isWhite) {
  12. //diagonal left
  13. if (CurrentX != 0 && CurrentY != 7) {
  14. Debug.Log("x != 0, y != 7");
  15. gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX - 1, CurrentY + 1);
  16. if (c != null && !c.isWhite) {
  17. r[CurrentX - 1, CurrentY + 1] = true;
  18. Debug.Log("diagonal left");
  19. }
  20. }
  21.  
  22. //diagonal right
  23. if (CurrentX != 7 && CurrentY != 7) {
  24. gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX + 1, CurrentY + 1);
  25. if (c != null && !c.isWhite) {
  26. r[CurrentX + 1, CurrentY + 1] = true;
  27. }
  28. }
  29.  
  30. //middle
  31. if (CurrentY != 7) {
  32. c = BoardManager.Instance.Chessmans[CurrentX, CurrentY + 1];
  33. if (c == null) {
  34. r[CurrentX, CurrentY + 1] = true;
  35. }
  36. }
  37.  
  38. //middle on first move
  39. if (CurrentY == 1) {
  40. c = BoardManager.Instance.Chessmans[CurrentX, CurrentY + 1];
  41. c2 = BoardManager.Instance.Chessmans[CurrentX, CurrentY + 2];
  42. if (c == null && c2 == null) {
  43. r[CurrentX, CurrentY + 2] = true;
  44. }
  45. }
  46. }
  47. else { //black team move
  48. //diagonal left
  49. if (CurrentX != 0 && CurrentY != 0) {
  50. gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX - 1, CurrentY - 1);
  51. if (c != null && c.isWhite) {
  52. r[CurrentX - 1, CurrentY - 1] = true;
  53. }
  54. }
  55.  
  56. //diagonal right
  57. if (CurrentX != 7 && CurrentY != 0) {
  58. gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX + 1, CurrentY - 1);
  59. if (c != null && c.isWhite) {
  60. r[CurrentX + 1, CurrentY - 1] = true;
  61. }
  62. }
  63.  
  64. //middle
  65. if (CurrentY != 0) {
  66. c = BoardManager.Instance.Chessmans[CurrentX, CurrentY - 1];
  67. if (c == null) {
  68. r[CurrentX, CurrentY - 1] = true;
  69. }
  70. }
  71.  
  72. //middle on first move
  73. if (CurrentY == 6) {
  74. c = BoardManager.Instance.Chessmans[CurrentX, CurrentY - 1];
  75. c2 = BoardManager.Instance.Chessmans[CurrentX, CurrentY - 2];
  76. if (c == null && c2 == null) {
  77. r[CurrentX, CurrentY - 2] = true;
  78. }
  79. }
  80. }
  81.  
  82. return r;
  83. }
  84.  
  85. [PunRPC]
  86. public void setC (int x, int y) {
  87. c = BoardManager.Instance.Chessmans[x, y];
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement