// 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 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: 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; } }
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); } }
// 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()); } } }
// 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")) { } }