Ejemplo n.º 1
0
 public void dealDamage() //Called by animation event
 {
     if (!UnitDealsSplashDamage)
     {
         OnDealingDamage?.Invoke(defenderOrCreepStats.meleeDamage); //Damage needs to inherit from stats
     }
     if (UnitDealsSplashDamage)
     {
         localSplashDamageClass.DealSplashDamage(transform.position, defenderOrCreepStats.meleeDamage); //Deal damage at locaiton
     }
 }
Ejemplo n.º 2
0
    private void MoveProjectileWithoutHoming()
    {
        if (t < 1f)
        {
            t += (Time.deltaTime * ProjectileMovementSpeed) / 10;
        }
        aPos = TurretOwner.transform.position + Vector3.up * 2.5f; //Needs improvement
        bPos = ((TurretOwner.transform.position + Vector3.up * topProjectileHight) + targetPos) / 2;
        cPos = targetPos;
        //New movement

        ABPos.position = Vector3.Lerp(aPos, bPos, t);                         //Move from A to B

        BCPos.position = Vector3.Lerp(bPos, cPos, t);                         //Move from B to C

        transform.position = Vector3.Lerp(ABPos.position, BCPos.position, t); //Move the projectile

        float distanceToTarget = (cPos - transform.position).magnitude;       //IMPORTANT AND USEFULL. THIS IS HOW YOU CAN GET A DISTANCE

        ////BETWEEN TWO "Vector3" POINTS AS A "float"!
        if (distanceToTarget < MinDistanceToDealDamage) //Check if the projectile is close
        {
            projectileIsFired = false;
            TurretOwner.ResetTurretProjectile();
            ObjectPooler.SetObjectToInactive(gameObject); //Return this projectile to the pool
            if (!DealsSplashDamage)
            {
                _creepTarget._CreepHealth.DealDamage(Damage); //Fires the deal damage function in the creephealth reference
                OnCreepHit?.Invoke(_creepTarget, Damage);     //DELETE this later, as it is ONLY used for displaying DAMAGE NUMBERS
            }
            if (DealsSplashDamage)
            {
                localSplashDamage.DealSplashDamage(transform.position, Damage); //Deal damage at location
            }
            t = 0f;
        }
    }