void ShootLaser(EnemyCannons cannons) { cannons.FireStraightForward(); if (isQuadFireShip) { cannons.FireStraightForward(); } }
void ShootNonStop() { EnemyCannons cannons = GetComponentInChildren <EnemyCannons>(); cannons.FireStraightForward(); if (isQuadFireShip) { cannons.FireStraightForward(); } }
// Update is called once per frame void Update() { // check if can shoot if (canShootLaser || canShootTorpedo || canShootMissile) { Vector2 pos = new Vector2(transform.position.x + 0.5f, transform.position.y); // raycast to player ship RaycastHit2D hit = Physics2D.Raycast(pos, transform.right); if (hit.collider != null) { if (hit.transform.tag == "PlayerShipTag") { // if successful, shoot EnemyCannons cannons = GetComponentInChildren <EnemyCannons>(); if (canShootTorpedo) { if (2.5f < Vector2.Distance(transform.position, hit.transform.position)) { StartCoroutine(PlayMissileLockBeep()); cannons.FireTorepdo(hit.transform.gameObject); canShootTorpedo = false; Invoke("CanShootTorpedo", torpedoMissileShootingSpeed); } } else if (canShootLaser) { ShootLaser(cannons); canShootLaser = false; Invoke("CanShoot", laserShootingSpeed); } else { if (2.5f < Vector2.Distance(transform.position, hit.transform.position)) { StartCoroutine(PlayMissileLockBeep()); cannons.FireMissile(hit.transform.gameObject); canShootMissile = false; Invoke("CanShootMissile", torpedoMissileShootingSpeed); } } } } } }
void ShootLasers() { EnemyCannons cannons = GetComponentInChildren <EnemyCannons>(); cannons.FireStraightForward(); }