Ejemplo n.º 1
0
    private void Attack()
    {
        if (N.CurrentTarget != null)
        {
            AttackTarget = N.CurrentTarget.transform;
            //Calculo de Daño.
            TimeToBasicAttack -= Time.deltaTime;

            if (TimeToBasicAttack <= 0 && AttackTarget != null)
            {
                MonoBehaviour.print("Te ataco viejo");
                float TargetLife = AttackTarget.GetComponent <Unit>().HealhPoints;
                TargetLife       -= basePhysicalDamage + modifier_Strenght * 3; //El multiplicador se debe reemplazar en el futuro por algo calculable.
                TimeToBasicAttack = attackRate;

                if (TargetLife <= 0)
                {
                    AttackTarget.GetComponent <Unit>().HealhPoints = (int)TargetLife;
                    N.CheckForEnemies();
                    if (N.CurrentTarget == null)
                    {
                        N.FSM.SetState(0);
                    }
                }
                else
                {
                    AttackTarget.GetComponent <Unit>().HealhPoints = (int)TargetLife;
                }
            }
        }
        else
        {
            N.FSM.SetState(0);
        }
    }