Pull request #4: Jason
Merge in CEGJ/ludumdare50 from jason to dev * commit 'bd5efcb31a1335a9f65b63f37e5ae47b74ee7e0c': Fixed exiting safe zone before game starts Forgot to resolve deltaTime to Time.fixedDeltaTime
This commit is contained in:
commit
64b5704d34
@ -3,6 +3,10 @@ using UnityEngine.InputSystem;
|
||||
|
||||
//Could be a singleton
|
||||
public class GameFlowManager : MonoBehaviour {
|
||||
/// <summary>
|
||||
/// True if time is frozen (Start, Pause Menu, Dead)
|
||||
/// </summary>
|
||||
/// <remarks>Could be renamed appropriately</remarks>
|
||||
[field: SerializeField]
|
||||
public bool Paused { get; private set; } = true;
|
||||
public BaseState CurrentState { get; private set; } = null!;
|
||||
|
||||
@ -51,10 +51,10 @@ public class Entity : MonoBehaviour
|
||||
}
|
||||
|
||||
protected virtual void MoveToTarget(){
|
||||
|
||||
//Would be nice if we could force this to be in FixedUpdate
|
||||
direction = Vector3.RotateTowards(direction, (target.position - transform.position), rotSpeed*Time.fixedDeltaTime, 0.0f);
|
||||
if(!IsInAttackRange()){
|
||||
rb.MovePosition(transform.position + direction * movementSpeed * deltaTime);
|
||||
rb.MovePosition(transform.position + direction * movementSpeed * Time.fixedDeltaTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,8 @@ public class PlayerMovement : MonoBehaviour {
|
||||
bool lastJumpButton;
|
||||
|
||||
#region Unity Messages
|
||||
void Awake(){
|
||||
|
||||
void Awake() {
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
currentState = new ImmobileMovementState(this);
|
||||
}
|
||||
@ -65,7 +66,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
if (!wasJustPressed)
|
||||
return;
|
||||
|
||||
if (safeZone == null)
|
||||
if (gameFlowManager.Paused || safeZone == null)
|
||||
return;
|
||||
|
||||
if (safeZone.IsInSafeZone) {
|
||||
@ -113,15 +114,14 @@ public class PlayerMovement : MonoBehaviour {
|
||||
|
||||
abstract class BaseStatePlayerMovement : BaseState {
|
||||
protected PlayerMovement playerMovement;
|
||||
public BaseStatePlayerMovement(PlayerMovement playerMovement){
|
||||
|
||||
public BaseStatePlayerMovement(PlayerMovement playerMovement) {
|
||||
this.playerMovement = playerMovement;
|
||||
}
|
||||
}
|
||||
|
||||
class NormalMovementState : BaseStatePlayerMovement {
|
||||
public NormalMovementState(PlayerMovement playerMovement) : base(playerMovement){
|
||||
|
||||
}
|
||||
public NormalMovementState(PlayerMovement playerMovement) : base(playerMovement) {}
|
||||
|
||||
public override BaseState? FixedUpdateState() {
|
||||
playerMovement.rb.velocity = (Vector3)playerMovement.moveDirection * playerMovement.stats.movementSpeed;
|
||||
@ -167,6 +167,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
|
||||
class EnterSafeZoneMovementState : JumpingMovementState {
|
||||
readonly SafeZone safeZone;
|
||||
|
||||
public EnterSafeZoneMovementState(PlayerMovement playerMovement, SafeZone safeZone) : base(playerMovement, safeZone.Stats.JumpDuration, safeZone.transform.position) {
|
||||
this.safeZone = safeZone;
|
||||
}
|
||||
@ -185,6 +186,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
|
||||
class ExitSafeZoneMovementState : JumpingMovementState {
|
||||
readonly SafeZone safeZone;
|
||||
|
||||
public ExitSafeZoneMovementState(PlayerMovement playerMovement, SafeZone safeZone, Vector2 direction) : base(playerMovement, safeZone.Stats.JumpDuration, safeZone.GetOutsidePosition(direction)) {
|
||||
this.safeZone = safeZone;
|
||||
}
|
||||
@ -200,9 +202,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
}
|
||||
|
||||
class ImmobileMovementState : BaseStatePlayerMovement {
|
||||
public ImmobileMovementState(PlayerMovement playerMovement) : base(playerMovement){
|
||||
|
||||
}
|
||||
public ImmobileMovementState(PlayerMovement playerMovement) : base(playerMovement) {}
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user