// Update is called once per frame. void Update() { // Reset total jumps allowed when not performing a jump and grounded or when on a moving/sinking platform. if (!jump && (player.grounded || player.IsStuckToPlatform()) && ((Mathf.Round(GetComponent <Rigidbody2D>().velocity.y) == 0) || ((player.OnMovingPlatform() || player.OnSinkingPlatform()) && GetComponent <Rigidbody2D>().velocity.y == player.GetPlatform().GetComponent <Rigidbody2D>().velocity.y))) { jumps = doubleJumping.totalJumps; } // If the jump button is pressed, jumps are allowed and the player is not dashing, sliding, on a ladder or crouching under an obstacle... if (!jump && CFInput.GetButtonDown("Jump") && jumps > 0 && !player.dashing && !player.sliding && !player.onLadder) { // If the player is grounded... if (player.grounded) { // ... initialize jump. InitJump(); // If the player is not grounded and totalJumps is higher than 1... } else if (doubleJumping.totalJumps > 1) { // ... initialize jump if the Y velocity is inside the double jump window (or when there isn't a window). if (!doubleJumping.jumpWindow || (doubleJumping.jumpWindow && GetComponent <Rigidbody2D>().velocity.y > doubleJumping.jumpWindowMin && GetComponent <Rigidbody2D>().velocity.y < doubleJumping.jumpWindowMax)) { doubleJump = true; InitJump(); } } } }
// This function is called every fixed framerate frame. void FixedUpdate() { // Cache the run input. bool running = CFInput.GetButton("Run"); // Get the current speed. float speed = GetSpeed(); // Only make the player walk when pressToRun is active and the player isn't running. player.Walk(pressToRun && !running); // If the player is not stuck to the wall and the player is not dashing, sliding, crouching and/or on a ladder... if (!player.stuckToWall && !player.dashing && !player.sliding && !player.crouching && !player.onLadder) { // ... if the player is changing direction (h has a different sign to velocity.x) or hasn't reached speed yet... if (player.hor * GetComponent <Rigidbody2D>().velocity.x < speed) { // ... add a force to the player. GetComponent <Rigidbody2D>().AddForce(transform.rotation * Vector2.right * player.hor * player.GetMovementForce(moveForce)); } // If the player's horizontal velocity is greater than the speed and the player isn't stuck to the X of a platform... if (Mathf.Abs(GetComponent <Rigidbody2D>().velocity.x) > speed && !player.IsStuckToPlatformX()) { // ... set the player's velocity to the speed in the x axis. player.SetXVelocity(Mathf.Sign(GetComponent <Rigidbody2D>().velocity.x) * speed); } } }
void FixedUpdate() { if (UseTouchControls) { float moveHorizontal = CFInput.GetAxis("Horizontal"); float moveVertical = CFInput.GetAxis("Vertical"); MoveShip(moveHorizontal, moveVertical); } if (!UseTouchControls) { float moveHorizontal = (Input.acceleration.x * 2); float moveVertical = (Input.acceleration.y * 2); MoveShip(moveHorizontal - deviceHorizontal, moveVertical - deviceVertical); } // !!! Make sure to disable Keyboard control in the UI when building for mobile!! if (Testing) { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); MoveShip(moveHorizontal, moveVertical); } rigidbody.position = new Vector3( Mathf.Clamp(rigidbody.position.x, boundary.xMin, boundary.xMax), 0.0f, Mathf.Clamp(rigidbody.position.z, boundary.zMin, boundary.zMax) ); rigidbody.rotation = Quaternion.Euler(0.0f, 0.0f, rigidbody.velocity.x * -tilt); }
void Update() { if (player.grounded) { totalAirDashes = airDashTotal; } SetDashAllowed(); if (player.dashing) { dashAllowed = false; if (GetComponent <Rigidbody2D>().velocity.x == 0) { dashTimer = 0; } if (dashTimer > 0) { dashTimer -= Time.deltaTime; } else { runCooldownTimer = true; player.Dash(false); } } if (runCooldownTimer) { dashAllowed = false; if (cooldownTimer > 0) { cooldownTimer -= Time.deltaTime; } else { runCooldownTimer = false; SetDashAllowed(); } } else if (CFInput.GetButtonDown("Dash") && dashAllowed && !player.dashing && !player.crouching && !player.stuckToWall && !player.falling && !player.sliding && !player.onLadder && !player.stop) { dash = true; GetComponent <AudioSource>().PlayOneShot(dashsound); Instantiate(dashparticle, dashparticleloc.position, dashparticleloc.localRotation); if (PlayerPrefs.GetInt("Vibrate") == 0) { player.Vib650(); } } }
// Token: 0x060007E5 RID: 2021 RVA: 0x000346A0 File Offset: 0x00032AA0 public static bool GetMouseButtonUp(int i) { if (CFInput.ControllerActive()) { return(CFInput.ctrl.GetMouseButtonUp(i)); } return(Input.GetMouseButtonUp(i)); }
// Token: 0x06000DB2 RID: 3506 RVA: 0x00057AC8 File Offset: 0x00055EC8 private void Update() { this.target.transform.Rotate(new Vector3(0f, CFInput.GetAxis("Mouse X"), 0f) * (this.XSpeed * 100f) * Time.deltaTime); if (this.enableYAxis) { base.transform.Rotate(new Vector3(CFInput.GetAxis("Mouse Y"), 0f, 0f) * (this.YSpeed * 100f) * Time.deltaTime); } }
// Token: 0x060007E6 RID: 2022 RVA: 0x000346BE File Offset: 0x00032ABE public static void ResetInputAxes() { Input.ResetInputAxes(); if (CFInput.ControllerActive()) { CFInput.ctrl.ReleaseTouches(); } }
// Token: 0x060007E2 RID: 2018 RVA: 0x00034600 File Offset: 0x00032A00 public static float GetAxisPx(string axisName, float refResolution = 1280f, float maxDragInches = 1f) { if (CFInput.ControllerActive() && TouchController.IsSupported()) { float actualDPI = CFInput.ctrl.GetActualDPI(); float axis = CFInput.GetAxis(axisName); return(axis / (actualDPI * maxDragInches) * refResolution); } int width = Screen.currentResolution.width; return(CFInput.GetAxis(axisName) * ((width != 0) ? (refResolution / (float)width) : 1f)); }
// Token: 0x060007DC RID: 2012 RVA: 0x0003441C File Offset: 0x0003281C public static bool GetKeyUp(KeyCode key) { if (CFInput.ControllerActive()) { bool flag = false; bool keyUpEx = CFInput.ctrl.GetKeyUpEx(key, out flag); if (flag) { return(keyUpEx); } } return(Input.GetKeyUp(key)); }
void Update() { if (UseTouchControls) { if (CFInput.GetButton("Fire2") && Time.time > nextFire) { FireEvent(); } } if (!UseTouchControls) { if (CFInput.GetButton("Fire1") && Time.time > nextFire) { FireEvent(); } } if (Testing) { if (Input.GetButton("Fire1") && Time.time > nextFire) { FireEvent(); } } if (forceField == true && forceFieldCreated == false) { GameObject ForceFieldInstance = Instantiate(ForceFieldObject, transform.position, shotSpawn.rotation) as GameObject; ForceFieldInstance.transform.parent = transform; forceFieldCreated = true; } // Change Weapons if (Input.GetKeyDown("space")) { if (WeaponNumber == Weapons.Length - 1) { WeaponNumber = 0; } else { WeaponNumber++; } } }
// Get the current speed for the player. public float GetSpeed(bool withPlatform = true) { // Cache the horizontal input, run input and speed. bool running = CFInput.GetButton("Run"); float speed = runSpeed; // If a button needs to be pressed to run... if (pressToRun) { // If the player is in the air and can't change between walking and running in the air... if (!player.grounded && !player.CanWalkAndRunInAir()) { // ... set the speed based on if the player was walking or running before jumping. speed = player.AirWalk() ? walkSpeed : runSpeed; } else { // ... set the speed to walking or running, depending on the run input. if (player.hor != 0f) { speed = running ? runSpeed : walkSpeed; } } } // If the player is crouching... if (player.crouching) { // ... set the speed to the crouch speed. speed = player.GetCrouchSpeed(); } // Set the player's speed based on the speed of the platform. if (withPlatform) { speed = player.GetSpeedOnMovingPlatform(speed); } // Get the player's air movement speed. speed = player.GetSpeedInAir(speed); // Return the speed. return(speed); }
// Token: 0x060007DE RID: 2014 RVA: 0x000344A8 File Offset: 0x000328A8 public static bool GetButtonDown(string axisName) { if (CFInput.ControllerActive()) { bool flag = false; bool buttonDownEx = CFInput.ctrl.GetButtonDownEx(axisName, out flag); if (flag) { return(buttonDownEx); } } try { return(Input.GetButtonDown(axisName)); } catch (UnityException) { } return(false); }
// Token: 0x060007E1 RID: 2017 RVA: 0x000345A8 File Offset: 0x000329A8 public static float GetAxisRaw(string axisName) { if (CFInput.ControllerActive()) { bool flag = false; float axisEx = CFInput.ctrl.GetAxisEx(axisName, out flag); if (flag) { return(axisEx); } } try { return(Input.GetAxisRaw(axisName)); } catch (UnityException) { } return(0f); }
// Token: 0x06000DB6 RID: 3510 RVA: 0x00057BB0 File Offset: 0x00055FB0 private void Update() { if (this.target) { this.target.transform.Rotate(new Vector3(0f, CFInput.GetAxis("Mouse X"), 0f) * (this.angularSpeed * 10f) * Time.deltaTime); if (this.lockOn) { base.transform.localEulerAngles = this.euler; this.RotUpDown = -CFInput.GetAxis("Mouse Y") * (this.angularSpeed * 10f) * Time.deltaTime; this.euler.y = this.euler.y + this.RotLeftRight; this.euler.x = this.euler.x + this.RotUpDown; if (this.euler.x >= this.maxY) { this.euler.x = this.maxY; } if (this.euler.x <= this.minY) { this.euler.x = this.minY; } } } }
// Token: 0x06000C31 RID: 3121 RVA: 0x0004D2BC File Offset: 0x0004B6BC private void LateUpdate() { if (!this.target) { return; } if (!this.targetBody) { this.targetBody = this.target; } if (Time.timeScale == 0f) { return; } this.x += CFInput.GetAxis("Mouse X") * this.xSpeed * 0.02f; this.y -= CFInput.GetAxis("Mouse Y") * this.ySpeed * 0.02f; this.distance -= CFInput.GetAxis("Mouse ScrollWheel") * Time.deltaTime * this.zoomRate * Mathf.Abs(this.distance); this.distance = Mathf.Clamp(this.distance, this.minDistance, this.maxDistance); this.y = ARPGcameraC.ClampAngle(this.y, this.yMinLimit, this.yMaxLimit); Quaternion rotation = Quaternion.Euler(0f, this.x, 0f); base.transform.rotation = rotation; this.aim = Quaternion.Euler(0f - this.aimAngle, this.x, 0f); if (CFInput.GetButton("Fire1") || CFInput.GetButton("Fire2") || CFInput.GetAxis("Horizontal") != 0f || CFInput.GetAxis("Vertical") != 0f || this.lockOn) { this.targetBody.transform.rotation = Quaternion.Euler(0f, this.x, 0f); } Vector3 position = this.target.position - (rotation * Vector3.forward * this.distance + new Vector3(this.offsetX, -this.targetHeight, this.offsetZ)); base.transform.position = position; Vector3 vector = this.target.transform.position - new Vector3(0f, -this.targetHeight, 0f); if (Physics.Linecast(vector, base.transform.position, out this.hit) && this.hit.transform.tag == "Wall") { float d = Vector3.Distance(vector, this.hit.point) - 0.28f; position = this.target.position - (rotation * Vector3.forward * d + new Vector3(0f, -this.targetHeight, 0f)); base.transform.position = position; } }
// Update is called once per frame. void Update() { // Check if the player's hitbox collides with a ladder. Vector2 pos = transform.position; Vector2 pointA = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2), pos.y + boxCollider.offset.y - (boxCollider.size.y / 2)); Vector2 pointB = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2)); hitLadder = Physics2D.OverlapArea(pointA, pointB, ladderLayer); // If the player isn't currently on a ladder, there is a ladder collission and the player isn't falling, dashing, crouching, sliding or stuck on a wall... if (!player.onLadder && hitLadder && !player.falling && !player.dashing && !player.crouching && !player.sliding && !player.stuckToWall) { // ... cache the vertical CFInput. float v = CFInput.GetAxis("Vertical"); // If the player isn't on a ladder and the vertical movement is either moving up or down... if (!player.onLadder && (v > 0.5 || v < -0.5)) { // ... make sure the player is stuck to the ladder. Stick(); } } // If there isn't a collission with a ladder and the player is considered on a ladder... if (!hitLadder && player.onLadder) { // ... make the player unstuck from the ladder. Unstick(); } // If the player is on a ladder, there is a ladder object and the player is allowed to jump... if (player.onLadder && ladder && ladder.allowJump && CFInput.GetButtonDown("Jump")) { // ... unstick the player from the ladder and perform the jump. Unstick(); player.Jump(); } }
void Update() { animator.SetBool("grounded", grounded); animator.SetBool("walking", walking); animator.SetBool("crouching", crouching); animator.SetBool("sliding", sliding); animator.SetBool("dashing", dashing); animator.SetBool("falling", falling); animator.SetBool("wall", stuckToWall); animator.SetBool("onLadder", onLadder); animator.SetBool("jumpingThrough", jumpingThrough); if (timer > 0f) { timer -= Time.deltaTime; } if (timer < 0f) { timer = 0f; } if (timer == 0f) { WSVibrator.Cancel(); } if (orient == null) { orient = GameObject.Find("KingOrient"); } if (goodSpawn == null) { goodSpawn = GameObject.Find("EndSpawnBack"); } if (attackTimer > 0f) { attackTimer -= Time.deltaTime; } if (attackTimer == 0f && timedFire) { timedFire = false; fire = false; } if (nextFire > 0f) { nextFire -= Time.deltaTime; } if (attackTimer < 0f) { attackTimer = 0f; } if (staffTimer < 0f) { staffTimer = 0f; } if (staffTimer > 0f) { staffTimer -= Time.smoothDeltaTime; } if (staffTimer == 0) { staffClicks = 0; } if (nextFire < 0f) { nextFire = 0f; } Vector2 pos = transform.position; if (facingRight) { frontCheckTop.transform.position = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2)); frontCheckBot.transform.position = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2) + 0.1f, pos.y + boxCollider.offset.y - (boxCollider.size.y / 2) - (circleCollider.radius / 2)); } else { frontCheckTop.transform.position = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2)); frontCheckBot.transform.position = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2) - 0.1f, pos.y + boxCollider.offset.y - (boxCollider.size.y / 2) - (circleCollider.radius / 2)); } if (!stop) { hor = CFInput.GetAxis("Horizontal"); animator.SetFloat("horizontal", Mathf.Abs(hor)); } animator.SetFloat("xSpeed", Mathf.Abs(GetComponent <Rigidbody2D>().velocity.x)); animator.SetFloat("ySpeed", GetComponent <Rigidbody2D>().velocity.y); if (!OnPlatform()) { groundCollider = Physics2D.OverlapCircle(groundCheck.position, groundRadius, groundLayer); } if (keepVelocityOnGround && groundedXVelocity > 0) { if (groundedTimer > 0) { groundedTimer -= Time.deltaTime; } else { groundedXVelocity = 0; } } if (groundCollider && !jumpingThrough) { if (keepVelocityOnGround && !grounded) { groundedXVelocity = GetComponent <Rigidbody2D>().velocity.x; groundedTimer = groundedVelocityTime; } grounded = true; jumping = false; if (rotateOnSlope && !OnPlatform()) { transform.rotation = groundCollider.transform.localRotation; } if (falling) { animator.SetTrigger("stateComplete"); } falling = false; } else { transform.rotation = normalRotation; grounded = false; } if ((hor > 0 && !facingRight) || (hor < 0 && facingRight) || flipAgain) { Flip(); } if (Staff) { if (pickup.staffAmmo > 0f && staffClicks == 1 && !staffFired) { if (staffTimer < 0.3f) { Vib100(); isAttacking = true; fire = true; animator.SetBool("StaffFire", true); GetComponent <AudioSource>().PlayOneShot(staffShot, 1.0f); GameObject newBullet = Instantiate(staffBullet); StaffController bullCon = newBullet.GetComponent <StaffController>(); bullCon.playerObject = gameObject; bullCon.StaffShoot(); newBullet.transform.position = staffBulletSpawn.position; pickup.staffAmmo--; staffFired = true; } } } if (CFInput.GetButtonDown("Fire1")) { Fire(); } if (CFInput.GetButton("Fire1") && Machinegun) { machinegunBulletSpawn = GameObject.Find("MachineGunSpawnPoint").transform; if (!onLadder && !stuckToWall) { if (nextFire == 0f && pickup.machinegunAmmo > 0f) { Vib50(); isAttacking = true; nextFire = machinegunFireRate; animator.SetBool("MachineGunFire", true); GetComponent <AudioSource>().PlayOneShot(machinegunShot, 1.0f); GameObject newBullet = Instantiate(machinegunBullet); GameObject newKick = Instantiate(machinegunKick); MachineGunController bullCon = newBullet.GetComponent <MachineGunController>(); ParticleFlip kickCon = newKick.GetComponent <ParticleFlip>(); bullCon.playerObject = gameObject; kickCon.playerObject = gameObject; bullCon.MachineGunShoot(); kickCon.MachineGunShoot(); newBullet.transform.position = machinegunBulletSpawn.position; newKick.transform.position = machinegunBulletSpawn.position; pickup.machinegunAmmo--; } else if (pickup.machinegunAmmo == 0f) { isAttacking = false; animator.SetBool("MachineGunFire", false); GetComponent <AudioSource>().PlayOneShot(outOfAmmo); } } } if (CFInput.GetButtonUp("Fire1") && Machinegun) { isAttacking = false; animator.SetBool("MachineGunFire", false); } }
// Fixed update is called in sync with physics private void FixedUpdate() { // if (!m_Character.JetPackStatus) { float h = CFInput.GetAxis("Horizontal"); float v = CFInput.GetAxis("Vertical"); PlayerPrefs.SetFloat(mushroomdirection, h); v = 0.0f; // m_Move = h * Vector3.right + v * Vector3.up; //0 TRUE 1 FALSE int backrestrict = PlayerPrefs.GetInt("BACKRESTRICT"); // Debug.Log ("backkkkkkkkkkk"+backrestrict); if (backrestrict == 1) { // Debug.Log("h valueee" +h); if (h < 0.0f) { h = 0.0f; //m_Move = new Vector3(0,0,0); m_Character.Move(m_Move, false, false); m_Character.playerVelocityZero(); return; } } if (this.ctrl != null) { int uiDisable = PlayerPrefs.GetInt("UI_DESABLE"); if (uiDisable == 0) { Time.timeScale = 1; walkStick.Enable(true); } else if (uiDisable == 2) { PlayerPrefs.SetInt("walkStickStatus", 0); walkStick.Disable(true); } else { walkStick.Disable(true); PlayerPrefs.SetInt("walkStickStatus", 0); Time.timeScale = 0; } if (walkStick.JustPressed()) { PlayerPrefs.SetInt("walkStickStatus", 1); // walkStick.Disable(true); // walkStick.Enable(true); // Debug.Log("SDHAKAR JustPressed "); } else if (walkStick.GetKey(KeyCode.UpArrow) && walkStick.GetKey(KeyCode.LeftArrow)) { // Debug.Log("left Upper"); // if(m_Character.isMovingOnRope) // return; // if(m_Character.isMovingOnLog) // return; PlayerPrefs.SetInt("walkStickStatus", 1); if (m_Character.swimStatus) { m_Character.swimUpMovingAnim(); } else if (m_Character.swimUpStatus) { m_Character.swimUpClimbingLeftAnim(); } if (m_Character.JetPackStatus) { return; } m_Jump = true; m_Character.jumpDirectionValue = -10.0f; moveTrasfer(h, v); PlayerPrefs.SetInt("PathRemovalLEFT", 1); return; } else if (walkStick.GetKey(KeyCode.UpArrow) && walkStick.GetKey(KeyCode.RightArrow)) { // Debug.Log("right Upper"); // if(m_Character.isMovingOnRope) // return; // if(m_Character.isMovingOnLog) // return; PlayerPrefs.SetInt("walkStickStatus", 1); if (m_Character.swimStatus) { m_Character.swimUpMovingAnim(); } else if (m_Character.swimUpStatus) { m_Character.swimUpClimbingRightAnim(); } if (m_Character.JetPackStatus) { return; } m_Jump = true; // m_Character.jumpDirection(); m_Character.jumpDirectionValue = 10.0f; moveTrasfer(h, v); return; } else if (walkStick.GetKey(KeyCode.DownArrow) && walkStick.GetKey(KeyCode.LeftArrow)) { return; } else if (walkStick.GetKey(KeyCode.DownArrow) && walkStick.GetKey(KeyCode.RightArrow)) { return; } else if (walkStick.GetKey(KeyCode.UpArrow)) { // if(m_Character.isMovingOnRope) // return; // if(m_Character.isMovingOnLog) // return; // Debug.Log(" Upper"); PlayerPrefs.SetInt("walkStickStatus", 1); if (m_Character.swimStatus) { m_Character.swimUpMovingAnim(); } if (m_Character.swimUpStatus) { m_Character.swimUpClimbingRightAnim(); } if (m_Character.JetPackStatus) { m_Character.jetPackUpMoving(); } else { m_Jump = true; m_Character.jumpDirectionValue = 0.0f; moveTrasfer(h, v); } } else if (walkStick.GetKey(KeyCode.DownArrow)) { // if(m_Character.isMovingOnRope) // return; // if(m_Character.isMovingOnLog) // return; PlayerPrefs.SetInt("walkStickStatus", 1); if (PlayerPrefs.GetInt("JetPackStatus") != 1) { if (m_Character.swimStatus) { return; } if (m_Character.JetPackStatus) { m_Character.jetPackDownMoving(); } else { if (!SlidingStatus && !m_Character.isSwimStarted && !m_Character.clibStartTag) { // SlidingStatus = true; // m_Character.slidingAnimation (); // Invoke ("slidingCompleted", 1.0f); } } } } else if (walkStick.GetKey(KeyCode.RightArrow)) { PlayerPrefs.SetInt("walkStickStatus", 1); PlayerPrefs.SetInt("walkStickStatus2", 0); // if(m_Character.isMovingOnLog) // m_Character.movingOnLogStatus = true; // if(m_Character.isMovingOnRope) // m_Character.movingOnRopeStatus = true; if (m_Character.swimStatus) { m_Character.swimRightMovingAnim(); } if (m_Character.JetPackStatus) { return; } PlayerPrefs.SetInt(ShieldRotateStatus, 1); PlayerPrefs.SetInt("PathRemovalLEFT", 0); m_Character.jumpDirectionValue = 0.0f; moveTrasfer(h, v); return; } else if (walkStick.GetKey(KeyCode.LeftArrow)) { PlayerPrefs.SetInt("walkStickStatus", 1); PlayerPrefs.SetInt("walkStickStatus2", 1); if (m_Character.swimStatus) { m_Character.swimLeftMovingAnim(); } if (m_Character.JetPackStatus) { return; } PlayerPrefs.SetInt(ShieldRotateStatus, 1); PlayerPrefs.SetInt("PathRemovalLEFT", 1); m_Character.jumpDirectionValue = 0.0f; moveTrasfer(h, v); return; } else if (walkStick.JustReleased()) { PlayerPrefs.SetInt("walkStickStatus", 0); // m_Character.movingOnRopeStatus = false; // m_Character.movingOnLogStatus = false; } else { // m_Character.movingOnRopeStatus = false; // m_Character.movingOnLogStatus = false; } } if (m_Character.JetPackStatus) { h = 0; } if (h == 0) { PlayerPrefs.SetInt(ShieldRotateStatus, 0); } moveTrasfer(h, v); }
// This function is called every fixed framerate frame. void FixedUpdate() { // If the player should jump... if (jump) { // If the player is jumping down a platform and is doing the first jump... if (player.jumpDown && jumps == doubleJumping.totalJumps) { // ... add a small Y force. GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, 200f)); // If the player is on a platform... if (player.OnPlatform()) { // Set the moving platform to null. player.UnstickFromPlatform(); } // Reset the jumping variables. ResetJumpVars(); // Reset jumpDown. player.jumpDown = false; // Stop the player from jumping. return; } // If this is the initial jump... if (initialJump) { // Check if the player is running when the jump is being performed. walkingOnJump = player.walking; // When double jumping, set Y velocity to 0 to make sure the jump force is applied correctly. if (doubleJump) { player.SetYVelocity(0); } // Decrease total jumps allowed with 1. jumps--; // If the player is on a moving platform and should not keep the speed when jumping from a moving platform... if (player.OnMovingPlatform() && !player.KeepSpeedOnJump()) { // Set the X velocity to 0. player.SetXVelocity(0); } } // Get the jump factor. float jumpFactor = player.GetJumpFactor(); // If you need to hold the Jump input to jump higher... if (jumpType == JumpType.HoldToJumpHigher) { // When there is an initial jump... if (initialJump) { // ... set the y velocity to the player's initial jump value. float yVel = jumpFactor * (doubleJump ? holdToJumpHigher.initialDoubleJump : holdToJumpHigher.initialJump); // If the player is on a moving platform... if (player.OnMovingPlatform()) { // ... get the current platform. GameObject platform = player.GetPlatform(); // If the platform's Y velocity is greater than 0... if (platform.GetComponent <Rigidbody2D>().velocity.y > 0) { // ... make sure the y velocity of this platform is taken into account when jumping. yVel += platform.GetComponent <Rigidbody2D>().velocity.y; } } // If the player is on a platform... if (player.OnPlatform()) { // Set the moving platform to null. player.UnstickFromPlatform(); } // Make sure the player's velocity is set. player.SetYVelocity(yVel); // Set initialJump to false. initialJump = false; // When the jump button is being pressed and the timer isn't finished yet... } else if (CFInput.GetButtonDown("Jump") && jumpTimer > 0) { // ... decrease the timer's value. jumpTimer -= Time.deltaTime; // Set the Y Force for the player. GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, jumpFactor * (doubleJump ? holdToJumpHigher.doubleJumpForce : holdToJumpHigher.jumpForce))); // When the timer is finished or the jump button isn't being pressed... } else { // ... reset the jumping variables. ResetJumpVars(); } // Or else if you need a single press to perform a jump... } else { // Add a vertical force to the player. GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, jumpFactor * (doubleJump ? singlePressToJump.doubleJumpForce : singlePressToJump.jumpForce))); // If the player is on a platform... if (player.OnPlatform()) { // Set the moving platform to null. player.UnstickFromPlatform(); } // Reset the jumping variables. ResetJumpVars(); } } }
// Token: 0x060003E6 RID: 998 RVA: 0x00018788 File Offset: 0x00016B88 private void Update() { this.stick = (UnityEngine.Object.FindObjectOfType(typeof(EasyJoystick)) as EasyJoystick); if (CFInput.GetButton("Eat") && this.eats && this.questM.Eatbar()) { if (base.GetComponent <AttackTriggerC>().useMecanim) { this.mainModel.GetComponent <Animator>().CrossFade(this.EatingAnim, 0.5f); } else { this.mainModel.GetComponent <Animation>()[this.EatingAnim].layer = 25; this.mainModel.GetComponent <Animation>().CrossFade(this.EatingAnim); } } if (this.moveSleep && this.maleSleepPos && this.femaleSleepPos) { this.mate.transform.position = Vector3.MoveTowards(this.mate.transform.position, this.femaleSleepPos.position, 0.1f); base.transform.position = Vector3.MoveTowards(base.transform.position, this.maleSleepPos.position, 0.1f); } if (this.rotating) { this._lookRotation = Quaternion.LookRotation(this._direction); base.transform.rotation = Quaternion.Slerp(base.transform.rotation, this._lookRotation, Time.deltaTime * this.RotationSpeed); } StatusC component = base.GetComponent <StatusC>(); if (component.freeze) { this.motor.inputMoveDirection = new Vector3(0f, 0f, 0f); return; } if (Time.timeScale == 0f) { return; } if (this.dodging) { Vector3 a = base.transform.TransformDirection(this.dir); this.controller.Move(a * 8f * Time.deltaTime); return; } if (this.recover && !this.sprint && !this.dodging) { if (this.recoverStamina >= this.staminaRecover) { this.StaminaRecovery(); } else { this.recoverStamina += Time.deltaTime; } } if (this.dodgeRollSetting.canDodgeRoll) { if (CFInput.GetButtonDown("Vertical") && CFInput.GetAxis("Vertical") > 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && CFInput.GetAxis("Horizontal") == 0f) { if (CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime < 0.4f && CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime > 0.1f && CFInput.GetAxis("Vertical") > 0.03f) { this.lastTime = Time.time; this.dir = Vector3.forward; base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeForward)); } else { this.lastTime = Time.time; } } if (CFInput.GetButtonDown("Vertical") && CFInput.GetAxis("Vertical") < 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && CFInput.GetAxis("Horizontal") == 0f) { if (CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime < 0.4f && CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime > 0.1f && CFInput.GetAxis("Vertical") < -0.03f) { this.lastTime = Time.time; this.dir = Vector3.back; base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeBack)); } else { this.lastTime = Time.time; } } if (CFInput.GetButtonDown("Horizontal") && CFInput.GetAxis("Horizontal") < 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && !CFInput.GetButton("Vertical")) { if (CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime < 0.3f && CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime > 0.15f && CFInput.GetAxis("Horizontal") < -0.03f) { this.lastTime = Time.time; this.dir = Vector3.left; base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeLeft)); } else { this.lastTime = Time.time; } } if (CFInput.GetButtonDown("Horizontal") && CFInput.GetAxis("Horizontal") > 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && !CFInput.GetButton("Vertical")) { if (CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime < 0.3f && CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime > 0.15f && CFInput.GetAxis("Horizontal") > 0.03f) { this.lastTime = Time.time; this.dir = Vector3.right; base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeRight)); } else { this.lastTime = Time.time; } } } if ((this.sprint && Input.GetAxis("Vertical") < 0.02f) || (this.sprint && this.stamina <= 0f) || (this.sprint && Input.GetButtonDown("Fire1")) || (this.sprint && Input.GetKeyUp(KeyCode.LeftShift))) { this.sprint = false; this.recover = true; this.motor.movement.maxForwardSpeed = this.walkSpeed; this.motor.movement.maxSidewaysSpeed = this.walkSpeed; this.recoverStamina = 0f; } Vector3 vector = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")); if (vector != Vector3.zero) { float num = vector.magnitude; vector /= num; num = Mathf.Min(1f, num); num *= num; vector *= num; } this.motor.inputMoveDirection = base.transform.rotation * vector; if (CFInput.GetButton("Jump") && !this.alwJump) { base.GetComponent <PlayerMecanimAnimationC>().PlayAnim("jump"); base.GetComponent <PlayerMecanimAnimationC>().PlayAnim("Jump_place_All_short"); base.StartCoroutine(this.jumping()); } this.motor.inputJump = CFInput.GetButton("Jump"); if (this.sprint) { this.motor.movement.maxForwardSpeed = this.sprintSpeed; this.motor.movement.maxSidewaysSpeed = this.sprintSpeed; return; } if (CFInput.GetButton("Sprint") && Input.GetAxis("Vertical") > 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && this.canSprint && this.stamina > 0f) { this.sprint = true; base.StartCoroutine(this.Dasher()); } if (CFInput.GetButton("Sprint")) { } }
// Token: 0x0600032F RID: 815 RVA: 0x0000E5B0 File Offset: 0x0000C9B0 private void Update() { StatusC component = base.GetComponent <StatusC>(); if (this.freeze || this.atkDelay || Time.timeScale == 0f || component.freeze) { return; } CharacterController component2 = base.GetComponent <CharacterController>(); if (this.flinch && this.allowFlinch) { component2.Move(this.knock * 6f * Time.deltaTime); return; } if (Input.GetKeyDown(KeyCode.K)) { } if (Input.GetKeyDown(KeyCode.P)) { } if (this.meleefwd) { Vector3 a = base.transform.TransformDirection(Vector3.forward); component2.Move(a * 5f * Time.deltaTime); } if (this.aimingType == AttackTriggerC.AimType.Raycast || this.aimingType == AttackTriggerC.AimType.Normal) { this.Aiming(); } if (Input.GetKeyDown(KeyCode.Escape)) { if (Time.timeScale == 1f) { Time.timeScale = 0f; } else { Time.timeScale = 1f; } } if ((CFInput.GetButton("Fire1") || Input.GetButton("Firing")) && Time.time > this.nextFire && !this.isCasting) { if (!this.useBurst) { if (Time.time > this.nextFire + 0.5f) { this.c = 0; } if (this.attackCombo.Length >= 1) { this.conCombo++; base.StartCoroutine(this.AttackCombo()); } } else { this.nextFire = Time.time + 0.1f; Transform transform = UnityEngine.Object.Instantiate <Transform>(this.attackPrefab, this.attackPoint.transform.position, this.attackPoint.transform.rotation); transform.GetComponent <BulletStatusC>().Setting(this.str, this.matk, "Player", base.gameObject); base.GetComponent <AudioSource>().PlayOneShot(this.sound.attackComboVoice[0]); this.mainModel.GetComponent <Animator>().Play(this.attackCombo[0].name); } if (this.muzzleFlash) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.muzzleFlash, this.attackPoint.transform.position, this.attackPoint.transform.rotation); gameObject.transform.parent = this.attackPoint.transform; } } if (CFInput.GetButton("Fire3") && Time.time > this.nextFire && !this.isCasting && this.skillPrefab[this.skillEquip] && !component.silence) { base.GetComponent <WeaponSwitch>().bowArrow(); base.StartCoroutine(this.MagicSkill(0)); } if ((CFInput.GetButton("Attack") || Input.GetButton("Firing")) && Time.time > this.nextFire && !this.isCasting && !this.useBurst) { if (Time.time > this.nextFire + 0.5f) { this.c = 0; } if (this.attackCombo.Length >= 1) { this.conCombo++; base.StartCoroutine(this.AttackCombo()); } } }
// This function is called every fixed framerate frame. void FixedUpdate() { // Cache the vertical and horizontal CFInput. float v = CFInput.GetAxis("Vertical"); float h = CFInput.GetAxis("Horizontal"); // If the player is on a ladder and the Ladder class is set... if (player.onLadder && ladder) { // Create the variables used to check if the player is almost falling off the ladder. bool stillOnLadder = true; Vector2 pos = transform.position; Vector2 pointA = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2), pos.y + boxCollider.offset.y - (boxCollider.size.y / 2)); Vector2 pointB = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2)); // If the player is moving down and movement down is allowed... if (v < 0 && ladder.allowDown) { // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off. if (!ladder.fallOffBottom) { stillOnLadder = Physics2D.OverlapArea(pointA, new Vector2(pointB.x, pointB.y - 0.1f), ladderLayer); } // If the player isn't allowed to fall off and is almost falling off the ladder... if (!ladder.fallOffBottom && !stillOnLadder) { // ... make sure there is no Y movement. player.SetYVelocity(0); // Or else... } else { // ... set the player's Y velocity based on the climbing and default speed. player.SetYVelocity(v * (climingSpeedDown + (ladder.defaultSpeedY <= 0 ? ladder.defaultSpeedY : -ladder.defaultSpeedY))); } // Or else if the player is moving up and movement down is allowed... } else if (v > 0 && ladder.allowUp) { // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off. if (!ladder.fallOffTop) { stillOnLadder = Physics2D.OverlapArea(new Vector2(pointA.x, pointA.y + 0.1f), pointB, ladderLayer); } // If the player isn't allowed to fall off and is almost falling off the ladder... if (!ladder.fallOffTop && !stillOnLadder) { // ... make sure there is no Y movement. player.SetYVelocity(0); // Or else... } else { // ... set the player's Y velocity based on the climbing and default speed. player.SetYVelocity(v * (climingSpeedUp + ladder.defaultSpeedY)); } // Or else ... } else { // ... set the player's speed to the ladder's default speed. player.SetYVelocity(ladder.defaultSpeedY); } // If the player is grounded and is moving left or right... if (player.grounded && (h < 0 || h > 0)) { // ... unstick the player from the ladder. Unstick(); // Or else if the player is snapped to the middle... } else if (ladder.snapToMiddle) { // ... if the player is snapped to the middle and allowed to fall off the ladder and moving left or right... if (snappedToMiddle && (v == 0) && ((ladder.fallOffLeft && h < 0) || (ladder.fallOffRight && h > 0))) { // ... unstick the player from the ladder. Unstick(); // Or else... } else { // ... if the player is currently in the middle of the ladder... if (transform.position.x > (hitLadder.transform.position.x - 0.05f) && transform.position.x < (hitLadder.transform.position.x + 0.05f)) { // Make sure the X velocity is set to 0. player.SetXVelocity(0); // Make sure the player is snapped to the middle. snappedToMiddle = true; // Or else... } else { // ... calculate the velocity needed to move to the center of the ladder. Vector2 gotoCenter = (new Vector3(hitLadder.transform.position.x, transform.position.y, 0) - transform.position).normalized * snapSpeed; // Set the X velocity to this velocity. player.SetXVelocity(gotoCenter.x); // Make sure the player isnt't snapped to the middle. snappedToMiddle = false; } } // Or else... } else { // ... if the player is moving to the left and is allowed to move to the left... if (h < 0 && ladder.allowLeft) { // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off. if (!ladder.fallOffLeft) { // stillOnLadder = Physics2D.OverlapArea(pointA, new Vector2(pointB.x - 0.1f, pointB.y), ladderLayer); } // If the player isn't allowed to fall off and is almost falling off the ladder... if (!ladder.fallOffLeft && !stillOnLadder) { // ... make sure the X velocity is set to 0. player.SetXVelocity(0); // Or else... } else { // ... set the player's X velocity based on the climbing and default speed. player.SetXVelocity(h * (climingSpeedLeft + (ladder.defaultSpeedX <= 0 ? ladder.defaultSpeedX : -ladder.defaultSpeedX))); } // Or else if the player is moving to the right and is allowed to move to the right... } else if (h > 0 && ladder.allowRight) { // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off. if (!ladder.fallOffRight) { stillOnLadder = Physics2D.OverlapArea(new Vector2(pointA.x + 0.1f, pointA.y), pointB, ladderLayer); } // If the player isn't allowed to fall off and is almost falling off the ladder... if (!ladder.fallOffRight && !stillOnLadder) { // ... make sure the X velocity is set to 0. player.SetXVelocity(0); // Or else... } else { // ... set the player's X velocity based on the climbing and default speed. player.SetXVelocity(h * (climingSpeedRight + ladder.defaultSpeedX)); } // Or else... } else { // ... set the player's X velocity to the ladder's X default speed. player.SetXVelocity(ladder.defaultSpeedX); } } } }