Skip to content

Commit

Permalink
fix: Sync paused variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed May 4, 2024
1 parent ac1eaf4 commit ef17a3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
15 changes: 4 additions & 11 deletions Assets/JCSUnity/Scripts/Managers/JCS_GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ public class JCS_GameManager : JCS_Manager<JCS_GameManager>

[Separator("Check Variable (JCS_GameManager)")]

[Tooltip("Is the game pasue?")]
[SerializeField]
[ReadOnly]
private bool mGamePause = false;

[Tooltip("Is game done initialize?")]
[SerializeField]
[ReadOnly]
Expand All @@ -40,23 +35,21 @@ public class JCS_GameManager : JCS_Manager<JCS_GameManager>
public bool GAME_DONE_INITIALIZE { get { return this.mGameDoneInitialize; } }
public bool GAME_PAUSE
{
get { return this.mGamePause; }
get { return JCS_PauseManager.instance.Paused; }
set
{
var pm = JCS_PauseManager.instance;

// check if need the game pause the same as the value previously
// set. In order to save some perforce by enable/disable all the
// JCS_PauseAction in the game.
if (mGamePause != value)
if (pm.Paused != value)
{
var pm = JCS_PauseManager.instance;

if (value)
pm.Pause();
else
pm.Unpause();
}

this.mGamePause = value;
}
}
public JCS_Player Player { get { return this.mPlayer; } set { this.mPlayer = value; } }
Expand Down
7 changes: 7 additions & 0 deletions Assets/JCSUnity/Scripts/Managers/JCS_PauseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public class JCS_PauseManager : JCS_Manager<JCS_PauseManager>

[Separator("Check Variables (JCS_PauseManager)")]

[Tooltip("Set to true if game is paused.")]
[SerializeField]
private bool mPaused = false;

[Tooltip("Target time scale.")]
[SerializeField]
[ReadOnly]
Expand Down Expand Up @@ -98,6 +102,7 @@ public class JCS_PauseManager : JCS_Manager<JCS_PauseManager>

/* Setter & Getter */

public bool Paused { get { return this.mPaused; } }
public List<JCS_PauseAction> PausesActions { get { return this.mPauseActions; } }
public float ResizePauseActionListTime { get { return this.mResizePauseActionListTime; } set { this.mResizePauseActionListTime = value; } }
public float DefaultTimeScale { get { return this.mDefaultTimeScale; } set { this.mDefaultTimeScale = value; } }
Expand Down Expand Up @@ -213,6 +218,8 @@ public void PauseTheWholeGame(bool act = true)

// resize the list once.
RemoveNullRefInPauseActionList();

mPaused = act;
}

/// <summary>
Expand Down

0 comments on commit ef17a3d

Please sign in to comment.