Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Photon.Pun;
- public class Pawn : Chessman {
- public Chessman c, c2;
- public override bool[,] PossibleMove () {
- bool[,] r = new bool[8, 8];
- //White team move
- if (isWhite) {
- //diagonal left
- if (CurrentX != 0 && CurrentY != 7) {
- Debug.Log("x != 0, y != 7");
- gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX - 1, CurrentY + 1);
- if (c != null && !c.isWhite) {
- r[CurrentX - 1, CurrentY + 1] = true;
- Debug.Log("diagonal left");
- }
- }
- //diagonal right
- if (CurrentX != 7 && CurrentY != 7) {
- gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX + 1, CurrentY + 1);
- if (c != null && !c.isWhite) {
- r[CurrentX + 1, CurrentY + 1] = true;
- }
- }
- //middle
- if (CurrentY != 7) {
- c = BoardManager.Instance.Chessmans[CurrentX, CurrentY + 1];
- if (c == null) {
- r[CurrentX, CurrentY + 1] = true;
- }
- }
- //middle on first move
- if (CurrentY == 1) {
- c = BoardManager.Instance.Chessmans[CurrentX, CurrentY + 1];
- c2 = BoardManager.Instance.Chessmans[CurrentX, CurrentY + 2];
- if (c == null && c2 == null) {
- r[CurrentX, CurrentY + 2] = true;
- }
- }
- }
- else { //black team move
- //diagonal left
- if (CurrentX != 0 && CurrentY != 0) {
- gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX - 1, CurrentY - 1);
- if (c != null && c.isWhite) {
- r[CurrentX - 1, CurrentY - 1] = true;
- }
- }
- //diagonal right
- if (CurrentX != 7 && CurrentY != 0) {
- gameObject.GetComponent<PhotonView>().RPC("setC", RpcTarget.All, CurrentX + 1, CurrentY - 1);
- if (c != null && c.isWhite) {
- r[CurrentX + 1, CurrentY - 1] = true;
- }
- }
- //middle
- if (CurrentY != 0) {
- c = BoardManager.Instance.Chessmans[CurrentX, CurrentY - 1];
- if (c == null) {
- r[CurrentX, CurrentY - 1] = true;
- }
- }
- //middle on first move
- if (CurrentY == 6) {
- c = BoardManager.Instance.Chessmans[CurrentX, CurrentY - 1];
- c2 = BoardManager.Instance.Chessmans[CurrentX, CurrentY - 2];
- if (c == null && c2 == null) {
- r[CurrentX, CurrentY - 2] = true;
- }
- }
- }
- return r;
- }
- [PunRPC]
- public void setC (int x, int y) {
- c = BoardManager.Instance.Chessmans[x, y];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement