static void OnDestroyed(ShipEntity s) { OnShipDestroyed?.Invoke(s); _ships.Remove(s); LogManager.getInstance.AddEntry(s.teamID == 0 ? "The <i><color=yellow>" + s.name + "</color></i> has been lost with all souls, Admiral." : "Hostile vessel, <i><color=yellow>" + s.name + "</color></i> has been destroyed."); UpdateGameStatus(); }
private void OnTriggerEnter2D(Collider2D collision) { if (!collision.gameObject.CompareTag("Asteroid")) { return; } if (OnShipDestroyed != null) { OnShipDestroyed.Invoke(); } }
void UnsubscribeAllEventListeners() { if (OnShipDestroyed != null) { Delegate[] subscribers = OnShipDestroyed.GetInvocationList(); foreach (Delegate subscriber in subscribers) { OnShipDestroyed -= (subscriber as Action); } OnShipDestroyed = null; } }
// Called when the ship is destroyed public void Destroyed() { GameObject destroyedFx = Instantiate(destroyedPrefab); destroyedFx.transform.position = this.transform.position; destroyedFx.transform.up = this.transform.up; destroyedFx.GetComponent <DestroyedShipFx>().DestroyFrom(_rb.velocity); OnShipDestroyed?.Invoke(); Destroy(gameObject); }
private void OnTriggerEnter2D(Collider2D collision) { var asteroid = collision.gameObject.GetComponent <Asteroid>(); if (asteroid == null) { return; } if (OnShipDestroyed != null) { OnShipDestroyed.Invoke(); } }
private void OnTriggerEnter2D(Collider2D collision) { var asteroid = collision.gameObject.GetComponent <Asteroid>(); var homingEnemy = collision.gameObject.GetComponent <HomingEnemy>(); if (homingEnemy == null && asteroid == null) { return; } if (OnShipDestroyed != null) { StartCoroutine(CoroutineDestroyShip()); } OnShipDestroyed.Invoke(); //co to robi?? }
/// <summary> /// <para>Invokes the OnShipDestroyed event</para> /// <para>If there are lives left, initializes the next available ship if there is any and invokes the /// OnPlayerDestroyed event.</para> /// <para>If there is no ships available then the OnAllShipsDestroyed event will be invoked</para> /// <remarks>This method is executed when a player ship is destroyed</remarks> /// </summary> /// <param name="ship"></param> private void OnShipDie(PlayerShip ship) { OnShipDestroyed?.Invoke(ship.PlayerController.gameObject); if (ship.PlayerController != ships[currentLife].PlayerController) { return; } currentLife++; livesUI.UpdateValue(lives - currentLife); if (currentLife >= lives) { OnAllShipsDestroyed?.Invoke(); } else { InitializeShip(); OnPlayerDestroyed?.Invoke(); } }
private void OnCollisionEnter2D(Collision2D collision) { AudioSource.PlayClipAtPoint(explosionSound, gameObject.transform.position); gameObject.SetActive(false); OnShipDestroyed?.Invoke(); }