Пример #1
0
    void LostLife()
    {
        isRespawning = true;

        // blow us up!
        GameController_Tank.Instance.PlayerHit(myTransform);

        // reduce lives by one
        myDataManager.ReduceHealth(1);

        // as our ID is 1, we must be player 1
        GameController_Tank.Instance.UpdateLivesP1(myDataManager.GetHealth());

        if (myDataManager.GetHealth() < 1)            // <- game over
        // stop movement, as long as rigidbody is not kinematic (otherwise it will have no velocity and we
        // will generate an error message trying to set it)
        {
            if (myBody != null)
            {
                if (!myBody.isKinematic)
                {
                    myBody.velocity = Vector3.zero;
                }
            }

            // hide ship body
            theMeshGO.SetActive(false);

            // disable and hide weapon
            weaponControl.DisableCurrentWeapon();

            // do anything we need to do at game finished
            PlayerFinished();
        }
        else
        {
            // hide ship body
            theMeshGO.SetActive(false);

            // disable and hide weapon
            weaponControl.DisableCurrentWeapon();

            // respawn
            Invoke("Respawn", 2f);
        }
    }
Пример #2
0
    void LostLife()
    {
        myDataManager_New.ReduceHealth(1);

        if (myDataManager_New.GetHealth() == 0)
        {
            // tell game controller to make an explosion at our position and to award the player points for hitting us
            TellGCEnemyDestroyed();

            // if this is a boss enemy, tell the game controller when we get destroyed so it can end the level
            if (isBoss)
            {
                TellGCBossDestroyed();
            }

            // destroy this
            Destroy(gameObject);
        }
    }