Exemple #1
0
    private void PlayerTurn()
    {
        InputManager.GetInput(_inputAction);

        switch (_inputAction.type)
        {
        case InputAction.Type.MOVE:
            if (!_board.MovePlayer((Board.Direction)_inputAction.GetDirection()))
            {
                break;
            }
            if (!_spellManager.IsActivated(InputAction.Spell.ACCELERATION))
            {
                _turn = 1;
            }
            else
            {
                _spellManager.Deactivate(InputAction.Spell.ACCELERATION);
            }
            DecreaseTurn();
            break;

        case InputAction.Type.SPELL:
            var spell = _spellManager.Get(_inputAction.GetSpell());

            if (spell.Activated)
            {
                Debug.Log("Cancel spell: " + spell.type);
                spell.Cancel();
                break;
            }
            if (!spell.IsAvailable())
            {
                Debug.Log("Spell not available: " + spell.type);
                break;
            }
            if (spell.Instant)
            {                    //TODO a refaire d�gueulasse
                if (spell.type == InputAction.Spell.DELETE_VIRUS)
                {
                    _board.DeleteVirus();
                }
                spell.Use();
            }
            else
            {
                if (spell.type == InputAction.Spell.ACCELERATION)
                {
                    Debug.Log("Activate Accel");
                }
                spell.Activate();
            }
            break;

        case InputAction.Type.RETRY:
            ResetGame();
            break;
        }
    }