// Update is called once per frame void Update() { if (!rewind.Complete) { currentStep--; if (currentStep < 0) { currentStep = movementCommands.Length - 1; } return; } if (Dead) { rewind.AddCommand(new IdleCommand(), false); return; } var command = movementCommands [currentStep]; command.MultiplyByDeltaTime(Time.deltaTime); rewind.AddCommand(command, true); currentStep = (currentStep + 1) % movementCommands.Length; HandleSpriteFlip(command.Direction.x); }
// Update is called once per frame void Update() { if (!rewind.Complete) { return; } var force = Direction * MovementSpeed; rewind.AddCommand(new MovementCommand(transform, force * Time.deltaTime), true); }
// Update is called once per frame void Update() { if (!rewind.Complete) { return; } if (Dead) { if (!onDeadRewindInvoked) { playerAnimation.Hurt(); rewindScene.PauseRewindAbility(); rewindScene.ExecuteInSeconds(0.4f); rewindScene.CancelInSeconds(2.5f); onDeadRewindInvoked = true; } CalculateDeadVelocity(); rewind.AddCommand(new PlayerDeadCommand(transform, amountToMove * Time.deltaTime, this), true); return; } if (BelowStage()) { Dead = true; return; } if (OkToClimb()) { HandleClimbing(); } if (OkToJump()) { CalculateJumpingVelocity(); } if (IsAlive()) { CalculateWalkingVelocity(); } if (OkToApplyGravity()) { CalculateGravity(); } Move(); HandleSpriteFlip(); }
void Update() { if (!rewind.Complete) { currentShootSpeed -= Time.deltaTime; if (currentShootSpeed < 0) { currentShootSpeed = 0f; } return; } currentShootSpeed += Time.deltaTime; if (currentShootSpeed > ShootSpeed) { currentShootSpeed = 0f; rewind.AddCommand(new ShootLaserCommand(transform, ShootDirection, LaserPrefab, rend, ShootSprite), true); } else { rewind.AddCommand(new IdleCommand(), false); } }
// Update is called once per frame void Update() { if (!rewind.Complete) { firstSightOfPlayer = true; return; } if (Dead) { var gravity = new Vector2(0, -1) * 16f; rewind.AddCommand(new MovementCommand(transform, gravity * Time.deltaTime), true); } var heading = Player.position - transform.position; var distance = heading.magnitude; var dir = heading / distance; if (distance < SightRadius) { if (firstSightOfPlayer) { rewind.AddCommand(new AnimationChangeCommand(animator, "playerInSight", true), true); firstSightOfPlayer = false; } var move = dir * MovementSpeed; rewind.AddCommand(new MovementCommand(transform, move * Time.deltaTime), true); HandleSpriteFlip(move.x); } else { rewind.AddCommand(new IdleCommand(), false); } }
public void Jump() { DisableAnimation(); rewind.AddCommand(enableJumpCommand, true); }