// Update is called once per frame void Update() { if (x3 == null) { x3 = new Xbox360Controller(ID); } if (SignedIn) { float hor = x3.HorizontalAxis(); float ver = x3.VerticalAxis(); this.transform.position += new Vector3(hor, -ver) * speed; } else { if (x3.StartPressed()) { SignedIn = true; this.GetComponent <SpriteRenderer> ().enabled = true; select.transform.GetChild(1).GetComponent <Text> ().text = ""; select.color = desired; SignedInCount++; AudioSource.PlayClipAtPoint(GameObject.FindObjectOfType <NetworkingObjectMenu>().click, GameObject.FindGameObjectWithTag("MainCamera").transform.position); } } if (collidingLevel != null) { if (x3.PressedJump()) { LevelType level = collidingLevel.lt; GlobalProperties.LEVEL = level.ToString(); collidingLevel.GetComponent <SpriteRenderer>().color = Color.red; AudioSource.PlayClipAtPoint(collidingLevel.noise, GameObject.FindGameObjectWithTag("MainCamera").transform.position); if (prevCollidingLevel == null || prevCollidingLevel == collidingLevel) { prevCollidingLevel = collidingLevel; } else { prevCollidingLevel.GetComponent <SpriteRenderer>().color = Color.white; prevCollidingLevel = collidingLevel; } } } else if (colliding != null) { if (x3.PressedJump()) { CharacterType character = colliding.ct; GlobalProperties.PLAYERCHOICE[ID - 1] = character.ToString(); select.transform.GetChild(2).GetComponent <Image>().sprite = GameObject.FindObjectOfType <CharacterDictionary>().GetByText(character.ToString()); select.transform.GetChild(1).GetComponent <Text> ().text = "\n" + character.ToString(); select.transform.GetChild(1).GetComponent <Text> ().alignment = TextAnchor.UpperRight; AudioSource.PlayClipAtPoint(colliding.noise, GameObject.FindGameObjectWithTag("MainCamera").transform.position); } } }
//input and logic goes here void Update() { //<<<<<<< HEAD:A Sticky Situation/Assets/Engine/PlayerController.cs if (!canMove) { return; } if (celebrating) { return; } //get horizontal movement if (GlobalProperties.IS_NETWORKED) { xInput = Input.GetAxis("Horizontal"); xInput *= accelerationSpeed; } else if (!isPaused) //>>>>>>> 9d7014c9d9c7ae46f9e434202e06ac007b80b210:A Sticky Situation/Assets/Engine/Player/PlayerController.cs { if (XBox.StartPressed()) { isPaused = true; Camera.main.GetComponent <PauseButtons>().pauseScreen.SetActive(true); Camera.main.GetComponent <PauseButtons>().mainCanvas.SetActive(false); PlayerController[] allPlayers = GameObject.FindObjectsOfType <PlayerController>(); foreach (var p in allPlayers) { p.isPaused = true; } } if (!canMove) { return; } //get horizontal movement if (GlobalProperties.IS_NETWORKED) { xInput = Input.GetAxis("Horizontal"); xInput *= accelerationSpeed; } else { if (AI == null) { xInput = XBox.HorizontalAxis(); xInput *= accelerationSpeed; if (XBox.SprintPressed() && xInput != 0 && !exhausted) { COMMAND_Sprint(); } else { COMMAND_DontSprint(); } } } if (GlobalProperties.IS_NETWORKED) { SpecialCharacterMovesNetwork(); } else { SpecialCharacterMovesLocal(); } CalculateSprintScale(false /*xInput > 0*/); if (xInput > 0 || xInput < 0) { animator.SetBool("Walking", true); if (xInput > 0) { this.transform.localScale = scale; nametag.transform.localScale = nametagScale; abs.transform.localScale = absScale; } else { this.transform.localScale = minScale; nametag.transform.localScale = nametagMinScale; abs.transform.localScale = absMinScale; } } else { animator.SetBool("Walking", false); } isGrounded = Physics2D.OverlapCircle(footTransform.position, groundedRadius, whatIsGround); animator.SetBool("Grounded", isGrounded); if (isGrounded) { if (GlobalProperties.IS_NETWORKED) { if (Input.GetButtonDown("Jump")) { isGrounded = false; animator.SetBool("Grounded", false); animator.SetBool("Jumped", true); myBody.AddForce(Vector2.up * jumpForce); AudioSource.PlayClipAtPoint(jump, this.transform.position); animator.SetBool("InAir", true); } } else { if (AI == null) { if (XBox.PressedJump()) { COMMAND_Jump(); } } } if (!wasGrounded) { AudioSource.PlayClipAtPoint(land, this.transform.position); animator.SetBool("InAir", false); } } else { animator.SetBool("InAir", true); } //<<<<<<< HEAD:A Sticky Situation/Assets/Engine/PlayerController.cs if (XBox.CelebratePressed()) { if (!celebrating) { Celebrate(); } } float raycastD = .55f; //check raycasting for objects to the left and right of player if (xInput > 0) { //right if (RaycastCollision(true, raycastD)) { myBody.velocity = new Vector2(0, myBody.velocity.y); xInput = 0; if (AI != null) { AI.BlockCollide(true); } } } else if (xInput < 0) { //left if (RaycastCollision(false, raycastD)) { myBody.velocity = new Vector2(0, myBody.velocity.y); xInput = 0; if (AI != null) { AI.BlockCollide(false); } } } if (hasStickyBomb) { if (AI == null) { bombImage.SetActive(true); if (GlobalProperties.IS_NETWORKED && Input.GetMouseButtonDown(0)) { NetworkThrowBomb(); } else if (!GlobalProperties.IS_NETWORKED && XBox.PressedThrow()) { COMMAND_LocalThrowBomb(); } } } else if (isStuck) { bombImage.SetActive(true); bombImage.GetComponent <Image> ().color = Color.red; } else { bombImage.SetActive(false); } wasGrounded = isGrounded; } }