コード例 #1
0
ファイル: GameManager.cs プロジェクト: AG4W/AxiomaticKangaroo
    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();
    }
コード例 #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (!collision.gameObject.CompareTag("Asteroid"))
     {
         return;
     }
     if (OnShipDestroyed != null)
     {
         OnShipDestroyed.Invoke();
     }
 }
コード例 #3
0
ファイル: Ship.cs プロジェクト: Shad0X/Asteroids
 void UnsubscribeAllEventListeners()
 {
     if (OnShipDestroyed != null)
     {
         Delegate[] subscribers = OnShipDestroyed.GetInvocationList();
         foreach (Delegate subscriber in subscribers)
         {
             OnShipDestroyed -= (subscriber as Action);
         }
         OnShipDestroyed = null;
     }
 }
コード例 #4
0
    // 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);
    }
コード例 #5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        var asteroid = collision.gameObject.GetComponent <Asteroid>();

        if (asteroid == null)
        {
            return;
        }

        if (OnShipDestroyed != null)
        {
            OnShipDestroyed.Invoke();
        }
    }
コード例 #6
0
ファイル: Ship.cs プロジェクト: MRMajewski/SpaceShooter
    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??
    }
コード例 #7
0
    /// <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();
        }
    }
コード例 #8
0
ファイル: Ship.cs プロジェクト: Shad0X/Asteroids
 private void OnCollisionEnter2D(Collision2D collision)
 {
     AudioSource.PlayClipAtPoint(explosionSound, gameObject.transform.position);
     gameObject.SetActive(false);
     OnShipDestroyed?.Invoke();
 }