示例#1
0
        private double DeterminateDistance(Point point)
        {
            if (point.X > buttonOK.Location.X && point.X <= buttonOK.Location.X + buttonOK.Width &&
                point.Y <= buttonOK.Location.Y)
            {
                Position = CursorPositions.IsOnTop;
            }
            else if (point.X >= buttonOK.Location.X && point.X < buttonOK.Location.X + buttonOK.Width &&
                     point.Y >= buttonOK.Location.Y + buttonOK.Height)
            {
                Position = CursorPositions.IsOnBottom;
            }
            else if (point.X <= buttonOK.Location.X &&
                     point.Y >= buttonOK.Location.Y && point.Y < buttonOK.Location.Y + buttonOK.Height)
            {
                Position = CursorPositions.IsOnLeft;
            }
            else if (point.X >= buttonOK.Location.X + buttonOK.Width &&
                     point.Y >= buttonOK.Location.Y && point.Y < buttonOK.Location.Y + buttonOK.Height)
            {
                Position = CursorPositions.IsOnRight;
            }
            else if (point.X > buttonOK.Location.X + buttonOK.Width && point.Y > buttonOK.Location.Y + buttonOK.Height)
            {
                Position = CursorPositions.IsOnBottomRight;
            }
            else if (point.X >= buttonOK.Location.X + buttonOK.Width &&
                     point.Y < buttonOK.Location.Y)
            {
                Position = CursorPositions.IsOnTopRight;
            }
            else if (point.X < buttonOK.Location.X &&
                     point.Y > buttonOK.Location.Y + buttonOK.Height)
            {
                Position = CursorPositions.IsOnBottomLeft;
            }
            else
            {
                Position = CursorPositions.IsOnTopLeft;
            }

            return(GetVector(point));
        }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(InputManager.Slash))
        {
            if (cursorPos == CursorPositions.Jump)
            {
                KeyBindingButton(0);
            }
            else if (cursorPos == CursorPositions.Slash)
            {
                KeyBindingButton(1);
            }
            else if (cursorPos == CursorPositions.Shuriken)
            {
                KeyBindingButton(2);
            }
            else if (cursorPos == CursorPositions.GrapplingHook)
            {
                KeyBindingButton(3);
            }
            else if (cursorPos == CursorPositions.SmokeBomb)
            {
                KeyBindingButton(4);
            }
            else if (cursorPos == CursorPositions.Hints)
            {
                if (optionSettings.displayHints)
                {
                    checkmark.GetComponent <Image>().enabled = false;
                    optionSettings.displayHints = false;
                }
                else
                {
                    checkmark.GetComponent <Image>().enabled = true;
                    optionSettings.displayHints = true;
                }
            }



            else if (cursorPos == CursorPositions.Back)
            {
                mainMenuController.optionsOpen = false;
            }
        }


        if (mainMenuController.optionsOpen)
        {
            _canvasGroup.alpha = optionsAlpha;
            if (optionsAlpha < 1)
            {
                optionsAlpha += Time.deltaTime * 3;
            }
            else if (Input.GetButtonDown("Cancel"))
            {
                mainMenuController.optionsOpen = false;
            }
        }
        else
        {
            _canvasGroup.alpha = optionsAlpha;
            if (optionsAlpha > 0)
            {
                optionsAlpha -= Time.deltaTime * 3;
            }
            else
            {
                mainMenuController.OptionsBack();
                gameObject.SetActive(false);
            }
        }
        cursorArrow.GetComponent <RectTransform>().anchoredPosition = Vector2.Lerp(cursorArrow.GetComponent <RectTransform>().anchoredPosition, new Vector2(cursorPositions[(int)cursorPos].anchoredPosition.x, cursorPositions[(int)cursorPos].anchoredPosition.y), cursorArrowSpeed * Time.deltaTime);

        if (Input.GetKeyDown(KeyCode.DownArrow) && !cursorCantMove)
        {
            if ((int)cursorPos < 9)
            {
                if ((int)cursorPos == 3)
                {
                    cursorPos = (CursorPositions)9;
                }
                else
                {
                    cursorPos++;
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.UpArrow) && !cursorCantMove)
        {
            if ((int)cursorPos > 0)
            {
                if ((int)cursorPos == 9)
                {
                    cursorPos = (CursorPositions)3;
                }
                else if ((int)cursorPos == 4)
                {
                    cursorPos = (CursorPositions)0;
                }
                else
                {
                    cursorPos--;
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.RightArrow) && !cursorCantMove)
        {
            if ((int)cursorPos < 4)
            {
                cursorPos += 4;
            }
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) && !cursorCantMove)
        {
            if ((int)cursorPos > 3 && (int)cursorPos < 8)
            {
                if ((int)cursorPos == 4)
                {
                    cursorPos = (CursorPositions)1;
                }
                else
                {
                    cursorPos -= 4;
                }
            }
            else if ((int)cursorPos == 8)
            {
                cursorPos -= 5;
            }
        }


        if (PressAnyKeyPanel.activeSelf)
        {
            if (Input.anyKeyDown)
            {
                foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
                {
                    if (Input.GetKeyDown(kcode))
                    {
                        if (keyBinding == KeyBinding.Jump)
                        {
                            jumpKey.text        = kcode.ToString();
                            InputManager.JumpTD = kcode;
                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.Slash)
                        {
                            slashKey.text      = kcode.ToString();
                            InputManager.Slash = kcode;
                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.Shuriken)
                        {
                            shurikenKey.text      = kcode.ToString();
                            InputManager.Shuriken = kcode;
                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.GrapplingHook)
                        {
                            grapplingHookKey.text = kcode.ToString();
                            InputManager.Hook     = kcode;
                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.SmokeBomb)
                        {
                            smokeBombKey.text      = kcode.ToString();
                            InputManager.SmokeBomb = kcode;
                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                    }
                }
            }
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(InputManager.Slash) || Input.GetKeyDown(InputManager.JSlash))
        {
            if (cursorPos == CursorPositions.Jump)
            {
                KeyBindingButton(0);
            }
            else if (cursorPos == CursorPositions.Slash)
            {
                KeyBindingButton(1);
            }
            else if (cursorPos == CursorPositions.Shuriken)
            {
                KeyBindingButton(2);
            }
            else if (cursorPos == CursorPositions.GrapplingHook)
            {
                KeyBindingButton(3);
            }
            else if (cursorPos == CursorPositions.SmokeBomb)
            {
                KeyBindingButton(4);
            }
            else if (cursorPos == CursorPositions.Hints)
            {
                if (optionSettings.displayHints)
                {
                    checkmark.GetComponent <Image>().enabled = false;
                    optionSettings.displayHints = false;
                }
                else
                {
                    checkmark.GetComponent <Image>().enabled = true;
                    optionSettings.displayHints = true;
                }
            }



            else if (cursorPos == CursorPositions.Back)
            {
                mainMenuController.optionsOpen = false;
            }
        }


        if (mainMenuController.optionsOpen)
        {
            _canvasGroup.alpha = optionsAlpha;
            if (optionsAlpha < 1)
            {
                optionsAlpha += Time.deltaTime * 3;
            }
            else if (Input.GetButtonDown("Cancel"))
            {
                mainMenuController.optionsOpen = false;
            }
        }
        else
        {
            _canvasGroup.alpha = optionsAlpha;
            if (optionsAlpha > 0)
            {
                optionsAlpha -= Time.deltaTime * 3;
            }
            else
            {
                mainMenuController.OptionsBack();
                gameObject.SetActive(false);
            }
        }
        cursorArrow.GetComponent <RectTransform>().anchoredPosition = Vector2.Lerp(cursorArrow.GetComponent <RectTransform>().anchoredPosition, new Vector2(cursorPositions[(int)cursorPos].anchoredPosition.x, cursorPositions[(int)cursorPos].anchoredPosition.y), cursorArrowSpeed * Time.deltaTime);

        if (Input.GetAxisRaw("Vertical") != 0 && !cursorCantMove)
        {
            if (!vAxisInUse && Input.GetAxisRaw("Vertical") < 0)
            {
                vAxisInUse = true;
                if ((int)cursorPos < 9)
                {
                    mainMenuController.sound.PlayOneShot(mainMenuController.buttonHover);
                    if ((int)cursorPos == 3)
                    {
                        cursorPos = (CursorPositions)9;
                    }
                    else
                    {
                        cursorPos++;
                    }
                }
            }
            else if (!vAxisInUse && Input.GetAxisRaw("Vertical") > 0)
            {
                vAxisInUse = true;
                if ((int)cursorPos > 0)
                {
                    mainMenuController.sound.PlayOneShot(mainMenuController.buttonHover);
                    if ((int)cursorPos == 9)
                    {
                        cursorPos = (CursorPositions)3;
                    }
                    else if ((int)cursorPos == 4)
                    {
                        cursorPos = (CursorPositions)0;
                    }
                    else
                    {
                        cursorPos--;
                    }
                }
            }
        }
        else if (Input.GetAxisRaw("Vertical") == 0)
        {
            vAxisInUse = false;
        }



        if (Input.GetAxisRaw("Horizontal") != 0 && !cursorCantMove)
        {
            if (!hAxisInUse && Input.GetAxisRaw("Horizontal") > 0)
            {
                hAxisInUse = true;
                if ((int)cursorPos < 4)
                {
                    mainMenuController.sound.PlayOneShot(mainMenuController.buttonHover);
                    cursorPos += 4;
                }
            }
            else if (!hAxisInUse && Input.GetAxisRaw("Horizontal") < 0)
            {
                hAxisInUse = true;
                if ((int)cursorPos > 3 && (int)cursorPos < 8)
                {
                    mainMenuController.sound.PlayOneShot(mainMenuController.buttonHover);
                    if ((int)cursorPos == 4)
                    {
                        cursorPos = (CursorPositions)1;
                    }
                    else
                    {
                        cursorPos -= 4;
                    }
                }
                else if ((int)cursorPos == 8)
                {
                    mainMenuController.sound.PlayOneShot(mainMenuController.buttonHover);
                    cursorPos -= 5;
                }
            }
        }
        else if (Input.GetAxisRaw("Horizontal") == 0)
        {
            hAxisInUse = false;
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow) && !cursorCantMove)
        {
        }


        if (PressAnyKeyPanel.activeSelf)
        {
            bool joyKey = false;
            if (Input.anyKeyDown)
            {
                foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
                {
                    for (int i = 0; i < 20; i++)
                    {
                        //print(kcode.ToString());
                        if (Input.GetKeyDown("joystick 1 button " + i))
                        {
                            joyKey = true;
                        }
                    }



                    if (Input.GetKeyDown(kcode))
                    {
                        if (keyBinding == KeyBinding.Jump)
                        {
                            if (!joyKey)
                            {
                                jumpKey.text        = kcode.ToString();
                                InputManager.JumpTD = kcode;
                            }
                            else
                            {
                                jjumpKey.text        = kcode.ToString().Remove(0, 9);
                                InputManager.JJumpTD = kcode;
                            }
                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.Slash)
                        {
                            if (!joyKey)
                            {
                                slashKey.text      = kcode.ToString();
                                InputManager.Slash = kcode;
                            }
                            else
                            {
                                jslashKey.text      = kcode.ToString().Remove(0, 9);
                                InputManager.JSlash = kcode;
                            }

                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.Shuriken)
                        {
                            if (!joyKey)
                            {
                                shurikenKey.text      = kcode.ToString();
                                InputManager.Shuriken = kcode;
                            }
                            else
                            {
                                jshurikenKey.text      = kcode.ToString().Remove(0, 9);
                                InputManager.JShuriken = kcode;
                            }

                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.GrapplingHook)
                        {
                            if (!joyKey)
                            {
                                grapplingHookKey.text = kcode.ToString();
                                InputManager.Hook     = kcode;
                            }
                            else
                            {
                                jgrapplingHookKey.text = kcode.ToString().Remove(0, 9);
                                InputManager.JHook     = kcode;
                            }

                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                        else if (keyBinding == KeyBinding.SmokeBomb)
                        {
                            if (!joyKey)
                            {
                                smokeBombKey.text      = kcode.ToString();
                                InputManager.SmokeBomb = kcode;
                            }
                            else
                            {
                                jsmokeBombKey.text      = kcode.ToString().Remove(0, 9);
                                InputManager.JSmokeBomb = kcode;
                            }

                            InputManager.SaveKeys();
                            Invoke("SmallDelayToClose", 0.05f);
                        }
                    }
                }
            }
        }
    }