Beispiel #1
0
    void OnHealthChanged(Ship damageDealer)
    {
        if (m_Health <= 0)
        {
            m_Health = 0;
            Instantiate(ExplosionPrefab, transform.position, Quaternion.identity);
            SetVisibility(false);

            //If our local ship dies, call the respawn function after 2 seconds and award
            //the kill to the damage dealer
            if (PhotonView.isMine == true)
            {
                if (damageDealer != null)
                {
                    damageDealer.OnKilledShip(this);
                }

                Invoke("SendRespawn", 2f);
            }
        }

        //The ShipVisuals component shows the smoke when the ship is damaged
        ShipVisuals.OnHealthChanged(m_Health);
    }