public override void ProcessState() { bool PressedUp = Input.GetAxis("Vertical") > 0f; bool PressedDown = Input.GetAxis("Vertical") < 0f; bool PressedJump = Input.GetButtonDown("Action"); Actor.Velocity.x += Actor.AirAccelerationForward; if (PressedUp) { Actor.Velocity.y += Actor.AirAccelerationForward; } else if (PressedDown) { Actor.Velocity.y -= Actor.AirAccelerationForward; } else { Actor.Velocity.y = 0; } if (PressedJump) { MyStateManager.SetNextState("PlayerState_Idle"); } }
public override void ProcessState() { bool WalkingRight = Input.GetAxis("Horizontal") > 0f || AutoWalkRight; bool WalkingLeft = Input.GetAxis("Horizontal") < 0f || AutoWalkLeft; bool PressedJump = Input.GetButtonDown("Action"); if (Input.GetKeyDown("r")) { if (Actor.FacingRight) { AutoWalkRight = !AutoWalkRight; } else { AutoWalkLeft = !AutoWalkLeft; } } if (!Actor.IsGrounded) { MyStateManager.SetNextState("PlayerState_Fall"); } if (!WalkingRight && !WalkingLeft) { MyStateManager.SetNextState("PlayerState_Idle"); } if (PressedJump) { MyStateManager.SetNextState("PlayerState_Jump"); } if (WalkingRight) { Actor.Velocity.x += Actor.GroundAcceleration; if (Actor.Velocity.x < 0f) { Actor.Velocity.x += Actor.GroundAcceleration; } Actor.FacingRight = true; } if (WalkingLeft) { Actor.Velocity.x -= Actor.GroundAcceleration; if (Actor.Velocity.x > 0f) { Actor.Velocity.x -= Actor.GroundAcceleration; } Actor.FacingRight = false; } }
public override void ProcessState() { bool PressedWalk = Input.GetAxis("Horizontal") != 0; bool PressedJump = Input.GetButtonDown("Action"); if (Input.GetKeyDown("r")) { MyStateManager.SetNextState("PlayerState_Shmup"); } if (PressedWalk) { MyStateManager.SetNextState("PlayerState_Walk"); return; } if (Actor.IsGrounded && PressedJump) { MyStateManager.SetNextState("PlayerState_Jump"); return; } if (!Actor.IsGrounded) { MyStateManager.SetNextState("PlayerState_Fall"); return; } if (Actor.FacingRight) { Actor.Velocity.x -= Actor.GroundDeceleration; if (Actor.Velocity.x <= 0) { Actor.Velocity.x = 0; } } if (!Actor.FacingRight) { Actor.Velocity.x += Actor.GroundDeceleration; if (Actor.Velocity.x >= 0) { Actor.Velocity.x = 0; } } }
public override void ProcessState() { bool PressedUp = Input.GetAxis("Vertical") > 0f; bool PressedDown = Input.GetAxis("Vertical") < 0f; bool PressedRight = Input.GetAxis("Horizontal") > 0f; bool PressedLeft = Input.GetAxis("Horizontal") < 0f; if(PressedUp || PressedDown || PressedRight || PressedLeft){ MyStateManager.SetNextState("PlayerState_TopDownWalk"); } if(Actor.Velocity.x > 0f){ Actor.Velocity.x -= Actor.Deceleration; if(Actor.Velocity.x < 0f){ Actor.Velocity.x = 0f; } } if(Actor.Velocity.x < 0f){ Actor.Velocity.x += Actor.Deceleration; if(Actor.Velocity.x > 0f){ Actor.Velocity.x = 0f; } } if(Actor.Velocity.y > 0f){ Actor.Velocity.y -= Actor.Deceleration; if(Actor.Velocity.y < 0f){ Actor.Velocity.y = 0f; } } if(Actor.Velocity.y < 0f){ Actor.Velocity.y += Actor.Deceleration; if(Actor.Velocity.y > 0f){ Actor.Velocity.y = 0f; } } }
public override void ProcessState() { Actor.Velocity = new Vector3(0, 0, 0); Actor.Sprite.transform.rotation = Quaternion.Euler(0, 0, Rotation); Rotation += RotationSpeed; if (Rotation > 360) { Rotation = 0; } if (Input.GetKeyDown("o")) { Actor.Sprite.transform.rotation = Quaternion.Euler(0, 0, 0); MyStateManager.SetNextState("PlayerState_Idle"); return; } if (Input.GetKeyDown("up")) { RotationSpeed += 1; } if (Input.GetKeyDown("down")) { RotationSpeed -= 1; } if (RotationSpeed <= 0) { RotationSpeed = 0; } if (RotationSpeed >= 50) { RotationSpeed = 50; } }
public override void ProcessState() { float verticalExtent = Actor.Camera.orthographicSize; float horizontalExtent = verticalExtent * Screen.width / Screen.height; if (Input.GetKeyDown("m")) { MyStateManager.SetNextState("CameraState_Rotation"); } if (Actor.CurrentView == null) { return; } Actor.DestinationPosition = Actor.Player.transform.position + new Vector3(0, 2, -25); if (Actor.DestinationPosition.x - horizontalExtent < Actor.CurrentView.LeftExtent) { Actor.DestinationPosition.x = Actor.CurrentView.LeftExtent + horizontalExtent; } if (Actor.DestinationPosition.x + horizontalExtent > Actor.CurrentView.RightExtent) { Actor.DestinationPosition.x = Actor.CurrentView.RightExtent - horizontalExtent; } if (Actor.DestinationPosition.y - verticalExtent < Actor.CurrentView.BottomExtent) { Actor.DestinationPosition.y = Actor.CurrentView.BottomExtent + verticalExtent; } if (Actor.DestinationPosition.y + verticalExtent > Actor.CurrentView.TopExtent) { Actor.DestinationPosition.y = Actor.CurrentView.TopExtent - verticalExtent; } }
public override void ProcessState() { bool PressedUp = Input.GetAxis("Vertical") > 0f; bool PressedDown = Input.GetAxis("Vertical") < 0f; bool PressedRight = Input.GetAxis("Horizontal") > 0f; bool PressedLeft = Input.GetAxis("Horizontal") < 0f; if (!(PressedUp || PressedDown || PressedRight || PressedLeft)) { MyStateManager.SetNextState("PlayerState_TopDownIdle"); } if (PressedUp) { Actor.FacingDirection = "up"; Actor.Velocity.y += Actor.Acceleration; Actor.Velocity.x = 0; } else if (PressedRight) { Actor.FacingDirection = "right"; Actor.Velocity.x += Actor.Acceleration; Actor.Velocity.y = 0; } else if (PressedDown) { Actor.FacingDirection = "down"; Actor.Velocity.y -= Actor.Acceleration; Actor.Velocity.x = 0; } else if (PressedLeft) { Actor.FacingDirection = "left"; Actor.Velocity.x -= Actor.Acceleration; Actor.Velocity.y = 0; } }
public override void ProcessState() { if (Input.GetKeyDown("m")) { MyStateManager.SetNextState("CameraState_SnapToPlayer"); } if (Input.GetKeyDown("l")) { RotationSpeed += 1; } if (Input.GetKeyDown("k")) { RotationSpeed -= 1; } if (RotationSpeed <= 0) { RotationSpeed = 0; } if (RotationSpeed >= MaxRotationSpeed) { RotationSpeed = MaxRotationSpeed; } Actor.transform.rotation = Quaternion.Euler(0, 0, Rotation); Rotation += RotationSpeed; if (Rotation > 360) { Rotation = 0; } }
public override void ProcessState() { bool PressingRight = Input.GetAxis("Horizontal") > 0; bool PressingLeft = Input.GetAxis("Horizontal") < 0; bool StillHoldingJump = Input.GetButton("Action"); bool ExceededMaximumJumpDuration = TotalJumpDuration >= Actor.MaximumJumpDuration; bool HasBonkedHead = Actor.GenerateMaxOffset("UP") <= 0; if (Input.GetKeyDown("o")) { MyStateManager.SetNextState("PlayerState_Rotate"); return; } if (!PressingLeft && !PressingRight) { if (Actor.FacingRight) { if (Actor.Velocity.x > 0f) { Actor.Velocity.x -= Actor.AirDecelerationForward; if (Actor.Velocity.x <= 0f) { Actor.Velocity.x = 0f; } } else { Actor.Velocity.x += Actor.AirDecelerationBackward; if (Actor.Velocity.x >= 0f) { Actor.Velocity.x = 0f; } } } if (!Actor.FacingRight) { if (Actor.Velocity.x < 0f) { Actor.Velocity.x += Actor.AirDecelerationForward; if (Actor.Velocity.x >= 0f) { Actor.Velocity.x = 0f; } } else { Actor.Velocity.x -= Actor.AirDecelerationBackward; if (Actor.Velocity.x <= 0f) { Actor.Velocity.x = 0f; } } } } if (PressingRight) { if (Actor.FacingRight) { Actor.Velocity.x += Actor.AirAccelerationForward; } else { Actor.Velocity.x += Actor.AirAccelerationBackward; } if (Actor.CanChangeDirectionInMidAir) { Actor.FacingRight = true; } } if (PressingLeft) { if (!Actor.FacingRight) { Actor.Velocity.x -= Actor.AirAccelerationForward; } else { Actor.Velocity.x -= Actor.AirAccelerationBackward; } if (Actor.CanChangeDirectionInMidAir) { Actor.FacingRight = false; } } if (StillHoldingJump && !ExceededMaximumJumpDuration && !HasBonkedHead) { Actor.Velocity.y = Actor.JumpStrength; TotalJumpDuration += WorldProperties.GetDeltaTime(); } else { if (HasBonkedHead) { Actor.Velocity.y = 0; } MyStateManager.SetNextState("PlayerState_Fall"); } }
public override void ProcessState() { bool PressingRight = Input.GetAxis("Horizontal") > 0f; bool PressingLeft = Input.GetAxis("Horizontal") < 0f; if (Input.GetKeyDown("o")) { MyStateManager.SetNextState("PlayerState_Rotate"); return; } if (!Actor.IsGrounded) { if (Actor.Velocity.y > -WorldProperties.TerminalVelocity) { Actor.Velocity.y += -WorldProperties.Gravity; } } else { MyStateManager.SetNextState("PlayerState_Idle"); return; } if (!PressingLeft && !PressingRight) { if (Actor.FacingRight) { if (Actor.Velocity.x > 0f) { Actor.Velocity.x -= Actor.AirDecelerationForward; if (Actor.Velocity.x <= 0f) { Actor.Velocity.x = 0f; } } else { Actor.Velocity.x += Actor.AirDecelerationBackward; if (Actor.Velocity.x >= 0f) { Actor.Velocity.x = 0f; } } } if (!Actor.FacingRight) { if (Actor.Velocity.x < 0f) { Actor.Velocity.x += Actor.AirDecelerationForward; if (Actor.Velocity.x >= 0f) { Actor.Velocity.x = 0f; } } else { Actor.Velocity.x -= Actor.AirDecelerationBackward; if (Actor.Velocity.x <= 0f) { Actor.Velocity.x = 0f; } } } } if (PressingRight) { if (Actor.FacingRight) { Actor.Velocity.x += Actor.AirAccelerationForward; } else { Actor.Velocity.x += Actor.AirAccelerationBackward; } if (Actor.CanChangeDirectionInMidAir) { Actor.FacingRight = true; } } if (PressingLeft) { if (!Actor.FacingRight) { Actor.Velocity.x -= Actor.AirAccelerationForward; } else { Actor.Velocity.x -= Actor.AirAccelerationBackward; } if (Actor.CanChangeDirectionInMidAir) { Actor.FacingRight = false; } } }