Exemple #1
0
    private void HandleAttack()
    {
        Vector3 mouseVector3 = GridUtils.GetMouseWorldPosition(Input.mousePosition);

        mouseVector3.z = 0;
        int mouseX, mouseY;

        _grid.GetCellPosition(mouseVector3, out mouseX, out mouseY);

        if (_unitPhase == UnitPhase.AfterMovement && IsCellOcuppiedByEnemy(mouseX, mouseY) && _unitRange.IsInAttackRange(_unitMovement.GetUnitXPosition(), _unitMovement.GetUnitYPosition(), mouseX, mouseY))
        {
            HandleAttackUnit(mouseX, mouseY);
        }
        else if ((_unitPhase == UnitPhase.Standby) && IsCellOcuppiedByEnemy(mouseX, mouseY) && _unitRange.IsInAttackRange(_unitMovement.GetUnitXPosition(), _unitMovement.GetUnitYPosition(), mouseX, mouseY))
        {
            if (!_grid.IsPositionInAttackRange(mouseX, mouseY, _unitRange.minRange, _unitRange.maxRange))
            {
                _unitAnimations.AnimateLoopUnit("WALK");
                _attackAfterMovementXTarget = mouseX;
                _attackAfterMovementYTarget = mouseY;
                _unitMovement.MoveBeforeAttack(mouseX, mouseY, this, ActionType.MovementBeforeAttack);
                Turn.BlockTurn();
            }
            else
            {
                HandleAttackUnit(mouseX, mouseY);
            }
        }
    }
Exemple #2
0
    private void HandleMovement()
    {
        Vector3 mouseVector3 = GridUtils.GetMouseWorldPosition(Input.mousePosition);

        mouseVector3.z = 0;
        int mouseX, mouseY;

        _grid.GetCellPosition(mouseVector3, out mouseX, out mouseY);

        if (_unitPhase == UnitPhase.Standby && _unitMovement.IsInMovementRange(mouseX, mouseY))
        {
            Turn.BlockTurn();
            _unitAnimations.AnimateLoopUnit("WALK");
            _unitMovement.Move(mouseX, mouseY, this, ActionType.Movement);
        }
    }
Exemple #3
0
 private void HandleAttackUnit(int mouseX, int mouseY)
 {
     Turn.BlockTurn();
     _currentTargetX = mouseX;
     _currentTargetY = mouseY;
     _unitAnimations.AnimateUnit("ATTACK");
     _unitSounds.PlayAttackSound();
     if (unitData.unitName == "Archer")
     {
         Invoke("HandleRecievingDamage", 2f);
     }
     else if (unitData.unitName == "Rogue")
     {
         HandleRecievingDamage();
     }
     else
     {
         Invoke("HandleRecievingDamage", 0.5f);
     }
 }
Exemple #4
0
 private void ActiveAbility()
 {
     Turn.BlockTurn();
     SetUnitPhase(UnitPhase.AbilityActivated);
     _unitAbility.ActiveAbility(GetUnitXPosition(), GetUnitYPosition());
 }