Esempio n. 1
0
    public void update()
    {
        if (Input.GetMouseButtonDown(0) && Input.touchCount < 2)
        {
            lastMouseDown = Time.time;
        }

        if (selectedMove != null && Game.instance.state == Game.State.GETTING_PLAYER_INPUT && Input.GetMouseButtonDown(0))
        {
            Vector3    pos           = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2Int touchLocation = new Vector2Int(Mathf.FloorToInt(pos.x), Mathf.FloorToInt(pos.y));
            foreach (Vector2Int v in inputChoices)
            {
                if (v == touchLocation)
                {
                    if (selectedMove.isCantrip)
                    {
                        selectedMove.setCastLocation(v);
                        selectedMove.performMove();
                        clearInputChoices();
                    }
                    else
                    {
                        selectedMove.setCastLocation(v);
                        Game.QueueMove(selectedMove);
                        clearInputChoices();
                        Game.finishState(Game.State.GETTING_PLAYER_INPUT);
                    }
                }
            }
        }
    }
Esempio n. 2
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();
    }