Example #1
0
    //=====================================
    #region Helper Functions

    private void BButtonBack()
    {
        _chooseObjectWithBools.CancelChoose();
        _dPadGlobal.BButton = false;
        chosenAttack        = null;
        _hudsManager.GetComponent <HudsManager>().BattleActionsHudBack();
        _hudsManager.GetComponent <HudsManager>().playerBattleActionHudActive = true;
        if (_movingAction && !canMoveAgain)
        {
            _moveActionDone = true;
        }
    }
Example #2
0
    //=====================================
    #region Battle States

    private Vector3Int[] BeforeStart()
    {
        turnNumber   = 0;
        chosenAttack = null;
        var battleBoundaryTilesLocationsList = new List <Vector3Int>();

        if (initiatedEnemy == null)
        {
            initiatedEnemy = enemiesInvolved[0];
        }

        var localBattleArea = initiatedEnemy.GetComponent <EnemyStats>().battleArea;

        var enemyPosRounded = new Vector3Int(Convert.ToInt32(initiatedEnemy.transform.position.x),
                                             Convert.ToInt32(initiatedEnemy.transform.position.y),
                                             Convert.ToInt32(initiatedEnemy.transform.position.z));

        var pos = _tileManager.GetComponent <TileManager>().GenerateBoundaryPosFromArea(localBattleArea, enemyPosRounded); //here is the magic
        var battleBoundaryTilesLocations = _tileManager.GetComponent <TileManager>().PlaceTilesIfEmpty(pos, initiatedEnemy.GetComponent <EnemyStats>().battleBoundaryTile);

        battleArea = _tileManager.GetComponent <TileManager>().Reposition(localBattleArea, enemyPosRounded);
        return(battleBoundaryTilesLocations);
    }
Example #3
0
    private void PlayerTurn()
    {
        //=== Beginning ===
        if (_setUpState)
        {
            _blockSpeed = _player.GetComponent <PlayerStats>().blockSpeed;
            turnNumber  = turnNumber + 1;
            _hudsManager.GetComponent <HudsManager>().CollapseBattleActionsHud();
            _hudsManager.GetComponent <HudsManager>().playerBattleActionHudActive = true;
            var playerBattleButtons = _hudsManager.GetComponent <HudsManager>().playerBattleActionHud.GetComponent <PlayerBattleButtons>();
            _setUpState       = false;
            _movingAction     = false;
            _attackActionDone = false;
            _moveActionDone   = false;
        }


        if (_hudsManager.GetComponent <HudsManager>().playerBattleActionHudActive == true &&
            _highlightedArea != null && _highlightedArea.Length > 0)
        {
            _tileManager.GetComponent <TileManager>().RemoveTilesCarpet99(_highlightedArea);
        }

        //=== B Button, back ===
        if (_dPadGlobal.BButton)
        {
            BButtonBack();
        }

        //                      ATTACK
        // ==================================================

        //===CHOSING ATTACK===
        if (attackButtonClicked && chosenAttack != null && !_attackActionDone) //attack false, move true
        {
            attackButtonClicked = false;

            //todo highlight using chosenAttack.range
            var range = _tileManager.GetComponent <TileManager>().Reposition(chosenAttack.range,
                                                                             new Vector3Int(Convert.ToInt32(_player.transform.position.x),
                                                                                            Convert.ToInt32(_player.transform.position.y),
                                                                                            Convert.ToInt32(_player.transform.position.z)));


            range            = RemoveTilesOutsideOfArea(range, battleArea);
            _highlightedArea = range;
            _tileManager.GetComponent <TileManager>().HighlightTiles(range);
            var enemiesInRange = new BattleTrigger().GetObjectsInTiles(new string[1] {
                "Enemy"
            }, range);
            //delete range
            if (enemiesInRange.Length > 0)
            {
                _chooseObjectWithBools.StartChoose(selectorPrefab, enemiesInRange);
            }
            else
            {
                //there's nobody in range
            }
            _hudsManager.GetComponent <HudsManager>().playerBattleActionHudActive = false;
        }

        //===ATTACK CHOSEN===
        if (_chooseObjectWithBools.result != null && !_chooseObjectWithBools.choosing)
        {
            currentEnemy = _chooseObjectWithBools.currentObject;

            //TODO attacking logic ****
            var damage        = chosenAttack.damage;
            var curEnStats    = currentEnemy.GetComponent <EnemyStats>();
            var playerActions = _player.GetComponent <PlayerBattleActions>();
            playerActions.Attack(damage, curEnStats, chosenAttack.attackIcon, currentEnemy.transform.position + new Vector3(0, 0.5f, 0));
            //****

            _chooseObjectWithBools.result = null; //reset the choice.
            _attackActionDone             = true;
            if (!_moveActionDone)
            {
                _hudsManager.GetComponent <HudsManager>().CollapseBattleActionsHud();

                _hudsManager.GetComponent <HudsManager>().ToggleEnableButton(_hudsManager.GetComponent <HudsManager>()
                                                                             .playerBattleActionHud.GetComponent <PlayerBattleButtons>()
                                                                             .ActionsButton, false);
                _hudsManager.GetComponent <HudsManager>().playerBattleActionHudActive = true;
                //turn button off or something?
            }
        }

        //                      MOVE
        // ==================================================
        if (_playerBattleGlobal.MoveButton && !_moveActionDone)
        {
            _playerBattleGlobal.MoveButton = false;
            _hudsManager.GetComponent <HudsManager>().playerBattleActionHudActive = false;
            _player.GetComponent <PlayerMove>().canMove = true;
            _moved        = _player.GetComponent <Move>().moved;
            _movingAction = true;
        }
        if (_movingAction)
        {
            MovingAction();
        }
        if (_moveActionDone && _movingAction)
        {
            _player.GetComponent <PlayerMove>().canMove = false;
            _movingAction = false;
            if (!_attackActionDone)
            {
                _hudsManager.GetComponent <HudsManager>().ToggleEnableButton(_hudsManager.GetComponent <HudsManager>()
                                                                             .playerBattleActionHud.GetComponent <PlayerBattleButtons>()
                                                                             .moveButton, false);
                _hudsManager.GetComponent <HudsManager>().playerBattleActionHudActive = true;
                //turn button off or something?
            }
        }

        //                  BATTLE OVER
        // ==================================================
        if (ActorsHPZero(playersInvolved) || enemiesInvolved.Length == 0)
        {
            _isLose        = true;
            _takeDownState = true;
        }
        if (ActorsHPZero(enemiesInvolved) || enemiesInvolved.Length == 0)
        {
            _isWon          = true;
            _moveActionDone = true;
        }

        //                  END OF TURN
        // ==================================================
        if (_attackActionDone && _moveActionDone)
        {
            _takeDownState = true;
        }

        if (_takeDownState)
        {
            chosenAttack = null;


            if (_isWon)
            {
                state = BattleState.WON;
            }
            else if (_isLose)
            {
                state = BattleState.LOST;
            }
            else
            {
                state = BattleState.ENEMYTURN;
            }
            _hudsManager.GetComponent <HudsManager>().ToggleEnableButton(_hudsManager.GetComponent <HudsManager>()
                                                                         .playerBattleActionHud.GetComponent <PlayerBattleButtons>()
                                                                         .ActionsButton, true);
            _hudsManager.GetComponent <HudsManager>().ToggleEnableButton(_hudsManager.GetComponent <HudsManager>()
                                                                         .playerBattleActionHud.GetComponent <PlayerBattleButtons>()
                                                                         .moveButton, true);
            _moveActionDone   = false;
            _attackActionDone = false;
            _takeDownState    = false;
            _setUpState       = true;
        }
    }
 public void SetAttackBadge(AttackBadge attackBadge)
 {
     _attackBadge = attackBadge;
 }