// Update is called once per frame
    void Update()
    {
        //updates controller inputs
        ControllerPluginWrapper.UpdateControllers();

        //resets player movement when stick is not being used
        direction.Set(0, 0, 0);
        lookDirection.Set(0, 0, 0);

        //gets the x and y values from the controller analog sticks
        if (!ControllerPluginWrapper.LStick_InDeadZone(0))
        {
            direction.x = ControllerPluginWrapper.LeftStick_X(0);
            direction.z = ControllerPluginWrapper.LeftStick_Y(0);
        }

        if (!ControllerPluginWrapper.RStick_InDeadZone(0))
        {
            lookDirection.x = ControllerPluginWrapper.RightStick_X(0);
            lookDirection.z = ControllerPluginWrapper.RightStick_Y(0);
        }

        //equations for movement and rotation
        player.transform.Translate(direction * speed * Time.deltaTime);
        player.transform.Rotate(upVector * lookDirection.x * rotationSpeed);
        camera.transform.Rotate(rightVector * -lookDirection.z * rotationSpeed);

        //save controller states as previous actions for next frame
        ControllerPluginWrapper.RefreshStates();
    }
 // Use this for initialization
 void Start()
 {
     //initialzing variables
     direction.Set(0, 0, 0);
     upVector.Set(0, 1, 0);
     rightVector.Set(1, 0, 0);
     ControllerPluginWrapper.Initiate();
     rigidbody = player.GetComponent <Rigidbody>();
 }
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     info   = GetComponent <Info>();
     spells = GetComponent <SpellInventory>();
     ControllerPluginWrapper.Initiate();
     deadPosition = new Vector3(0, -10, 0);
     alive        = true;
     respawnTimer = 5.0f;
 }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        ControllerPluginWrapper.UpdateControllers();

        if (!initiated)
        {
            initiate();
        }

        if ((previousHealth != info.getHealth()) && (info.getHealth() > 0))
        {
Beispiel #5
0
        public void HandleInputs()
        {
            GameObject.Find("Prompt").GetComponent <Text>().text = "";

            //perform action linked to x button
            if (ControllerPluginWrapper.GetButtonDown(0, 0))
            {
                if ((XButton.getCommand() != "DoNothing") && (XButton.getCommand() != "Jump") && (XButton.getCommand() != "UndoButton") && (XButton.getCommand() != "RemapButton"))
                {
                    inputs.Push(XButton);
                }


                cooldown = maxCD;
                XButton.Execute(player, inputs.Peek());

                if (XButton.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (XButton.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to circle button
            else if (ControllerPluginWrapper.GetButtonDown(0, 1))
            {
                if ((CircleButton.getCommand() != "DoNothing") && (CircleButton.getCommand() != "Jump") && (CircleButton.getCommand() != "UndoButton") && (CircleButton.getCommand() != "RemapButton"))
                {
                    inputs.Push(CircleButton);
                }

                cooldown = maxCD;
                CircleButton.Execute(player, inputs.Peek());

                if (CircleButton.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (CircleButton.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to square button
            else if (ControllerPluginWrapper.GetButtonDown(0, 2))
            {
                if ((SquareButton.getCommand() != "DoNothing") && (SquareButton.getCommand() != "Jump") && (SquareButton.getCommand() != "UndoButton") && (SquareButton.getCommand() != "RemapButton"))
                {
                    inputs.Push(SquareButton);
                }

                cooldown = maxCD;
                SquareButton.Execute(player, inputs.Peek());

                if (SquareButton.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (SquareButton.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to triangle button
            else if (ControllerPluginWrapper.GetButtonDown(0, 3))
            {
                if ((TriangleButton.getCommand() != "DoNothing") && (TriangleButton.getCommand() != "Jump") && (TriangleButton.getCommand() != "UndoButton") && (TriangleButton.getCommand() != "RemapButton"))
                {
                    inputs.Push(TriangleButton);
                }

                cooldown = maxCD;
                TriangleButton.Execute(player, inputs.Peek());

                if (TriangleButton.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (TriangleButton.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to up on directional pad
            else if (ControllerPluginWrapper.GetButtonDown(0, 4))
            {
                if ((DPadUp.getCommand() != "DoNothing") && (DPadUp.getCommand() != "Jump") && (DPadUp.getCommand() != "UndoButton") && (DPadUp.getCommand() != "RemapButton"))
                {
                    inputs.Push(DPadUp);
                }

                cooldown = maxCD;
                DPadUp.Execute(player, inputs.Peek());

                if (DPadUp.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (DPadUp.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to down on directional pad
            else if (ControllerPluginWrapper.GetButtonDown(0, 5))
            {
                if ((DPadDown.getCommand() != "DoNothing") && (DPadDown.getCommand() != "Jump") && (DPadDown.getCommand() != "UndoButton") && (DPadDown.getCommand() != "RemapButton"))
                {
                    inputs.Push(DPadDown);
                }

                cooldown = maxCD;
                DPadDown.Execute(player, inputs.Peek());

                if (DPadDown.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (DPadDown.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to left on directional pad
            else if (ControllerPluginWrapper.GetButtonDown(0, 6))
            {
                if ((DPadLeft.getCommand() != "DoNothing") && (DPadLeft.getCommand() != "Jump") && (DPadLeft.getCommand() != "UndoButton") && (DPadLeft.getCommand() != "RemapButton"))
                {
                    inputs.Push(DPadLeft);
                }

                cooldown = maxCD;
                DPadLeft.Execute(player, inputs.Peek());

                if (DPadLeft.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (DPadLeft.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to right on directional pad
            else if (ControllerPluginWrapper.GetButtonDown(0, 7))
            {
                if ((DPadRight.getCommand() != "DoNothing") && (DPadRight.getCommand() != "Jump") && (DPadRight.getCommand() != "UndoButton") && (DPadRight.getCommand() != "RemapButton"))
                {
                    inputs.Push(DPadRight);
                }

                cooldown = maxCD;
                DPadRight.Execute(player, inputs.Peek());

                if (DPadRight.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (DPadRight.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to left bumper
            else if (ControllerPluginWrapper.GetButtonDown(0, 8))
            {
                if ((L1.getCommand() != "DoNothing") && (L1.getCommand() != "Jump") && (L1.getCommand() != "UndoButton") && (L1.getCommand() != "RemapButton"))
                {
                    inputs.Push(L1);
                }

                cooldown = maxCD;
                L1.Execute(player, inputs.Peek());

                if (L1.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (L1.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to right bumper
            else if (ControllerPluginWrapper.GetButtonDown(0, 9))
            {
                if ((R1.getCommand() != "DoNothing") && (R1.getCommand() != "Jump") && (R1.getCommand() != "UndoButton") && (R1.getCommand() != "RemapButton"))
                {
                    inputs.Push(R1);
                }

                cooldown = maxCD;
                R1.Execute(player, inputs.Peek());

                if (R1.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (R1.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to left stick pressed
            else if (ControllerPluginWrapper.GetButtonDown(0, 10))
            {
                if ((LStickPress.getCommand() != "DoNothing") && (LStickPress.getCommand() != "Jump") && (LStickPress.getCommand() != "UndoButton") && (LStickPress.getCommand() != "RemapButton"))
                {
                    inputs.Push(LStickPress);
                }

                cooldown = maxCD;
                LStickPress.Execute(player, inputs.Peek());

                if (LStickPress.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (LStickPress.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to right stick pressed
            else if (ControllerPluginWrapper.GetButtonDown(0, 11))
            {
                if ((RStickPress.getCommand() != "DoNothing") && (RStickPress.getCommand() != "Jump") && (RStickPress.getCommand() != "UndoButton") && (RStickPress.getCommand() != "RemapButton"))
                {
                    inputs.Push(RStickPress);
                }

                cooldown = maxCD;
                RStickPress.Execute(player, inputs.Peek());

                if (RStickPress.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (RStickPress.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to start button
            else if (ControllerPluginWrapper.GetButtonDown(0, 12))
            {
                if ((Pause.getCommand() != "DoNothing") && (Pause.getCommand() != "Jump") && (Pause.getCommand() != "UndoButton") && (Pause.getCommand() != "RemapButton"))
                {
                    inputs.Push(Pause);
                }

                cooldown = maxCD;
                Pause.Execute(player, inputs.Peek());

                if (Pause.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (Pause.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to back button
            else if (ControllerPluginWrapper.GetButtonDown(0, 13))
            {
                if ((Select.getCommand() != "DoNothing") && (Select.getCommand() != "Jump") && (Select.getCommand() != "UndoButton") && (Select.getCommand() != "RemapButton"))
                {
                    inputs.Push(Select);
                }

                cooldown = maxCD;
                Select.Execute(player, inputs.Peek());

                if (Select.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (Select.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to right trigger
            else if (ControllerPluginWrapper.RightTrigger(0) > 0.1f)
            {
                if ((RightTrigger.getCommand() != "DoNothing") && (RightTrigger.getCommand() != "Jump") && (RightTrigger.getCommand() != "UndoButton") && (RightTrigger.getCommand() != "RemapButton"))
                {
                    inputs.Push(RightTrigger);
                }

                cooldown = maxCD;
                RightTrigger.Execute(player, inputs.Peek());

                if (RightTrigger.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (RightTrigger.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }

            //perform action linked to left trigger
            else if (ControllerPluginWrapper.LeftTrigger(0) > 0.1f)
            {
                if ((LeftTrigger.getCommand() != "DoNothing") && (LeftTrigger.getCommand() != "Jump") && (LeftTrigger.getCommand() != "UndoButton") && (LeftTrigger.getCommand() != "RemapButton"))
                {
                    inputs.Push(LeftTrigger);
                }

                cooldown = maxCD;
                LeftTrigger.Execute(player, inputs.Peek());

                if (LeftTrigger.getCommand() == "UndoButton")
                {
                    inputs.Pop();
                }

                else if (LeftTrigger.getCommand() == "RemapButton")
                {
                    remapping = true;
                    ResetAllButtons();
                }
            }
        }
Beispiel #6
0
        //takes in the last button pressed
        public Command getNextButtonPress()
        {
            if (ControllerPluginWrapper.GetButtonDown(0, 0))
            {
                cooldown = maxCD;
                return(XButton);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 1))
            {
                cooldown = maxCD;
                return(CircleButton);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 2))
            {
                cooldown = maxCD;
                return(SquareButton);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 3))
            {
                cooldown = maxCD;
                return(TriangleButton);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 4))
            {
                cooldown = maxCD;
                return(DPadUp);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 5))
            {
                cooldown = maxCD;
                return(DPadDown);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 6))
            {
                cooldown = maxCD;
                return(DPadLeft);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 7))
            {
                cooldown = maxCD;
                return(DPadRight);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 8))
            {
                cooldown = maxCD;
                return(L1);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 9))
            {
                cooldown = maxCD;
                return(R1);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 10))
            {
                cooldown = maxCD;
                return(LStickPress);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 11))
            {
                cooldown = maxCD;
                return(RStickPress);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 12))
            {
                cooldown = maxCD;
                return(Pause);
            }

            else if (ControllerPluginWrapper.GetButtonDown(0, 13))
            {
                cooldown = maxCD;
                return(Select);
            }

            else if (ControllerPluginWrapper.LeftTrigger(0) > 0.9f)
            {
                cooldown = maxCD;
                return(LeftTrigger);
            }

            else if (ControllerPluginWrapper.RightTrigger(0) > 0.9f)
            {
                cooldown = maxCD;
                return(RightTrigger);
            }

            return(Blank);
        }