// Shooting void TargetEnemy() { if (targetShip != null && Vector2.Distance(transform.position, targetShip.transform.position) < attackRange && targetShip.gameObject.activeSelf) { return; } float minDis = 10f; targetShip = null; AlienSpaceship closestShip = null; foreach (AlienSpaceship ap in SpaceShipSpawner.allShips) { if (!ap.gameObject.activeSelf) { continue; } float apDis = Vector2.Distance(transform.position, ap.transform.position); if (apDis < minDis && apDis < attackRange) { minDis = apDis; closestShip = ap; } } targetShip = closestShip; }
IEnumerator SpawnerUpdate() { while (spawning) { if (inactivePool.Count > 0) { AlienSpaceship newShip = inactivePool.Dequeue(); newShip.gameObject.SetActive(true); } yield return(new WaitForSeconds(Mathf.Max(6f - (GameController.instance.level / 3f) - ((Time.time - sceneStartTime) / 40f), 0.1f))); } }
void Despawn(AlienSpaceship alienShip) { Instantiate(scrap, alienShip.transform.position, Quaternion.identity); alienShip.gameObject.SetActive(false); inactivePool.Enqueue(alienShip); }
public void AlienInvadedEvent(AlienSpaceship alienShip) { Health -= 1; }