Example #1
0
    public void StartAction(Action action, GameObject actionMenu)
    {
        switch (action)
        {
        case Action.move:
            if (hasMoved)
            {
                Debug.Log("you have already moved this unit");
                displayMessage.displayErrorMessage("you have already moved this unit", 2);
            }

            else if (isAttacking)
            {
                Debug.Log("you must finish your attack before you can make a move");
                displayMessage.displayErrorMessage("you must finish your attack before you can make a move", 2);
            }

            else
            {
                StartCoroutine("WaitForMove");
            }
            break;

        case Action.attack:
            if (myPlayer.unitIsMoving)
            {
                Debug.Log("you must finish your move before you can make an attack");
            }

            else if (hasAttacked || isAttacking)
            {
                Debug.Log("you have already attacked this turn");
                displayMessage.displayErrorMessage("you have already attacked this turn", 2);
            }

            else
            {
                StartCoroutine("WaitForAttack");
            }

            break;

        case Action.ability:
            if (!moved)
            {
                Debug.Log("finish move before attack");
            }
            if (hasAttacked)
            {
                Debug.Log("You have already made an action this turn");
            }
            else
            {
                StartCoroutine("WaitForAbility");
            }
            break;

        case Action.wait:
            if (myPlayer.myTurn.gameOver)
            {
                actionMenu.SetActive(false);
            }
            else if (myPlayer.unitIsMoving)
            {
                Debug.Log("wait until you finish moving");
            }
            else if (isAttacking)
            {
                Debug.Log("you must finish your attack before you can end your turn");
            }
            else
            {
                waitSelected();
            }

            break;

        default:
            break;
        }
    }