Ejemplo n.º 1
0
 bool TryPunch()
 {
     if (!hasObject)
     {
         if (XCI.GetButtonDown(XboxButton.X, playerNumber))
         {
             startRunParticle.Stop();
             SetState(PlayerStates.Punch);
             punchingVO();
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
    // MovePlayer ()
    // Called whenever MovePlayer is called.
    // Return:
    //     Void
    private void MovePlayer()
    {
        float axisX = XCI.GetAxis(XboxAxis.LeftStickX, controller);
        float axisZ = XCI.GetAxis(XboxAxis.LeftStickY, controller);

        Vector3 movement = new Vector3(axisX, 0, axisZ);

        rigidBody.AddForce(movement * movementSpeed);

        if (rigidBody.velocity.magnitude > maxSpeed)
        {
            rigidBody.velocity = rigidBody.velocity.normalized * maxSpeed;
        }
    }
Ejemplo n.º 3
0
        public override void Update(XboxController controller)
        {
            // aim
            Vector3 aimDirection = Vector3.zero;

            if (XCI.GetAxisRaw(XboxAxis.RightStickX, controller) != 0 || XCI.GetAxisRaw(XboxAxis.RightStickY, controller) != 0)
            {
                aimDirection = new Vector3(XCI.GetAxisRaw(XboxAxis.RightStickX, controller), 0, XCI.GetAxisRaw(XboxAxis.RightStickY, controller));
            }

            _characterController.Aim(aimDirection.normalized);

            base.Update(controller);
        }
Ejemplo n.º 4
0
    private void Update()
    {
        if (bulletCount <= 0)
        {
            wPUP.DisablePowerUp(powerUpNum);
        }


        if (XCI.GetButtonDown(XboxButton.A, controller) && Time.time >= nextTimeToFire)
        {
            nextTimeToFire = Time.time + 1f / fireRate;
            Shoot();
        }
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        // Dev keyboard controls
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            ToggleObjects();
        }
        // if the pause menu is active and the controller that paused it presses the start button
        if (m_active && XCI.GetButtonDown(XboxButton.Start, m_inputModule.m_controller))
        {
            ToggleObjects();

            m_inputModule.m_controller = XboxController.All; // set the current controller back to all
        }
        // for each controller
        for (int i = 1; i <= 4; i++)
        {
            // if the menu is not active
            if (!m_active)
            {
                // if any controller presses the start button
                if (XCI.GetButtonDown(XboxButton.Start, (XboxController)i))
                {
                    ToggleObjects();

                    m_inputModule.m_controller = (XboxController)i; // set the controller that has control of the pause menu to the one that pressed start
                }
            }
        }

        // if the pause menu is active
        if (m_active)
        {
            // if the user presses the back button
            if (XCI.GetButtonDown(XboxButton.B, m_inputModule.m_controller))
            {
                // if the options menu is open
                if (m_optionOpen)
                {
                    BackButton(); // return to the pause menu
                }
                else
                {
                    ToggleObjects(); // deactivate the pause menu
                }
            }
        }

        m_toggledThisFrame = false;
    }
Ejemplo n.º 6
0
 public void GetBButton(int playerNumber, bool playerTeam, UISprite aButtonCover, ref bool joined)
 {
     if (XCI.GetButtonDown(XboxButton.B, playerNumber))
     {
         if (!playerTeam)
         {
             //PLAYS BUTTON PRESS DOWN SFX :)
             AudioController.Play("UI_ButtonPressDown");
             aButtonCover.GetComponent <TweenColor>().enabled = true;
             aButtonCover.GetComponent <TweenColor>().PlayReverse();
             joined = false;
         }
     }
 }
Ejemplo n.º 7
0
 void InvertY()
 {
     if (XCI.GetButtonDown(XboxButton.Y))
     {
         if (invertY == false)
         {
             invertY = true;
         }
         else
         {
             invertY = false;
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Checks if shoot inputs have been pressed / released. Sets the animator accordingly.
 /// </summary>
 void CheckInputs()
 {
     if (XCI.GetButtonDown(XboxButton.X, myController.GetID()) || Input.GetKeyDown(KeyCode.F))
     {
         myController.SetCharging(true);
         strength = minStrength;
         // TODO: shot feints in pass
     }
     else if (XCI.GetButtonUp(XboxButton.X, myController.GetID()) || Input.GetKeyUp(KeyCode.F))
     {
         myController.SetCharging(false);
         shoot = true;
     }
 }
Ejemplo n.º 9
0
 public static bool GetAnyStartButtonDown()
 {
     if (XCI.GetNumPluggedCtrlrs() > 0)
     {
         for (int i = 0; i < XCI.GetNumPluggedCtrlrs(); ++i)
         {
             if (XCI.GetButtonDown(XboxButton.Start, i + 1))
             {
                 return(true);
             }
         }
     }
     return(Input.GetKeyDown("space") || Input.GetKeyDown("enter"));
 }
Ejemplo n.º 10
0
 void Start()
 {
     playerController = GetComponent <PlayerController> ();
     if (playerNum > GameRoundManager.instance.numPlayers)
     {
         Destroy(gameObject);
     }
     else if (playerNum > XCI.GetNumPluggedCtrlrs())
     {
         GetComponent <AIPlayer> ().enabled = true;
         GetComponent <Player> ().enabled   = false;
     }
     //Debug.Log(XCI.GetNumPluggedCtrlrs() + " Xbox controllers plugged in.");
 }
Ejemplo n.º 11
0
    //------------------------------------------------------------
    // Function allows for the Striker to rotate
    //------------------------------------------------------------
    private void Rotate()
    {
        // Only runs if the striker is not performing their special
        if (!strikerDoingSpecial)
        {
            // Both floats get direction of the Xbox controller's right stick
            float rotateAxisX = XCI.GetAxisRaw(XboxAxis.RightStickX, Controller);
            float rotateAxisZ = XCI.GetAxisRaw(XboxAxis.RightStickY, Controller);

            // Checks if the right stick is at default position on the x axis
            if (rotateAxisX == 0f)
            {
                // If so, set the rotation x to be the previous frame's rotation x
                rotateAxisX = prevRotateX;
            }

            // Otherwise store current rotate x into the previous frame rotate x
            else
            {
                prevRotateX = rotateAxisX;
            }

            // Checks if the right stick is at default position on the y axis
            if (rotateAxisZ == 0f)
            {
                // If so, set the rotation z to be the previous frame's rotation z
                rotateAxisZ = prevRotateZ;
            }

            // Otherwise store current rotate z into the previous frame rotate z
            else
            {
                prevRotateZ = rotateAxisZ;
            }

            // Checks if either rotate x isn't zero or rotate z isn't zero
            if (rotateAxisX != 0 || rotateAxisZ != 0)
            {
                // If one variable isn't zero, create a "new" Vector3 refering to looking direction
                Vector3 directionVector = new Vector3(rotateAxisX, 0, rotateAxisZ);

                // Allows for the striker to look in same direction as right stick's position
                transform.rotation = Quaternion.LookRotation(directionVector);
            }

            // Sets the angular velocity of the Striker to be zero
            rigidBody.angularVelocity = Vector3.zero;
        }
    }
Ejemplo n.º 12
0
    private void CalculateCurrentSpeed()
    {
        movementSpeed = powerBar.GetComponent <ItemPowerBar>().GetSpeed(minimumSpeed, maximumSpeed) * boostBonus;               //calculate current max speed that can be reached
//		float rightTriggerPressed = XboxCtrlrInput.XCI.GetAxis (XboxCtrlrInput.XboxAxis.RightTrigger, controllerNumber);
        float leftTriggerPressed = XboxCtrlrInput.XCI.GetAxis(XboxCtrlrInput.XboxAxis.LeftTrigger, controllerNumber);


        if (leftTriggerPressed == 1f && !(XCI.GetButton(XboxButton.LeftBumper, controllerNumber)))                                      //if the accelerator is pressed (and not the reverse button)
        {
            if (currentSpeed != movementSpeed)                                                                                          //if has not reached the max speed
            {
                currentSpeed += (movementSpeed - currentSpeed) / 150;                                                                   //add to the speed of the car
                if (currentSpeed > movementSpeed)                                                                                       //if adding exceeds the max speed - remove it
                {
                    currentSpeed = movementSpeed;
                }
            }
        }
        else if (leftTriggerPressed == 0f && !(XCI.GetButton(XboxButton.LeftBumper, controllerNumber)))                         //if the accelerator is NOT pressed (and not the reverse button)
        {
            if (currentSpeed != 0)                                                                                              //if there is speed in the car's movement
            {
                currentSpeed -= (currentSpeed) / 15;                                                                            //reduce the speed of the car
                if (currentSpeed < 0)                                                                                           //if remove speed drops beneath 0 - reset to 0
                {
                    currentSpeed = 0;
                }
            }
        }
        else if (XCI.GetButton(XboxButton.LeftBumper, controllerNumber))                                //if reverse button is pressed
        {
            if (currentSpeed > -maxReverseSpeed)                                                        //if the current speed is higher than the max reversing speed
            {
                if (currentSpeed > 15)                                                                  //if still going at a good forward speed
                {
                    currentSpeed -= (currentSpeed) / 25;                                                //then effectively break
                }
                else
                {
                    if (currentSpeed > -maxReverseSpeed)                                                                        //if speed drops below the max breaking speed - reset to maxBreakSpeed
                    {
                        currentSpeed += -(maxReverseSpeed) / 10;
                    }
                }
            }
        }

        xAxis = 1 * currentSpeed;
    }
Ejemplo n.º 13
0
    void tiltCharacter()
    {
        //gets references to the left stick input of the controller
        float axisX = XCI.GetAxis(XboxAxis.LeftStickX, controller);
        float axisY = XCI.GetAxis(XboxAxis.LeftStickY, controller);

        //if the control stick is pushed 40% of the way to the right
        if (axisX >= 0.4)
        {
            //sets the animation state to moving  right
            characterAnim.SetBool("MovingLeft", false);
            characterAnim.SetBool("MovingRight", true);
        }
        //if the control stick is pushed 40% of the way to the left
        else if (axisX <= -0.4)
        {
            //sets the animation state to moving left
            characterAnim.SetBool("MovingRight", false);
            characterAnim.SetBool("MovingLeft", true);
        }
        //if neither
        else
        {
            //sets the animation state to idle
            characterAnim.SetBool("MovingRight", false);
            characterAnim.SetBool("MovingLeft", false);
        }
        //if the control stick is pushed 40% of the way upwards
        if (axisY >= 0.4)
        {
            //sets the animation state to moving forward
            characterAnim.SetBool("MovingForward", true);
            characterAnim.SetBool("MovingBackward", false);
        }
        //if the control stick is pushed 40% of the way downwards
        else if (axisY <= -0.4)
        {
            //sets the animation state to moving backwards
            characterAnim.SetBool("MovingForward", false);
            characterAnim.SetBool("MovingBackward", true);
        }
        //if neither
        else
        {
            //sets the animation state to idle
            characterAnim.SetBool("MovingForward", false);
            characterAnim.SetBool("MovingBackward", false);
        }
    }
Ejemplo n.º 14
0
 // Gets the axis values then applys it to the movement vector with the players direction.
 private void UpdateMoveVector()
 {
     if (playerHandler.AssignedController > 0)
     {
         horizontalAxis = XCI.GetAxis(XboxAxis.LeftStickX, playerHandler.AssignedController);
         verticalAxis   = XCI.GetAxis(XboxAxis.LeftStickY, playerHandler.AssignedController);
     }
     else
     {
         horizontalAxis = Input.GetAxisRaw("Horizontal");
         verticalAxis   = Input.GetAxisRaw("Vertical");
     }
     moveDirection = (horizontalAxis * transform.right) + (verticalAxis * transform.forward);
     moveDirection.Normalize();
 }
Ejemplo n.º 15
0
 public void RaiseVolume()
 {
     Debug.Log("Increasing volume");
     if (volume < 100f)
     {
         volume += Time.deltaTime * volumeSpeed * XCI.GetAxis(XboxAxis.LeftStickX);
     }
     else
     {
         volume = 100f;
     }
     volumeSlider.value = volume;
     //audioSource.volume = (volume/100);
     mixer.SetFloat("MasterVolume", GetDBValueFromVolume(volume));
 }
Ejemplo n.º 16
0
 private void Update()
 {
     if (XCI.GetButton(XboxButton.A, controller))
     {
         Shoot();
     }
     if (XCI.GetButtonUp(XboxButton.A, controller))
     {
         flame.Stop();
         if (flame2)
         {
             flame2.Stop();
         }
     }
 }
Ejemplo n.º 17
0
 //----------------------------------------------------------------------
 //		PlayerShoot()
 // Lets the player shoot normal bullet
 //
 // Param:
 //          None
 // Return;
 //          Void
 //----------------------------------------------------------------------
 private void PlayerShoot()
 {
     if (XCI.GetAxis(XboxAxis.RightTrigger, controller) != 0)
     {
         if (canShoot == true)
         {
             GameObject Go = Instantiate(bullet, bulletSpawnPoint1.transform.position, ship.transform.rotation) as GameObject;
             Go.GetComponent <Rigidbody> ().AddForce(transform.forward * 100, ForceMode.Impulse);
             GameObject Go2 = Instantiate(bullet, bulletSpawnPoint2.transform.position, ship.transform.rotation) as GameObject;
             Go2.GetComponent <Rigidbody> ().AddForce(transform.forward * 100, ForceMode.Impulse);
             canShoot = false;
             Invoke("ResetShootBool", timeBetweenShots);
         }
     }
 }
Ejemplo n.º 18
0
    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    // load the next scene and start the game if Start is pressed by at least 2 people
    public void StartGame()
    {
        if (XCI.GetButtonDown(XboxButton.Start))                                            // when start is pressed...
        {
            CountPlayers();                                                                 // counts the number of players who have readied up
            if (playerCounter >= 2)                                                         // if at least 2 players have readied up...
            {
                if (SceneManager.GetActiveScene().name == "MainMenu")                       // if start is pressed and the current scene is "Main Menu"...
                {
                    SceneManager.LoadScene("Main_001_TunnelMiddle", LoadSceneMode.Single);  // loads the level
                }
            }
            playerCounter = 0;                                                              // sets the player count to 0, so it doesn't interfere the next time you press "Start" to start the game
        }
    }
Ejemplo n.º 19
0
 int DpadHorizontalTest()
 {
     for (int i = 0; i < (int)PlayerIndex.Four; ++i)
     {
         if (XCI.GetButtonDown(XboxButton.DPadRight, XboxController.First + i))
         {
             return(1);
         }
         else if (XCI.GetButtonDown(XboxButton.DPadLeft, XboxController.First + i))
         {
             return(-1);
         }
     }
     return(0);
 }
Ejemplo n.º 20
0
 // Update is called once per frame
 void Update()
 {
     if (XCI.GetButtonDown(XboxButton.A))
     {
         if (state == 0)
         {
             ground.sprite = secondSprite;
         }
         else
         {
             SceneManager.LoadScene("level");
         }
         state++;
     }
 }
Ejemplo n.º 21
0
 /*
  * Override of the base GetButtonDown to use xInput
  */
 public override bool GetButtonDown(string buttonName)
 {
     if (buttonName == "Submit")
     {
         return(XCI.GetButtonDown(XboxButton.A, m_controller));
     }
     else if (buttonName == "Cancel")
     {
         return(XCI.GetButtonDown(XboxButton.B, m_controller));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 22
0
 /*
  * Override of the base GetAxisRaw to use xInput
  */
 public override float GetAxisRaw(string axisName)
 {
     if (axisName == "Horizontal")
     {
         return(XCI.GetAxisRaw(XboxAxis.LeftStickX, m_controller));
     }
     else if (axisName == "Vertical")
     {
         return(XCI.GetAxisRaw(XboxAxis.LeftStickY, m_controller));
     }
     else
     {
         return(0);
     }
 }
Ejemplo n.º 23
0
    public void ReturnToMenu()
    {
        XboxController controller = XboxController.First;

        for (int i = 0; i < Menus.GetMaxNumOfPlayers(); i++)
        {
            if (XCI.GetButtonDown(XboxButton.Back, controller) || XCI.GetButtonDown(XboxButton.B, controller))
            {
                m_creditsMenu.SetActive(false);
                m_MainMenu.SetActive(true);
            }

            controller++;
        }
    }
Ejemplo n.º 24
0
    /* ========= Public Helper Methods ========= */

    public int GetNumPlayers()
    {
        int numCtrls = XCI.GetNumPluggedCtrlrs();

        if (numCtrls == 0)
        {
            // due to keyboard input
            return(1);
        }
        if (numCtrls > MAX_NUM_PLAYERS)
        {
            return(MAX_NUM_PLAYERS);
        }
        return(numCtrls);
    }
Ejemplo n.º 25
0
 // Update is called once per frame
 void Update()
 {
     if (XCI.GetButtonUp(XboxButton.Start))
     {
         onPause = !onPause;
     }
     if (onPause)
     {
         Time.timeScale = 0;
     }
     else
     {
         Time.timeScale = 1;
     }
 }
Ejemplo n.º 26
0
    private void ReadyUp()
    {
        for (int i = 0; i < Menus.GetActivatedPlayerAmount(); i++)
        {
            StaticVariables holder = Menus.GetPlayerInformation(i);
            XboxController controller = holder.Controller;

            if (XCI.GetButtonDown(XboxButton.Y, controller))
            {
                holder.IsReady = true;
                m_listOfUI[i].GetComponent<ConfirmController>().ChangeConfirmState(holder.IsReady);
                LockedIn(holder);
            }
        }
    }
Ejemplo n.º 27
0
    // Update is called once per frame
    void Update()
    {
        GameObject go = GameObject.FindGameObjectWithTag("LookAtMe");

        //Calls cam Rotate function
        CameraRotate();
        clampedPosition   = transform.position;
        clampedPosition.y = Mathf.Clamp(transform.position.y, player.transform.position.y, player.transform.position.y + 8);

        Offset = Quaternion.AngleAxis(XCI.GetAxis(XboxAxis.RightStickX) * 3, Vector3.up) * Offset;

        transform.position = clampedPosition = player.transform.position + Offset;
        transform.LookAt(player.transform.position);
        guide.transform.position = player.transform.position;
    }
Ejemplo n.º 28
0
    // Update is called once per frame
    void Update()
    {
        int id = myController.GetID();

        if (canBomb && (Input.GetButtonDown("Fire" + id) || XCI.GetButtonDown(XboxButton.A, id)))
        {
            GameObject newBomb = Instantiate(bombPrefab) as GameObject;
            newBomb.transform.parent = level;
            audio.PlayOneShot(sound);
            newBomb.transform.localPosition = transform.localPosition + (transform.right / 5f);
            newBomb.transform.localScale    = transform.localScale;
            newBomb.transform.FindChild("Explosion").GetComponent <Explosion>().sender = myController;
            StartCoroutine(SetCooldown());
        }
    }
Ejemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        if (XCI.GetButtonDown(XboxButton.A))
        {
            elementController.SetSelectedElement(Element.Seed);
        }

        if (XCI.GetAxis(XboxAxis.RightTrigger) > 0.1f)
        {
            if (elementController.IsSelectedElementSeed())
            {
                SpawnPlant();
            }
        }
    }
Ejemplo n.º 30
0
 void Update()
 {
     if (XCI.GetButtonDown(XboxButton.RightBumper, Controller))
     {
         Fire();
     }
     if (XCI.GetAxis(XboxAxis.RightStickX, Controller) < 0)
     {
         transform.Rotate(0, -Speed, 0);
     }
     if (XCI.GetAxis(XboxAxis.RightStickX, Controller) > 0)
     {
         transform.Rotate(0, Speed, 0);
     }
 }