예제 #1
0
    public void update()
    {
        switch (state)
        {
        case State.ROUND_START:
            Game.getSpellManager().tick();
            Game.getEnemyHandler().tick();
            Spell s = Game.getSpellManager().getSpell(Game.getPlayer().position);
            if (s != null)
            {
                Game.getPlayer().takeDamage(s.damage);
            }
            Game.getDungeonBoard().occupiedSpaces = new List <Vector2Int>();
            timeInFixedFrames = 0;
            //inputManager.selectMove(new GodMove(Game.getPlayer()));
            foreach (Enemy e in enemyHandler.getAggroedEnemies())
            {
                e.queueMove();
            }
            finishState(State.ROUND_START);
            break;

        case State.GETTING_PLAYER_INPUT:
            inputTimer.value = ((300.0f - timeInFixedFrames) / 300);
            if (timeInFixedFrames > 300)
            {
                finishState(State.GETTING_PLAYER_INPUT);
            }
            // InputHandler can get input from the user while this state is active
            break;

        case State.PERFORMING_ACTIONS:
            if (queuedMoves.Count == 0)
            {
                moveQueuePointer = 0;
                queuedMoves      = new List <ShiblitzMove>();
                finishState(State.PERFORMING_ACTIONS);
                break;
            }
            ShiblitzMove move = queuedMoves[moveQueuePointer];
            if (!move.started())
            {
                move.performMove();
            }
            if (Game.getEnemyHandler().getAggroedEnemies().Count == 0)
            {
                moveQueuePointer = 0;
                queuedMoves      = new List <ShiblitzMove>();
                finishState(State.PERFORMING_ACTIONS);
                break;
            }
            if (move.isFinished())
            {
                moveQueuePointer++;
            }
            if (moveQueuePointer >= queuedMoves.Count)
            {
                moveQueuePointer = 0;
                queuedMoves      = new List <ShiblitzMove>();
                finishState(State.PERFORMING_ACTIONS);
            }
            break;

        default:
            Debug.Log("Game state is not listed in State enum");
            break;
        }
        inputManager.update();
    }