Ejemplo n.º 1
0
 void OnGUI()
 {
     if (!Knight.knightAtk)
     {
         if (Piece.attacking)
         {
             if (GUI.Button(new Rect(10, 10, 150, 100), "End Turn"))
             {
                 MovePiece.EndTurn();
             }
         }
         else if (MovePiece.selectedPiece != null)
         {
             if (MovePiece.selectedPiece.tag == "Knight")
             {
                 if (GUI.Button(new Rect(10, 150, 150, 100), "Attack With " + MovePiece.selectedPiece.tag))
                 {
                     MovePiece.selectedPiece.GetComponent <Knight>().atk = true;
                     Knight.knightAtk = true;
                 }
                 Piece.attacking = true;
             }
         }
     }
 }
Ejemplo n.º 2
0
 public override void Move(Vector3 target)
 {
     if (CanMove(gameObject.transform.position, target))
     {
         base.Move(target);
         MovePiece.EndTurn();
     }
 }
Ejemplo n.º 3
0
 public virtual void Attack(GameObject target)
 {
     if (target.GetComponent <Piece>().hp <= 0)
     {
         target.GetComponent <Piece>().Kill();
     }
     target.GetComponent <Piece>().RefreshDisplay();
     MovePiece.EndTurn();
 }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && atk)
     {
         Ray          ray = cam.ScreenPointToRay(Input.mousePosition);
         RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
         if (hit.transform.parent.CompareTag("White") || hit.transform.parent.CompareTag("Black"))
         {
             Attack(hit.transform.gameObject);
             if (hp <= 0)
             {
                 knightAtk = false;
                 atk       = false;
                 MovePiece.EndTurn();
                 Debug.Log(knightAtk + " " + atk + " " + Board.whiteTurn);
                 Kill();
             }
         }
         else if (hit.transform.CompareTag("Empty"))
         {
             //MovePiece.EndTurn();
             int currX = (int)gameObject.transform.position.x;
             int currY = (int)gameObject.transform.position.y;
             if ((Math.Abs(currX - hit.transform.position.x) == 2 && Math.Abs(currY - hit.transform.position.y) == 1) ||
                 (Math.Abs(currX - hit.transform.position.x) == 1 && Math.Abs(currY - hit.transform.position.y) == 2))
             {
                 MoveTo(hit.transform.position);
                 hasMoved  = false;
                 atk       = false;
                 knightAtk = false;
                 MovePiece.EndTurn();
             }
             else
             {
                 knightAtk = false;
                 atk       = false;
                 MovePiece.DeselectPiece();
             }
         }
         else
         {
             atk       = false;
             knightAtk = false;
             attacking = false;
         }
     }
 }
Ejemplo n.º 5
0
 public override void Move(Vector3 target)
 {
     base.Move(target);
     MovePiece.EndTurn();
 }