// Start is called before the first frame update void Start() { health = GetComponent <Health>(); health.OnDeath += HandleDeath; impacter = GetComponent <Impacter>(); impacter.OnImpact += ImpactHandler; shooter = GetComponent <Shooter>(); rb = GetComponent <Rigidbody2D>(); }
void Start() { Impacter parentImpacter = GetComponentInParent <Impacter>(); if (parentImpacter != null) { impactTeam = parentImpacter.team; } impactTeam = gameObject.GetComponentInParent <Impacter>().team; m_timeSinceLastShot = 0; m_liveBullets = 0; }
public void Shoot() { if (m_timeSinceLastShot >= minimumTimeBetweenShots && m_liveBullets <= maximumLiveBullets) { GameObject bulletGO = Instantiate(bulletPrefab); bulletGO.transform.position = gameObject.transform.position; Bullet bullet = bulletGO.GetComponent <Bullet>(); bullet.OnBulletDeath += OnBulletDeath; if (impactTeam == Impacter.ImpactTeam.Enemy) { bullet.speed *= -1; } Impacter bulletImpacter = bulletGO.GetComponent <Impacter>(); bulletImpacter.team = impactTeam; m_timeSinceLastShot = 0; m_liveBullets++; } }
void Start() { Destroy(gameObject, timeAlive); impacter = GetComponent <Impacter>(); impacter.OnImpact += ImpactHandler; }