void FixedUpdate() { // get correct speed float forwardAndBackSpeed = walkSpeed; // if running, set run speed if (isRunning) { forwardAndBackSpeed = runSpeed; } // calculate how fast it should be moving //Vector3 targetVelocity = new Vector3(CheckMoveDirection(XCI.GetAxis(XboxAxis.LeftStickX,controllerNumber),transform.right) * strafeSpeed, 0,CheckMoveDirection(XCI.GetAxis(XboxAxis.LeftStickY,controllerNumber),transform.forward)* forwardAndBackSpeed); Vector3 targetVelocity = new Vector3(XCI.GetAxis(XboxAxis.LeftStickX, controllerNumber) * strafeSpeed, 0, XCI.GetAxis(XboxAxis.LeftStickY, controllerNumber) * forwardAndBackSpeed); targetVelocity = transform.TransformDirection(targetVelocity); // apply a force that attempts to reach our target velocity Vector3 velocity = GetComponent <Rigidbody>().velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.y = 0; GetComponent <Rigidbody>().AddForce(velocityChange, ForceMode.VelocityChange); // jump if (canJump && isGrounded && XCI.GetButton(XboxButton.A, controllerNumber)) { GetComponent <Rigidbody>().velocity = new Vector3(velocity.x, Mathf.Sqrt(2 * jumpHeight * gravity), velocity.z); isGrounded = false; } // apply gravity GetComponent <Rigidbody>().AddForce(new Vector3(0, -gravity * GetComponent <Rigidbody>().mass, 0)); }
public void Update() { // checks if both players controllers are true if (XboxController1.useController == true || XboxController2.useController == true) { // if the pause, game win and game over screens are not on the screen THEN if (pause.paused == false && manager.gameWin.winGameScreen.activeInHierarchy == false && manager.gameOver.DeathScreen.activeInHierarchy == false) { // the players can turn on the scoreboard screen // bringing up the score board if (XCI.GetButton(XboxButton.Back, XboxController1.controller) || XCI.GetButton(XboxButton.Back, XboxController2.controller)) { scoreBoard.SetActive(true); } // if the button is released the scoreboard will disappear from the screen else if (XCI.GetButtonUp(XboxButton.Back, XboxController1.controller) || XCI.GetButtonUp(XboxButton.Back, XboxController2.controller)) { scoreBoard.SetActive(false); } } } // updates both scores SizzleScoreBoard(); ChunkScoreBoard(); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player2" && XCI.GetButton(XboxButton.B, Controller)) { EnemyRigidBody.AddForce(new Vector3(50, 100, 0)); } }
// Update is called once per frame void Update() { if (XCI.GetButton(XboxButton.X, _ctlr) && sword_enabled && off_cooldown) { if (sword_range == 2) { ps_short.Play(); } else { ps_long.Play(); } box.enabled = true; off_cooldown = false; timer = cooldown_time; box.size = new Vector2(sword_range, .5f); box.offset = new Vector2(sword_range / 2, 0); if (sword_spins) { StartCoroutine(spin()); } Invoke("shut_down", sword_dur - .65f); } if (!box.enabled) { timer -= Time.deltaTime; } if (timer < 0) { off_cooldown = true; } }
private void Drift() { //Drift Steering if (XCI.GetButton(XboxButton.X)) { driftbool = true; steer = 0; steer = -XCI.GetAxis(XboxAxis.LeftStickX, controller) * driftSteer; wheelColliders[1].steerAngle = steer; wheelColliders[2].steerAngle = steer; wheelColliders[0].steerAngle = 0; wheelColliders[3].steerAngle = 0; } else { driftbool = false; steer = 0; steer = XCI.GetAxis(XboxAxis.LeftStickX, controller) * maxSteer; wheelColliders[1].steerAngle = 0; wheelColliders[2].steerAngle = 0; wheelColliders[0].steerAngle = steer; wheelColliders[3].steerAngle = steer; } }
private void DPadMovement() { //Movement based on individual keys (not using physics) //Create a temp pos based on your current pos Vector3 pos = transform.position; //Alter the temp pos if (XCI.GetButton(XboxButton.DPadUp, controller)) { pos.z += speed * Time.deltaTime; } if (XCI.GetButton(XboxButton.DPadDown, controller)) { pos.z -= speed * Time.deltaTime; } if (XCI.GetButton(XboxButton.DPadRight, controller)) { pos.x += speed * Time.deltaTime; } if (XCI.GetButton(XboxButton.DPadLeft, controller)) { pos.x -= speed * Time.deltaTime; } //Make the real pos equal to the temnp pos transform.position = pos; }
// Update is called once per frame void Update() { if (GameState == states.playing || GameState == states.replayingGame) { PlayGame(); } else { if (XCI.GetButtonDown(XboxButton.Start, XboxController.All)) { StartGame(); } } if (GameState == states.replayingGame && XCI.GetButton(XboxButton.Start, XboxController.All)) { SceneManager.LoadScene(0); } if (teamTwoScore != 0 || teamOneScore != 0) { float targetScore = 1 - ((float)teamTwoScore / ((float)teamOneScore + (float)teamTwoScore)); //Debug.Log ((float)teamTwoScore + " " + (float)teamOneScore + " " + (float)teamTwoScore / ((float)teamOneScore + (float)teamTwoScore)); teamScore.fillAmount = (Mathf.Lerp(teamScore.fillAmount, targetScore, 0.02f)); } }
public void GetBButton(int playerNumber, ref bool teamPicked, string teamColor, ref UISprite playerBackground, UIWidget widget, UISprite leftArrow, UISprite rightArrow) { if (XCI.GetButton(XboxButton.B, playerNumber)) { //PLAYS BUTTON PRESS DOWN SFX :) AudioController.Play("UI_ButtonPressDown"); teamPicked = false; if (playerBackground.color == blueColor) { blueCount--; SetPlayerTeamNumber(playerNumber, blueCount); } else { pinkCount--; SetPlayerTeamNumber(playerNumber, pinkCount); } playerBackground.color = greyColor; widget.gameObject.SetActive(true); leftArrow.gameObject.SetActive(true); rightArrow.gameObject.SetActive(true); } }
/// <summary> /// Update is called once per frame /// </summary> void Update() { if (SceneManager.GetActiveScene().name == playerSelectScene) { SelectPlayers(); ActivatePlayers(); if (XCI.GetButton(XboxButton.Start, XboxController.First) && anyActive) { //make more efficient later //loads next scene after character select for (int i = 0; i < players.Length; i++) { players[i].GetComponent <PlayerPoints>().enabled = true; players[i].GetComponent <PlayerInput>().enabled = true; players[i].GetComponent <PlayerDamageHandler>().enabled = true; players[i].GetComponent <AttackScript>().enabled = true; players[i].GetComponent <PlayerMoveScript>().enabled = true; players[i].GetComponent <CapsuleCollider>().enabled = true; players[i].GetComponent <FoodAndDrink>().enabled = true; } SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } } if (SceneManager.GetActiveScene().name == gameScene) { CheckActivePlayer(); SetControllerPlayer(Player1, p1); SetControllerPlayer(Player2, p2); SetControllerPlayer(Player3, p3); SetControllerPlayer(Player4, p4); } }
// Update is called once per frame void Update() { inputVec = new Vector2(XCI.GetAxis(XboxAxis.LeftStickX, (XboxController)playerIndex), XCI.GetAxis(XboxAxis.LeftStickY, (XboxController)playerIndex)); if (XCI.GetButtonUp(XboxButton.LeftStick, (XboxController)playerIndex)) { Movement.initiateSneak(); } if (XCI.GetButton(XboxButton.A, (XboxController)playerIndex) && Movement.jumpStates != Movement.JUMPSTATES.JUMPING) { Movement.jumpStates = Movement.JUMPSTATES.JUMPPREP; Movement.jumpPreparation(); } if (XCI.GetButtonUp(XboxButton.A, (XboxController)playerIndex) && Movement.jumpStates != Movement.JUMPSTATES.JUMPING) { Movement.jumpStates = Movement.JUMPSTATES.LAUNCH; } if (XCI.GetButton(XboxButton.Y, (XboxController)playerIndex)) { GetComponent <Abilities>().triggerEnemies(); } }
private void GetInput() { if (_IsUsingController) { _HorizontalAxis = XCI.GetAxis(XboxAxis.LeftStickX, controller); _VerticalAxis = XCI.GetAxis(XboxAxis.LeftStickY, controller); _LTrigger = 1 * XCI.GetAxis(XboxAxis.LeftTrigger, controller); _RTrigger = 1 * XCI.GetAxis(XboxAxis.RightTrigger, controller); _AButton = XCI.GetButton(XboxButton.A); _BButton = XCI.GetButton(XboxButton.B); _XButton = XCI.GetButton(XboxButton.X); _YButton = XCI.GetButton(XboxButton.Y); _DPadUp = XCI.GetButton(XboxButton.DPadUp); _DPadDown = XCI.GetButton(XboxButton.DPadDown); _DPadLeft = XCI.GetButton(XboxButton.DPadLeft); _DPadRight = XCI.GetButton(XboxButton.DPadRight); _BumperLeft = XCI.GetButton(XboxButton.LeftBumper); _BumperRight = XCI.GetButton(XboxButton.RightBumper); } if (_IsUsingController == false) { _RTrigger = Input.GetAxis("Vertical"); _HorizontalAxis = Input.GetAxis("Horizontal"); } }
// Update is used to set features regardless the active behaviour. void Update() { // Activate/deactivate aim by input. if (XCI.GetAxis(XboxAxis.LeftTrigger, joystick) != 0 && !aim) { StartCoroutine(ToggleAimOn()); } else if (aim && XCI.GetAxis(XboxAxis.LeftTrigger, joystick) == 0) { StartCoroutine(ToggleAimOff()); //moveScript.walkSpeed = 4; //moveScript.runSpeed = 4; } // No sprinting while aiming. canSprint = !aim; // Toggle camera aim position left or right, switching shoulders. if (aim && XCI.GetButton(XboxButton.LeftStick, joystick)) { aimCamOffset.x = aimCamOffset.x * (-1); aimPivotOffset.x = aimPivotOffset.x * (-1); } // Set aim boolean on the Animator Controller. behaviourManager.GetAnim.SetBool(aimBool, aim); }
private void Update() { if (XCI.GetButton(XboxButton.A, controller)) { Shockwave(); } }
//-------------------------------------------------------------------------------------- // Resets the game by returning to the Main Menu scene. //-------------------------------------------------------------------------------------- public void ResetGame() { if (XCI.GetButton(XboxButton.Start, controller) && XCI.GetButton(XboxButton.Back, controller)) { SceneManager.LoadScene("Main Menu"); } }
// Update is called once per frame void Update() { if (winActive && (Input.GetKeyDown("space") || XCI.GetButton(XboxButton.A) || XCI.GetButton(XboxButton.Start))) { StartCoroutine("TransitionToLevelSelect"); } }
public virtual void Update(XboxController controller) { // movement Vector3 moveDirection = new Vector3(XCI.GetAxisRaw(XboxAxis.LeftStickX, controller), 0, XCI.GetAxisRaw(XboxAxis.LeftStickY, controller)); _characterController.Move(moveDirection); // throw if (XCI.GetButton(XboxButton.RightBumper, controller) && _straightCoolDownTimer <= 0 && Time.time >= _straightThrowAvailableTime) { _straightCoolDownTimer = _settings.StraightCoolDown; _tossAvailableTime = Time.time + _settings.ThrowDeadzoneDuration; _characterController.Throw(); } if (_settings.StraightCoolDown > 0) { _straightCoolDownTimer -= Time.deltaTime; } // toss if (XCI.GetButton(XboxButton.LeftBumper, controller) && _arcCoolDownTimer <= 0 && Time.time >= _tossAvailableTime) { _arcCoolDownTimer = _settings.ArcCoolDown; _straightThrowAvailableTime = Time.time + _settings.ThrowDeadzoneDuration; _characterController.Toss(); } if (_settings.ArcCoolDown > 0) { _arcCoolDownTimer -= Time.deltaTime; } }
void ActivateOnDetectJoystick() { if (HasDetected == false) { // Array values = Enum.GetValues(typeof(XboxButton)); foreach (XboxButton val in buttons) { if (XCI.GetButton(val, XboxController) == true) { HasDetected = true; Player.SetActive(true); _spawnEntity.FirstSpawn(); } } foreach (XboxAxis ax in sticks) { if (XCI.GetAxis(ax, XboxController) > 0 || XCI.GetAxis(ax, XboxController) < 0) { HasDetected = true; Player.SetActive(true); _spawnEntity.FirstSpawn(); } } } }
// Update is called once per frame void Update() { if (!movementDisabled) { yAxis = XboxCtrlrInput.XCI.GetAxis(XboxCtrlrInput.XboxAxis.LeftStickY, controllerNumber) * rotationSpeed; RollVehicle(); CalculateCurrentSpeed(); CheckIfPickupActivated(); if (boostBonus > 1) { boostBonus -= 0.02f; } else { boostBonus = 1f; } } if (XCI.GetButton(XboxButton.Start)) { SceneManager.LoadScene("MainScene"); } //Debug.Log("xAxis: " + xAxis + " yAxis: " + yAxis + " rightTrigger: " + rightTriggerPressed + " leftTrigger: " + leftTriggerPressed + " Y: " + XboxCtrlrInput.XCI.GetButtonDown (XboxCtrlrInput.XboxButton.Y)); }
// Update is called once per frame void Update() { if (XCI.GetButton(XboxButton.Start)) { loadingText.text = "LOADING..."; SceneManager.LoadScene("MainScene"); } }
// Update is called once per frame void Update() { if ((XCI.GetButton(XboxButton.B)) && (XCI.GetButton(XboxButton.Y)) && (XCI.GetButton(XboxButton.X))) { objectRain.SetActive(true); Debug.Log("Cheat Code Activated! Arr!"); } }
private static float GetHorzScrollAxis(int player) { if (XCI.GetNumPluggedCtrlrs() > player) { bool left = XCI.GetButton(XboxButton.LeftBumper, player + 1); bool right = XCI.GetButton(XboxButton.RightBumper, player + 1); if (left && !right) { return(-1); } else if (!left && right) { return(1); } else { return(XCI.GetAxis(XboxAxis.LeftStickX, player + 1)); } } else if (player == 0) { bool left = Input.GetKey("a"); bool right = Input.GetKey("d"); if (left && !right) { return(-1); } else if (!left && right) { return(1); } else { return(0); } } else if (player == 1) { bool left = Input.GetKey("left"); bool right = Input.GetKey("right"); if (left && !right) { return(-1); } else if (!left && right) { return(1); } else { return(0); } } else { return(0); } }
private void Update() { RotateView(); if (XCI.GetButton(XboxButton.A) && !m_Jump) { m_Jump = true; } }
bool CheckForExitInput(XboxController controller) { bool doExit = (XCI.GetButton(XboxButton.Start, controller) && XCI.GetButtonDown(XboxButton.Back, controller)) || (XCI.GetButton(XboxButton.Back, controller) && XCI.GetButtonDown(XboxButton.Start, controller)) || Input.GetKeyDown(KeyCode.Escape); return(doExit); }
//Move the character with WASD void Controls() { if (Input.GetKey(KeyCode.W)) { transform.position += transform.forward * moveSpeed * Time.deltaTime; } else if (Input.GetKey(KeyCode.S)) { transform.position -= transform.forward * moveSpeed * Time.deltaTime; } if (Input.GetKey(KeyCode.A)) { transform.position -= transform.right * moveSpeed * Time.deltaTime; } else if (Input.GetKey(KeyCode.D)) { transform.position += transform.right * moveSpeed * Time.deltaTime; } if (Input.GetKey(KeyCode.Space) || XCI.GetButton(XboxButton.X)) { transform.position += Vector3.up * moveSpeed * Time.deltaTime; } if (Input.GetKey(KeyCode.LeftControl) || XCI.GetButton(XboxButton.B)) { transform.position -= Vector3.up * moveSpeed * Time.deltaTime; } if (Input.GetMouseButtonUp(0) || XCI.GetButtonUp(XboxButton.RightBumper)) { LeftMouseClick(); ui.charger.SetActive(false); } if (Input.GetMouseButton(0) || XCI.GetButton(XboxButton.RightBumper)) { buttonHeld += (Time.deltaTime); ui.charger.SetActive(true); runOnce = false; } else { buttonHeld = 0; } if (Input.GetMouseButtonDown(1) || XCI.GetButtonDown(XboxButton.LeftBumper)) { int lastLine = spawnedLineList.Count - 1; Destroy(spawnedLineList[lastLine]); spawnedLineList.RemoveAt(lastLine); } if (Input.GetKeyDown(KeyCode.Escape) || XCI.GetButtonDown(XboxButton.Start)) { Application.Quit(); } if (Input.GetKeyDown(KeyCode.R) || XCI.GetButtonDown(XboxButton.Back)) { SceneManager.LoadScene("TestMirror"); } }
// Update is called once per frame void Update() { if (GetComponent <Player>().IsDead() && m_playerGhostHolder == null) { //Decide which ghost to spawn if (GetComponent <ColourController>().m_firstBulletSlot) { m_playerGhostHolder = Instantiate(m_playerGhost, transform.TransformPoint(m_playerGhostOffset), Quaternion.identity, transform); //Ghost Destroy(Instantiate(m_playerDeathEffect[0], transform.TransformPoint(m_playerDeathEffectOffset), Quaternion.identity, transform), 5.0f); //Death effect } else { m_playerGhostHolder = Instantiate(m_playerGhost, transform.TransformPoint(m_playerGhostOffset), Quaternion.identity, transform); //Ghost Destroy(Instantiate(m_playerDeathEffect[1], transform.TransformPoint(m_playerDeathEffectOffset), Quaternion.identity, transform), 5.0f); //Death effect } GetComponent <PlayerSounds> ().m_deathAudio.GetComponent <AudioSource> ().Play(); //Play death sound for player this.gameObject.GetComponent <Player> ().m_childRenderer.GetComponentInChildren <SkinnedMeshRenderer> ().enabled = false; //Set player to be transparent } else if (!GetComponent <Player> ().IsDead() && m_playerGhostHolder != null) { this.gameObject.GetComponent <Player> ().m_childRenderer.GetComponentInChildren <SkinnedMeshRenderer> ().enabled = true; //Set player to not be transparent Destroy(m_playerGhostHolder); } if (isReviving && XCI.GetButton((XboxButton.X), controller) && !GetComponent <Player> ().IsDead() && m_otherPlayer.GetComponent <Player> ().IsDead()) { timer += Time.deltaTime; if (timer >= reviveTime) { timer = 0; //Revivie other player, play sound m_otherPlayer.GetComponent <Player> ().SetHealth(2); m_otherPlayer.GetComponent <PlayerSounds> ().m_reviveAudio.GetComponent <AudioSource> ().Play(); PlayerHealth otherPlayerHealth = m_otherPlayer.GetComponent <PlayerHealth>(); Destroy(Instantiate(otherPlayerHealth.m_playerReviveEffect, m_otherPlayer.transform.TransformPoint(otherPlayerHealth.m_playerReviveEffectOffset), Quaternion.identity, otherPlayerHealth.transform), 5.0f); //Death effect } //Play Audio for respawn if (!m_playerSounds.m_respawnAudio.GetComponent <AudioSource> ().isPlaying) { m_playerSounds.m_respawnAudio.GetComponent <AudioSource> ().Play(); } } if (XCI.GetButtonUp((XboxButton.B), controller)) { timer = 0; } }
/// <summary> /// 檢查角色選擇是否完成 /// </summary> private void CheckPlayerSelectFinish() { if (PlayerManager.Instance.players.Count > 0) { if (XCI.GetButton(XboxButton.Start, XboxController.First) || Input.GetKeyDown(KeyCode.Space)) { //GameManager.Instance.ChangeGameState(new State_LevelSelect(GameManager.Instance)); GameManager.Instance.ChangeGameState(new State_GamePlay(GameManager.Instance)); } } }
bool CheckLock() { if (XCI.GetAxis(XboxAxis.LeftTrigger, myController.GetID()) != 0 || XCI.GetButton(XboxButton.LeftBumper, myController.GetID())) { return(true); } else { return(false); } }
private void Update() { if (XCI.GetButton(XboxButton.A, controller)) { hm.enabled = true; } else { hm.enabled = false; } }
public override bool Calculate() { if (controllerChoice.Selected != lastSelected) { ChooseController(); } if (XCI.GetNumPluggedCtrlrs() > 0 && XCI.IsPluggedIn(boundController)) { var lX = XCI.GetAxis(XboxAxis.LeftStickX, boundController); var lY = XCI.GetAxis(XboxAxis.LeftStickY, boundController); var rX = XCI.GetAxis(XboxAxis.RightStickX, boundController); var rY = XCI.GetAxis(XboxAxis.RightStickY, boundController); leftStick = new Vector2(lX, lY); rightStick = new Vector2(rX, rY); leftTrigger = XCI.GetAxis(XboxAxis.LeftTrigger, boundController); rightTrigger = XCI.GetAxis(XboxAxis.RightTrigger, boundController); dpadUp = XCI.GetButton(XboxButton.DPadUp, boundController); dpadDown = XCI.GetButton(XboxButton.DPadDown, boundController); dpadLeft = XCI.GetButton(XboxButton.DPadLeft, boundController); dpadRight = XCI.GetButton(XboxButton.DPadRight, boundController); a = XCI.GetButton(XboxButton.A, boundController); b = XCI.GetButton(XboxButton.B, boundController); x = XCI.GetButton(XboxButton.X, boundController); y = XCI.GetButton(XboxButton.Y, boundController); leftBumper = XCI.GetButton(XboxButton.LeftBumper, boundController); rightBumper = XCI.GetButton(XboxButton.LeftBumper, boundController); start = XCI.GetButton(XboxButton.Start, boundController); back = XCI.GetButton(XboxButton.Back, boundController); LeftStickKnob.SetValue(leftStick); RightStickKnob.SetValue(rightStick); LeftTriggerKnob.SetValue(leftTrigger); RightTriggerKnob.SetValue(rightTrigger); dpadUpKnob.SetValue(dpadUp); dpadDownKnob.SetValue(dpadDown); dpadLeftKnob.SetValue(dpadLeft); dpadRightKnob.SetValue(dpadRight); aKnob.SetValue(a); bKnob.SetValue(b); xKnob.SetValue(x); yKnob.SetValue(y); leftBumperKnob.SetValue(leftBumper); rightBumperKnob.SetValue(rightBumper); startKnob.SetValue(start); backKnob.SetValue(back); } return(true); }
void Update() { // タイトルシーンへ戻る if ((Input.GetKeyDown(KeyCode.Space) || XCI.GetButton(XboxButton.B, XboxController.First)) && !changescene_flag) { changescene_flag = true; As.PlayOneShot(se); SceneManagerController.LoadScene(); SceneManagerController.ChangeScene(); } }