Exemple #1
0
    void OnMouseDown()
    {
        if (parentStats.playerOwner == gameController.playerTurn)
        {
            foreach (Transform children in transform)
            {
                Transform thisChild = children;
                foreach (Transform child in thisChild)
                {
                    moveGrandParent movObj = child.GetComponent <moveGrandParent> ();
                    //red_hex redhex = child.GetComponent<red_hex> ();
                    if (movObj != null && movObj.isClick && movObj.grandParentStats.picked)
                    {
                        //if you click on the unit while in movement phase, remove skip button
                        parentStats.isMoving = false;
                        //if you click on the unit while in attack phase, remove skip button
                        parentStats.isAttacking = false;

                        movObj.isClick         = false;
                        movObj.recentlyClicked = true;
                        //redhex.isClick = false;
                    }
                    else if (movObj != null && movObj.grandParentStats.picked)
                    {
                        //checks to see if it has any moves remaining
                        if (transform.parent.GetComponent <unitStatScript>().movesRemaining > 0 && !gameController.attackStep)                        //&& movObj.isGreen){

                        {
                            parentStats.isClicked = true;
                            OnMouseExit();

                            //if you click on unit in movement phase give the option for the skip
                            parentStats.isMoving = true;

                            if (movObj.isGreen || (movObj.transform.parent.GetComponent <ringScript>().rangeValue == parentStats.range && parentStats.range != 1))
                            {
                                movObj.isClick       = true;
                                movObj.isInit        = false;
                                movObj.isInitCollide = false;
                                movObj.isCollide     = false;
                            }
                        }
                        else if (movObj != null && gameController.attackStep && !movObj.isGreen && !parentStats.hasAttacked)
                        {
                            //if the button hasn't been pressed to skip move, hide the button
                            parentStats.isMoving = false;

                            //if you click on the unit in attack phase give the option for the skip
                            parentStats.isAttacking = true;

                            movObj.isClick       = true;
                            movObj.isInit        = false;
                            movObj.isInitCollide = false;
                            movObj.isCollide     = false;
                        }
                    }
                }
            }
        }
    }
Exemple #2
0
 //use this for hiding the green hex objects.
 public void hideMoves()
 {
     foreach (Transform children in transform)
     {
         Transform thisChild = children;
         foreach (Transform child in thisChild)
         {
             moveGrandParent movObj = child.GetComponent <moveGrandParent> ();
             if (movObj != null)
             {
                 //red_hex redhex = child.GetComponent<red_hex> ();
                 movObj.isClick         = false;
                 movObj.recentlyClicked = true;
                 //redhex.isClick = false;
             }
         }
     }
 }