private void Fire(ITarget intendedTarget) { if (FireParticle) { FireParticle.Play(); } for (int i = 0; i < Amount; i++) { Quaternion rotation = Muzzle.transform.rotation * Quaternion.Euler(UnityEngine.Random.Range(-Inaccuracy, Inaccuracy), UnityEngine.Random.Range(-Inaccuracy, Inaccuracy), 0f); GameObject proj = _pool.GetObject(Muzzle.transform.position, rotation); _team.ApplyTeam(proj); proj.transform.position = Muzzle.transform.position; proj.transform.rotation = Muzzle.transform.rotation; Projectile projectile = proj.GetComponent <Projectile>(); projectile.HitLayerMask = _hitLayerMask; projectile.Target = intendedTarget; projectile.Damage = Damage; projectile.DamageType = DamageType; projectile.Speed = Speed; projectile.Fire(rotation * Vector3.forward); projectile.OnHit += Projectile_OnHit; projectile.OnKill += Projectile_OnKill; projectile.OnEnd += Projectile_OnEnd; OnProjectile?.Invoke(this, projectile); } OnFire?.Invoke(this); }
public void Awake() { Team.ApplyTeam(gameObject); }