void CheckHealth()
        {
            if (currentHealth <= 0 && !isDead)
            {
                transform.root.SendMessage("DropRightWeapon", SendMessageOptions.DontRequireReceiver);
                transform.root.SendMessage("DropLeftWeapon", SendMessageOptions.DontRequireReceiver);

                tpCamera.ClearTargetLockOn();
                isDead = true;

                if (hud != null)
                {
                    hud.FadeText("You are Dead!", 2f, 0.5f);
                }

                if (vGameController.instance != null && vGameController.instance.playerPrefab != null)
                {
                    vGameController.instance.Invoke("Spawn", vGameController.instance.respawnTimer);
                }
                else if (vGameController.instance != null)
                {
                    //if (vSpawnEnemies.instance != null)
                    //    vSpawnEnemies.instance.Invoke("ShowLoseWindow", vGameController.instance.respawnTimer);
                    //else
                    vGameController.instance.Invoke("ResetScene", vGameController.instance.respawnTimer);
                }
            }
        }
Пример #2
0
        void OnGUI()
        {
            switch (inputDevice)
            {
            case InputDevice.MouseKeyboard:
                if (isJoystickInput())
                {
                    inputDevice = InputDevice.Joystick;

                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.FadeText("Control scheme changed to Controller", 2f, 0.5f);
                    }
                }
                else if (isMobileInput())
                {
                    inputDevice = InputDevice.Mobile;
                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.FadeText("Control scheme changed to Mobile", 2f, 0.5f);
                    }
                }
                break;

            case InputDevice.Joystick:
                if (isMouseKeyboard())
                {
                    inputDevice = InputDevice.MouseKeyboard;
                    if (hud != null)
                    {
                        hud.controllerInput = false;
                        hud.FadeText("Control scheme changed to Keyboard/Mouse", 2f, 0.5f);
                    }
                }
                else if (isMobileInput())
                {
                    inputDevice = InputDevice.Mobile;
                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.FadeText("Control scheme changed to Mobile", 2f, 0.5f);
                    }
                }
                break;

            case InputDevice.Mobile:
                if (isMouseKeyboard())
                {
                    inputDevice = InputDevice.MouseKeyboard;
                    if (hud != null)
                    {
                        hud.controllerInput = false;
                        hud.FadeText("Control scheme changed to Keyboard/Mouse", 2f, 0.5f);
                    }
                }
                else if (isJoystickInput())
                {
                    inputDevice = InputDevice.Joystick;
                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.FadeText("Control scheme changed to Controller", 2f, 0.5f);
                    }
                }
                break;
            }
        }