コード例 #1
0
 private void SpawnProjectilesForTargets(AbilityData data, Vector3 spawnPosition)
 {
     foreach (var target in data.GetTargets())
     {
         Health health = target.GetComponent <Health>();
         if (health)
         {
             Projectile projectile = Instantiate(projectileToSpawn);
             projectile.transform.position = spawnPosition;
             projectile.SetTarget(health, data.GetUser(), damage);
         }
     }
 }
コード例 #2
0
ファイル: HealthEffect.cs プロジェクト: janazleonhart/RPG
 public override void StartEffect(AbilityData data, Action finished)
 {
     foreach (var target in data.GetTargets())
     {
         var health = target.GetComponent <Health>();
         if (health)
         {
             if (healthChange < 0)
             {
                 health.TakeDamage(data.GetUser(), -healthChange);
             }
             else
             {
                 health.Heal(healthChange);
             }
         }
     }
     finished();
 }
コード例 #3
0
        private void SpawnProjectilesForTargets(AbilityData data, Vector3 spawnPosition)
        {
            int count = 0;

            foreach (var target in data.GetTargets())
            {
                if (count >= maxNumberOfTargets)
                {
                    break;
                }

                Health health = target.GetComponent <Health>();
                if (health)
                {
                    Projectile projectile = Instantiate(projectileToSpawn);
                    projectile.transform.position = spawnPosition;
                    projectile.SetTarget(health, data.GetUser(), damage);
                    count++;
                }
            }
        }