Ejemplo n.º 1
0
    public void RangedAttack(UnitConfig self, UnitConfig target)
    {
        if (TurnSystem.selectedUnit == null && !TurnSystem.selectedUnit.actionPoints.CheckAvailableActions(1))
        {
            return;
        }
        //if ability has been confirmed by player
        //Shooting target
        if (!target.isFriendly && accuracy != 0) //Checks if the unit hit is not friendly
        {
            animator.SetAnimationState(0);
            //Check if you hit
            //target.health.TakeDamage(unitWeapon);
            //Shoot target
            //Trigger shooting animation
            SetUnitState(UnitState.Shooting);

            //animator.AttackStart();


            //Calculate the distance between the units
            mapConfig.turnSystem.distance  = Vector3.Distance(TurnSystem.selectedUnit.transform.position, TurnSystem.selectedTarget.transform.position);
            mapConfig.turnSystem.distance /= 2;

            //Spend Actions
            TurnSystem.selectedUnit.actionPoints.SubtractAllActions();
            //Stop targeting mode
            //SetUnitState(UnitState.Idle);
            //mapConfig.turnSystem.DeselectUnit(TurnSystem.selectedTarget);
        }
    }