示例#1
0
    public void Update()
    {
        if (bProcessingRandomActions)
        {
            randomActionsTimePassed += Time.deltaTime;
            if (randomActionsTimePassed > randomActionTimer)
            {
                bProcessingRandomActions = false;
                return;
            }
            if (currentAction != null)
            {
                if (!currentAction.IsActionDone())
                {
                    currentAction.Update();
                }
                else
                {
                    currentAction = null;
                }
            }

            if (currentAction == null)
            {
                currentAction = generateRandomAction();
            }
            return;
        }

        if (currentAction != null)
        {
            if (!currentAction.IsActionDone())
            {
                currentAction.Update();
            }
            else
            {
                currentAction = null;

                //After a move is fully completed check whether the game is finished or not
                if (CheckIfGameIsFinished())
                {
                    FinishGame();
                }
            }
        }

        if (!bGameIsFinished)
        {
            timePassed += Time.deltaTime;
            if ((int)timePassed > seconds)
            {
                seconds = (int)timePassed;
                updateTime(seconds);
            }
        }
        bool bIsPinching = Input.touchCount >= 2;

        if (Input.GetMouseButtonDown(1) && !bIsPinching)
        {
            MainGameLogic.GetMainCamera().GetComponent <UIManager>().OpenGameMenu();
        }
    }