Пример #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);
        }
    }
Пример #3
0
    // main logic
    public override void Init()
    {
        base.Init();

        // do god mode, if needed)
        if (!godMode)
        {
            MakeVulnerable();
        }
        else
        {
            MakeInvulnerable();
        }

        // start out with no control from the player
        canControl = false;

        // get a ref to the weapon controller
        weaponControl = myGO.GetComponent <Standard_SlotWeaponController> ();

        // if a player manager is not set in the editor, let's try to find one
        if (myPlayerManager == null)
        {
            myPlayerManager = myGO.GetComponent <PlayerManager_Tank> ();
        }

        // set up the data for our player
        myDataManager = myPlayerManager.DataManager_Tank;
        myDataManager.SetName("Player");
        myDataManager.SetHealth(3);
        myDataManager.SetDetaleHealth(100);
        myDataManager.SetProtection(0.5f);

        isFinished = false;

        // get a ref to the player manager
        GameController_Tank.Instance.UpdateLivesP1(myDataManager.GetHealth());
        GameController_Tank.Instance.UpdateLivesDetaleP1(myDataManager.GetDetaleHealth());
    }