示例#1
0
    private void HandleInputs()
    {
        if (Input.GetKey(KeyCode.Equals) ||
            (contSupp.ControllerTriggerRight() > 0))
        {
            scale *= .99f;
        }
        else if (Input.GetKey(KeyCode.Minus) ||
                 (contSupp.ControllerTriggerLeft() > 0))
        {
            scale *= 1.01f;
        }

        if (Input.GetKey(KeyCode.E) ||
            contSupp.ControllerBumperLeft("hold"))
        {
            angle -= 0.01f;
        }
        else if (Input.GetKey(KeyCode.Q) ||
                 contSupp.ControllerBumperRight("hold"))
        {
            angle += 0.01f;
        }

        Vector2 dir = new Vector2(0.01f * scale, 0);
        float   s   = Mathf.Sin(angle);
        float   c   = Mathf.Cos(angle);

        dir = new Vector2(dir.x * c, dir.x * s);

        if (Input.GetKey(KeyCode.A) ||
            contSupp.ControllerLeftJoystickHorizontal() < 0 ||
            contSupp.ControllerDirectionalPadHorizontal() < 0)
        {
            pos -= dir;
        }
        else if (Input.GetKey(KeyCode.D) ||
                 contSupp.ControllerLeftJoystickHorizontal() > 0 ||
                 contSupp.ControllerDirectionalPadHorizontal() > 0)
        {
            pos += dir;
        }

        dir = new Vector2(-dir.y, dir.x);

        if (Input.GetKey(KeyCode.S) ||
            contSupp.ControllerLeftJoystickVertical() < 0 ||
            contSupp.ControllerDirectionalPadVertical() < 0)
        {
            pos -= dir;
        }
        else if (Input.GetKey(KeyCode.W) ||
                 contSupp.ControllerLeftJoystickVertical() > 0 ||
                 contSupp.ControllerDirectionalPadVertical() > 0)
        {
            pos += dir;
        }
    }
示例#2
0
    void Update()
    {
        // New Game -- Dialogue activation & strobe arrow start
        if (strobeTimer > 0)
        {
            // Script Pref -- Run uMan once after initial load in UIManager
            if (strobeTimer == 1f)
            {
                uMan.HideBrioAndButton();
            }

            strobeTimer -= Time.deltaTime;

            if (strobeTimer <= 0)
            {
                bOptModeSelect = true;
                StartCoroutine(dArrow.Strobe());
                dMan.bDialogueActive = true;
                sFaderAnimDia.transform.localScale = Vector3.zero; // Remove to allow mouse click on options prompts

                // Sound Effect
                SFXMan.sounds[2].PlayOneShot(SFXMan.sounds[2].clip);
            }
        }

        // Mode Selection Prompt
        if (bOptModeSelect &&
            !dMan.bDialogueActive)
        {
            GWC_PromptRestrictions();

            dialogueLines = new string[] {
                "First and first mostly, who's playing?"
            };
            GWC_DialogueResetter();

            optionsLines = new string[] {
                "Me (Single player)",
                "Us (Multiplayer)"
            };
            GWC_OptionsResetter_2Q();
        }

        // Begin play -- Activate music, UI, and fade after team selection
        if (!dMan.bDialogueActive &&
            !bAvoidUpdate &&
            bStartGame)
        {
            player.GetComponent <PlayerMovement>().bStopPlayerMovement = false;
            mMan.bMusicCanPlay = true;
            sFaderAnim.GetComponent <Animator>().enabled = true;

            // Change to avoid running this logic
            bAvoidUpdate = true;

            // Allow tile flipping
            StartCoroutine(StartFlipping());

            // Mode Reminders
            if (bOptModeMulti)
            {
                StartCoroutine(StartMulti());
            }
            if (bOptModeSingle)
            {
                StartCoroutine(StartSingle(1.0f));
            }
        }

        // Change from first music track to second
        if (bStartGame &&
            bAvoidUpdate &&
            musicTimer1 > 0)
        {
            musicTimer1 -= Time.deltaTime;

            if (musicTimer1 <= 0)
            {
                mMan.SwitchTrack(1);
            }
        }

        // Change from second music track to third
        if (musicTimer1 <= 0 &&
            musicTimer2 > 0)
        {
            musicTimer2 -= Time.deltaTime;

            if (musicTimer2 <= 0)
            {
                mMan.SwitchTrack(2);
            }
        }

        // Resetting
        if (!dMan.bDialogueActive &&
            bBoardReset &&
            !bCanFlip)
        {
            StartCoroutine(DelayedResetBoard());
        }

        // Zoom In -- Scroll Forward or press Y
        if (mainCamera.orthographicSize >= aUtil._wantedAspectRatio &&
            !dMan.bDialogueActive &&
            !pause.bPauseActive &&
            !pause.bPausing &&
            (Input.GetAxis("Mouse ScrollWheel") > 0 ||
             Input.GetKeyDown(KeyCode.Comma) ||
             //Input.GetKeyDown(KeyCode.JoystickButton3) ||
             contSupp.ControllerButtonPadTop("down") ||
             touches.bYaction))
        {
            mainCamera.orthographicSize = mainCamera.orthographicSize - 0.25f;
            touches.bYaction            = false;

            sceneTransAnim.transform.localScale = new Vector2
                                                      (sceneTransAnim.transform.localScale.x - 0.35f,
                                                      sceneTransAnim.transform.localScale.y - 0.35f);
        }

        // Zoom Out -- Scroll Back or press X
        if (mainCamera.orthographicSize < 5.642857f &&
            !dMan.bDialogueActive &&
            !pause.bPauseActive &&
            !pause.bPausing &&
            (Input.GetAxis("Mouse ScrollWheel") < 0 ||
             Input.GetKeyDown(KeyCode.Period) ||
             //Input.GetKeyDown(KeyCode.JoystickButton2) ||
             contSupp.ControllerButtonPadLeft("down") ||
             touches.bXaction))
        {
            mainCamera.orthographicSize = mainCamera.orthographicSize + 0.25f;
            touches.bXaction            = false;

            sceneTransAnim.transform.localScale = new Vector2
                                                      (sceneTransAnim.transform.localScale.x + 0.35f,
                                                      sceneTransAnim.transform.localScale.y + 0.35f);
        }

        // Single Player - Reminder to Guess
        if (bSingleReminder &&
            !dMan.bDialogueActive)
        {
            bSingleReminder     = false;
            bAllowPlayerToGuess = true;

            GWC_PromptRestrictions();

            dialogueLines = new string[] {
                "And when you're ready, just hold down for a couple of seconds."
            };
            GWC_DialogueResetter();
        }

        // Single Player - Player Guess
        if (bAllowPlayerToGuess &&
            !dMan.bDialogueActive &&
            (Input.GetKey(KeyCode.Space) ||
             Input.GetKey(KeyCode.G) ||
             Mathf.Abs(contSupp.ControllerTriggerLeft()) > 0 ||
             Mathf.Abs(contSupp.ControllerTriggerRight()) > 0 ||
             (Input.GetMouseButton(0) &&
              Input.touchCount < 2)))
        {
            buttonTimer += Time.deltaTime;

            if (buttonTimer >= guessThreshold &&
                !spLogic.bGuessingFTW)
            {
                if (spLogic.bPlayerMidGuess)
                {
                    spLogic.bPlayerGuessing = true;
                }
                else if (!bIsPlayerG2G)
                {
                    IsPlayerGoodToGuess();
                }

                buttonTimer = 0;
            }
        }

        // Single Player - Reset Player Guess timer
        if (Input.GetMouseButtonUp(0) ||
            Input.GetKeyUp(KeyCode.Space))
        {
            buttonTimer = 0;
        }
    }
示例#3
0
    private void HandleInputs()
    {
        // Zoom Out
        if (Input.GetKey(KeyCode.I) ||
            contSupp.ControllerTriggerRight() > 0 ||
            tConts.bYaction)
        {
            if (scale > 0.00000001f)
            {
                scale *= .99f;
            }
            // Jump to max zoomed-out level
            else
            {
                scale = 75000f;
            }
        }
        // Zoom In
        else if (Input.GetKey(KeyCode.K) ||
                 contSupp.ControllerTriggerLeft() > 0 ||
                 tConts.bXaction)
        {
            if (scale < 75000f)
            {
                scale *= 1.01f;
            }
            // Jump to max zoomed-in level
            else
            {
                scale       = 0.00000001f;
                smoothScale = Mathf.Lerp(scale, scale, 0.0333f);
                pos.x       = -0.7500075f;
                pos.y       = 0.003150068f;
                mat.SetVector("_Area", new Vector4(pos.x, pos.y, scale, scale));
            }
        }

        // Rotate Left
        if (Input.GetKey(KeyCode.J) ||
            contSupp.ControllerBumperLeft("hold") ||
            tConts.bAaction)
        {
            angle -= 0.01f;
        }
        // Rotate Right
        else if (Input.GetKey(KeyCode.L) ||
                 contSupp.ControllerBumperRight("hold") ||
                 tConts.bBaction)
        {
            angle += 0.01f;
        }

        Vector2 dir = new Vector2(0.01f * scale, 0);
        float   s   = Mathf.Sin(angle);
        float   c   = Mathf.Cos(angle);

        dir = new Vector2(dir.x * c, dir.x * s);

        // Move Left
        if (Input.GetKey(KeyCode.A) ||
            contSupp.ControllerLeftJoystickHorizontal() < 0 ||
            contSupp.ControllerDirectionalPadHorizontal() < 0 ||
            tConts.bLeft)
        {
            pos -= dir;
        }
        // Move Right
        else if (Input.GetKey(KeyCode.D) ||
                 contSupp.ControllerLeftJoystickHorizontal() > 0 ||
                 contSupp.ControllerDirectionalPadHorizontal() > 0 ||
                 tConts.bRight)
        {
            pos += dir;
        }

        dir = new Vector2(-dir.y, dir.x);

        // Move Down
        if (Input.GetKey(KeyCode.S) ||
            contSupp.ControllerLeftJoystickVertical() < 0 ||
            contSupp.ControllerDirectionalPadVertical() < 0 ||
            tConts.bDown)
        {
            pos -= dir;
        }
        // Move Up
        else if (Input.GetKey(KeyCode.W) ||
                 contSupp.ControllerLeftJoystickVertical() > 0 ||
                 contSupp.ControllerDirectionalPadVertical() > 0 ||
                 tConts.bUp)
        {
            pos += dir;
        }

        // Cycle Colors
        if (Input.GetKey(KeyCode.U) ||
            contSupp.ControllerButtonPadTop("hold") ||
            tConts.bUpLeft)
        {
            if (color > 0)
            {
                color -= 0.01f;
            }
        }
        else if (Input.GetKey(KeyCode.O) ||
                 contSupp.ControllerButtonPadLeft("hold") ||
                 tConts.bUpRight)
        {
            if (color < 1)
            {
                color += 0.01f;
            }
        }

        // Kaleidoscope
        if (Input.GetKey(KeyCode.E) ||
            contSupp.ControllerButtonPadRight("hold") ||
            tConts.bDownLeft)
        {
            if (symmetry > 0)
            {
                symmetry -= 0.1f;
            }

            else if (symmetry < 0)
            {
                symmetry = 0;
            }
        }
        else if (Input.GetKey(KeyCode.Q) ||
                 contSupp.ControllerButtonPadBottom("hold") ||
                 tConts.bDownRight)
        {
            if (symmetry < 1)
            {
                symmetry += 0.1f;
            }
        }

        if (Input.GetKey(KeyCode.R) ||
            contSupp.ControllerMenuLeft("hold") ||
            Input.touchCount == 3)
        {
            ResetShader();
        }
    }
    void Update()
    {
        if (TD_SBF_GameManagement.IsGameOver ||
            TD_SBF_GameManagement.IsLevelWon)
        {
            enabled = false;
            return;
        }

        if (!gMan.bIsHeroMode)
        {
            // Up
            if (Input.GetKey(KeyCode.W) ||
                Input.GetKey(KeyCode.UpArrow) ||
                (contSupp.bIsMoving &&
                 (contSupp.ControllerLeftJoystickVertical() > 0 ||
                  contSupp.ControllerDirectionalPadVertical() > 0)))
            {
                transform.Translate(Vector2.up * panSpeed * Time.deltaTime, Space.World);
            }

            // Down
            if (Input.GetKey(KeyCode.S) ||
                Input.GetKey(KeyCode.DownArrow) ||
                (contSupp.bIsMoving &&
                 (contSupp.ControllerLeftJoystickVertical() < 0 ||
                  contSupp.ControllerDirectionalPadVertical() < 0)))
            {
                transform.Translate(Vector2.down * panSpeed * Time.deltaTime, Space.World);
            }

            // Right
            if (Input.GetKey(KeyCode.D) ||
                Input.GetKey(KeyCode.RightArrow) ||
                (contSupp.bIsMoving &&
                 (contSupp.ControllerLeftJoystickHorizontal() > 0 ||
                  contSupp.ControllerDirectionalPadHorizontal() > 0)))
            {
                transform.Translate(Vector2.right * panSpeed * Time.deltaTime, Space.World);
            }

            // Left
            if (Input.GetKey(KeyCode.A) ||
                Input.GetKey(KeyCode.LeftArrow) ||
                (contSupp.bIsMoving &&
                 (contSupp.ControllerLeftJoystickHorizontal() < 0 ||
                  contSupp.ControllerDirectionalPadHorizontal() < 0)))
            {
                transform.Translate(Vector2.left * panSpeed * Time.deltaTime, Space.World);
            }

            // Need to handle virtual joystick movement seperately, i.e. too jarring otherwise
            if (touchConts.leftFixedJoystick.bJoying)
            {
                VirtualJoystickMove();
            }

            CalcPosition();

            // Click and drag (mouse)
            if (!devDetect.bIsMobile)
            {
                if (EventSystem.current.IsPointerOverGameObject())
                {
                    return;
                }

                if (Input.GetMouseButtonDown(0) ||
                    Input.GetMouseButtonDown(1))
                {
                    lastPosition = Input.mousePosition;
                }

                if (Input.GetMouseButton(0) ||
                    Input.GetMouseButton(1))
                {
                    Vector3 delta = Input.mousePosition - lastPosition;
                    transform.Translate(-delta.x * mouseSensitivity, -delta.y * mouseSensitivity, -10);
                    lastPosition = Input.mousePosition;
                }
            }

            // Click and drag (touch)
            if (Input.touchCount == 1)
            {
                if (tPlacer.CheckMobileAndGUIAndBail(Input.GetTouch(0).position))
                {
                    return;
                }

                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    lastPosition = new Vector3(
                        Input.GetTouch(0).position.x,
                        Input.GetTouch(0).position.y,
                        0);
                }

                if (Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    Vector3 delta = new Vector3(Input.GetTouch(0).position.x,
                                                Input.GetTouch(0).position.y,
                                                1) - lastPosition;
                    transform.Translate(-delta.x * mobileSensitivity, -delta.y * mobileSensitivity, -10);
                    lastPosition = Input.mousePosition;
                }
            }

            // Pinch and zoom
            if (!cMan.bAvoidCamScroll &&
                Input.touchCount == 2)
            {
                // Store both touches.
                Touch touchZero = Input.GetTouch(0);
                Touch touchOne  = Input.GetTouch(1);

                // Find the position in the previous frame of each touch.
                Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
                Vector2 touchOnePrevPos  = touchOne.position - touchOne.deltaPosition;

                // Find the magnitude of the vector (the distance) between the touches in each frame.
                float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
                float touchDeltaMag     = (touchZero.position - touchOne.position).magnitude;

                // Find the difference in the distances between each frame.
                float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;

                // If the camera is orthographic...
                if (gameObject.GetComponent <Camera>().orthographic)
                {
                    // ... change the orthographic size based on the change in distance between the touches.
                    gameObject.GetComponent <Camera>().orthographicSize += deltaMagnitudeDiff * orthoZoomSpeed;

                    // Make sure the orthographic size never drops below zero.
                    gameObject.GetComponent <Camera>().orthographicSize =
                        Mathf.Clamp(gameObject.GetComponent <Camera>().orthographicSize, 5f, 50f);
                }
                // DC 02/22/2019 -- This "should" never run
                else
                {
                    // Otherwise change the field of view based on the change in distance between the touches.
                    gameObject.GetComponent <Camera>().fieldOfView += deltaMagnitudeDiff * perspectiveZoomSpeed;

                    // Clamp the field of view to make sure it's between 0 and 180.
                    gameObject.GetComponent <Camera>().fieldOfView =
                        Mathf.Clamp(gameObject.GetComponent <Camera>().fieldOfView, 0.1f, 179.9f);
                }
            }
        }

        // Mouse
        if (!cMan.bAvoidCamScroll &&
            (Input.GetAxis("Mouse ScrollWheel") != 0 ||
             touchConts.rightFixedJoystick.Vertical != 0))
        {
            float scroll = 0;

            if (Input.GetAxis("Mouse ScrollWheel") != 0)
            {
                scroll = Input.GetAxis("Mouse ScrollWheel");
            }
            else
            {
                scroll = touchConts.rightFixedJoystick.Vertical * 0.05f;
            }

            // TODO - Investigate why mobile "locks" up on the zoom

            // Zoom In
            if (scroll > 0 &&
                GetComponent <Camera>().orthographicSize > 5)
            {
                GetComponent <Camera>().orthographicSize -=
                    scroll * 100 * scrollSpeed * Time.deltaTime;
            }

            // Zoom Out
            if (scroll < 0 &&
                GetComponent <Camera>().orthographicSize < 50)
            {
                GetComponent <Camera>().orthographicSize -=
                    scroll * 100 * scrollSpeed * Time.deltaTime;
            }

            if (GetComponent <Camera>().orthographicSize < 0)
            {
                GetComponent <Camera>().orthographicSize = 5f;
            }
            else if (GetComponent <Camera>().orthographicSize > 50)
            {
                GetComponent <Camera>().orthographicSize = 50f;
            }
        }

        // Controller
        if (!cMan.bAvoidCamScroll &&
            //Input.GetAxis("Controller Right Trigger") > 0)
            contSupp.ControllerTriggerRight() > 0)
        {
            //float scroll = Input.GetAxis("Controller Right Trigger");
            float scroll = contSupp.ControllerTriggerRight();

            // Zoom In
            if (scroll > 0 &&
                GetComponent <Camera>().orthographicSize > 5)
            {
                GetComponent <Camera>().orthographicSize -=
                    scroll * 5 * scrollSpeed * Time.deltaTime;
            }

            if (GetComponent <Camera>().orthographicSize < 0)
            {
                GetComponent <Camera>().orthographicSize = 5f;
            }
        }

        // Controller
        if (!cMan.bAvoidCamScroll &&
            //Input.GetAxis("Controller Left Trigger") > 0)
            contSupp.ControllerTriggerLeft() > 0)
        {
            //float scroll = Input.GetAxis("Controller Left Trigger");
            float scroll = contSupp.ControllerTriggerLeft();

            // Zoom Out
            if (scroll > 0 &&
                GetComponent <Camera>().orthographicSize < 50)
            {
                GetComponent <Camera>().orthographicSize +=
                    scroll * 5 * scrollSpeed * Time.deltaTime;
            }

            if (GetComponent <Camera>().orthographicSize > 50)
            {
                GetComponent <Camera>().orthographicSize = 50f;
            }
        }
    }