protected override void Apply(Transform other) { if (GameTime.Instance.GameSpeed <= 0) { return; } Transform target = (applyOnOther? other : TargetTransform); TimedHealth health = target.GetComponent <TimedHealth>(); if (health == null) { ApplyDamageOnCollision collision = target.GetComponent <ApplyDamageOnCollision>(); if (collision == null) { return; } health = collision.TargetTransform.GetComponent <TimedHealth>(); } if (health != null) { health.SetHealthDelta(-damage); } }
public override void SetPlayerProjectileStats(float currentSpeed, ProjectileStats stats) { movement = GetComponent <TransformMovement>(); damageOnCollision = GetComponent <ApplyDamageOnCollision>(); transform.localScale = Vector3.one * stats.Size; movement.AxisMultipliers = Vector3.one * (stats.AddedSpeed + currentSpeed); damageOnCollision.Damage = stats.Damage; }
private void SpawnWave(BulletWave wave) { BulletInstanceDefinition[] waveDefinitions = GetWaveDefinitions(wave); List <Transform> newProjectiles = new List <Transform>(); foreach (BulletInstanceDefinition def in waveDefinitions) { Transform newP = Transform.Instantiate(wave.projectile, def.position, def.rotation); newP.gameObject.SetActive(false); newProjectiles.Add(newP); ApplyDamageOnCollision damageOnCollision = newP.GetComponent <ApplyDamageOnCollision>(); if (damageOnCollision != null) { damageOnCollision.Damage = wave.damage; } } foreach (Transform t in newProjectiles) { t.gameObject.SetActive(true); } }