Beispiel #1
0
    void Update()
    {
        // only game mechanics
        if (appManager.appState != AppManager.AppState.Game)
        {
            return;
        }



#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.R))
        {
            appManager.RestartCurrentScene();
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            ship.Collision();
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            ship.shipNavigation.InitiateTurn(-1);
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            ship.shipNavigation.InitiateTurn(1);
        }
#endif

        // escape
        if (Input.GetButtonDown("Cancel"))
        {
            if (playerAlive)
            {
                crosshair.HideEverything();

                appManager.UnlockCursor();
                appManager.FreezeTimescale();
                appManager.MenuEntered();

                appManager.soundManager.Play(SoundManager.soundId.uiClick);
                return;
            }
            else
            {
                // ESC when game over: quit to title

                //appManager.UnlockCursor();
                //appManager.RestartCurrentScene();

                // now as a callback of fade
                appManager.screenFader.FadeScreenOut(ScreenFader.FadeOutCallback.RestartScene);
            }
        }

        // mouse sensitivity
        if (Input.GetKey(KeyCode.Alpha1))
        {
            playerLook.MouseSensitivity = 33f;
        }
        if (Input.GetKey(KeyCode.Alpha2))
        {
            playerLook.MouseSensitivity = 66f;
        }
        if (Input.GetKey(KeyCode.Alpha3))
        {
            playerLook.MouseSensitivity = 100f;
        }
        if (Input.GetKey(KeyCode.Alpha4))
        {
            playerLook.MouseSensitivity = 133f;
        }
        if (Input.GetKey(KeyCode.Alpha5))
        {
            playerLook.MouseSensitivity = 166f;
        }



        // following mechanics when game in progress only
        if (!playerAlive)
        {
            return;
        }


        // enable possible actions dependent on camera angle
        // (not while scoping)
        if (scopeManager.scoping)
        {
            availableAction = ClickAction.No;
        }
        else
        {
            PickMouseActionByCamAngle();
        }


        // mouse click
        if (Input.GetMouseButtonDown(0))
        {
            if (Cursor.lockState != CursorLockMode.Locked)
            {
                appManager.LockCursor();
                appManager.RestoreTimescale();
            }
            else
            {
                switch (availableAction)
                {
                case ClickAction.Scope:
                    //playerUsedScopeAction = true; // to hide hint every next time - abandoned
                    scopeManager.Activate();
                    break;

                case ClickAction.Nav:
                    //playerUsedNavAction = true;
                    BeginNavSelection();
                    break;

                case ClickAction.NavigateLeft:
                    ship.shipNavigation.InitiateTurn(-1);
                    EndNavSelection();
                    break;

                case ClickAction.NavigateRight:
                    ship.shipNavigation.InitiateTurn(1);
                    EndNavSelection();
                    break;

                case ClickAction.No:
                    if (navSelection)
                    {
                        EndNavSelection();
                    }
                    break;

                default:
                    break;
                }
            }
        }
        // mouse released
        if (!Input.GetMouseButton(0) && scopeManager.scoping)
        {
            scopeManager.Deactivate();
        }
    }