Rename RabiGameState to InGameState
This commit is contained in:
parent
cd0b45de22
commit
d6f701b12e
@ -5,37 +5,37 @@ using System.Text;
|
|||||||
|
|
||||||
namespace rabi_splitter_WPF
|
namespace rabi_splitter_WPF
|
||||||
{
|
{
|
||||||
enum GameActivity
|
enum InGameActivity
|
||||||
{
|
{
|
||||||
STARTING,
|
STARTING,
|
||||||
WALKING,
|
WALKING,
|
||||||
BOSS_BATTLE,
|
BOSS_BATTLE,
|
||||||
}
|
}
|
||||||
|
|
||||||
class RabiGameState
|
class InGameState
|
||||||
{
|
{
|
||||||
public int nRestarts;
|
public int nRestarts;
|
||||||
public int nDeaths;
|
public int nDeaths;
|
||||||
|
|
||||||
public int nDeathsAlt;
|
public int nDeathsAlt;
|
||||||
|
|
||||||
public GameActivity currentActivity;
|
public InGameActivity currentActivity;
|
||||||
|
|
||||||
public int lastNonZeroPlayTime = -1;
|
public int lastNonZeroPlayTime = -1;
|
||||||
|
|
||||||
public RabiGameState()
|
public InGameState()
|
||||||
{
|
{
|
||||||
currentActivity = GameActivity.STARTING;
|
currentActivity = InGameActivity.STARTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CurrentActivityIs(GameActivity gameActivity)
|
public bool CurrentActivityIs(InGameActivity gameActivity)
|
||||||
{
|
{
|
||||||
return currentActivity == gameActivity;
|
return currentActivity == gameActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsGameStarted()
|
public bool IsGameStarted()
|
||||||
{
|
{
|
||||||
return !CurrentActivityIs(GameActivity.STARTING);
|
return !CurrentActivityIs(InGameActivity.STARTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace rabi_splitter_WPF
|
|||||||
private MainWindow mainWindow;
|
private MainWindow mainWindow;
|
||||||
|
|
||||||
private GameStatus gameStatus = GameStatus.MENU;
|
private GameStatus gameStatus = GameStatus.MENU;
|
||||||
private RabiGameState gameState;
|
private InGameState inGameState;
|
||||||
private MemorySnapshot prevSnapshot;
|
private MemorySnapshot prevSnapshot;
|
||||||
private MemorySnapshot snapshot;
|
private MemorySnapshot snapshot;
|
||||||
|
|
||||||
@ -57,11 +57,11 @@ namespace rabi_splitter_WPF
|
|||||||
{
|
{
|
||||||
#region Game State Machine
|
#region Game State Machine
|
||||||
|
|
||||||
if (gameState.CurrentActivityIs(GameActivity.STARTING)) {
|
if (inGameState.CurrentActivityIs(InGameActivity.STARTING)) {
|
||||||
// Detect start game
|
// Detect start game
|
||||||
if (0 < snapshot.playtime && snapshot.playtime < 200)
|
if (0 < snapshot.playtime && snapshot.playtime < 200)
|
||||||
{
|
{
|
||||||
gameState.currentActivity = GameActivity.WALKING;
|
inGameState.currentActivity = InGameActivity.WALKING;
|
||||||
DebugLog("IGT start?");
|
DebugLog("IGT start?");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -69,11 +69,11 @@ namespace rabi_splitter_WPF
|
|||||||
{
|
{
|
||||||
if (StaticData.IsBossMusic(snapshot.musicid))
|
if (StaticData.IsBossMusic(snapshot.musicid))
|
||||||
{
|
{
|
||||||
gameState.currentActivity = GameActivity.BOSS_BATTLE;
|
inGameState.currentActivity = InGameActivity.BOSS_BATTLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gameState.currentActivity = GameActivity.WALKING;
|
inGameState.currentActivity = InGameActivity.WALKING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,17 +101,17 @@ namespace rabi_splitter_WPF
|
|||||||
#region Detect Reload
|
#region Detect Reload
|
||||||
|
|
||||||
bool reloaded = (prevSnapshot != null) && (snapshot.playtime < prevSnapshot.playtime);
|
bool reloaded = (prevSnapshot != null) && (snapshot.playtime < prevSnapshot.playtime);
|
||||||
if (gameState.IsGameStarted() && snapshot.playtime > 0)
|
if (inGameState.IsGameStarted() && snapshot.playtime > 0)
|
||||||
{
|
{
|
||||||
if (snapshot.playtime < gameState.lastNonZeroPlayTime)
|
if (snapshot.playtime < inGameState.lastNonZeroPlayTime)
|
||||||
{
|
{
|
||||||
if (InGame())
|
if (InGame())
|
||||||
{
|
{
|
||||||
gameState.nRestarts++;
|
inGameState.nRestarts++;
|
||||||
}
|
}
|
||||||
DebugLog("Reload Game! " + snapshot.playtime + " <- " + gameState.lastNonZeroPlayTime);
|
DebugLog("Reload Game! " + snapshot.playtime + " <- " + inGameState.lastNonZeroPlayTime);
|
||||||
}
|
}
|
||||||
gameState.lastNonZeroPlayTime = snapshot.playtime;
|
inGameState.lastNonZeroPlayTime = snapshot.playtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -124,7 +124,7 @@ namespace rabi_splitter_WPF
|
|||||||
{
|
{
|
||||||
if (InGame())
|
if (InGame())
|
||||||
{
|
{
|
||||||
gameState.nDeaths++;
|
inGameState.nDeaths++;
|
||||||
}
|
}
|
||||||
DebugLog("Death!");
|
DebugLog("Death!");
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ namespace rabi_splitter_WPF
|
|||||||
{
|
{
|
||||||
if (InGame())
|
if (InGame())
|
||||||
{
|
{
|
||||||
gameState.nDeathsAlt++;
|
inGameState.nDeathsAlt++;
|
||||||
}
|
}
|
||||||
DebugLog("Death (Alt)!");
|
DebugLog("Death (Alt)!");
|
||||||
}
|
}
|
||||||
@ -163,8 +163,8 @@ namespace rabi_splitter_WPF
|
|||||||
|
|
||||||
mainContext.Text1 = "Music: " + StaticData.GetMusicName(snapshot.musicid);
|
mainContext.Text1 = "Music: " + StaticData.GetMusicName(snapshot.musicid);
|
||||||
mainContext.Text2 = "Map: " + StaticData.GetMapName(snapshot.mapid);
|
mainContext.Text2 = "Map: " + StaticData.GetMapName(snapshot.mapid);
|
||||||
mainContext.Text3 = gameState == null ? "" : ("Deaths: " + gameState.nDeaths// + " [" + gameState.nDeathsAlt + "]"
|
mainContext.Text3 = inGameState == null ? "" : ("Deaths: " + inGameState.nDeaths// + " [" + gameState.nDeathsAlt + "]"
|
||||||
+ "\n" + "Resets: " + gameState.nRestarts);// + " [" + gameState.nRestartsAlt + "]");
|
+ "\n" + "Resets: " + inGameState.nRestarts);// + " [" + gameState.nRestartsAlt + "]");
|
||||||
|
|
||||||
mainContext.Text4 = "HP: " + snapshot.hp + " / " + snapshot.maxhp;
|
mainContext.Text4 = "HP: " + snapshot.hp + " / " + snapshot.maxhp;
|
||||||
mainContext.Text5 = "Amulet: " + snapshot.amulet + "\n" + "Boost: " + snapshot.boost;
|
mainContext.Text5 = "Amulet: " + snapshot.amulet + "\n" + "Boost: " + snapshot.boost;
|
||||||
@ -188,7 +188,7 @@ namespace rabi_splitter_WPF
|
|||||||
mainContext.Text14 = $"PLAYTIME: {snapshot.playtime}";
|
mainContext.Text14 = $"PLAYTIME: {snapshot.playtime}";
|
||||||
|
|
||||||
{
|
{
|
||||||
string bosstext = "Boss Fight: " + (gameState.currentActivity == GameActivity.BOSS_BATTLE) + "\n";
|
string bosstext = "Boss Fight: " + (inGameState.currentActivity == InGameActivity.BOSS_BATTLE) + "\n";
|
||||||
bosstext += "Bosses: " + snapshot.bossList.Count + "\n";
|
bosstext += "Bosses: " + snapshot.bossList.Count + "\n";
|
||||||
foreach (var boss in snapshot.bossList)
|
foreach (var boss in snapshot.bossList)
|
||||||
{
|
{
|
||||||
@ -201,14 +201,14 @@ namespace rabi_splitter_WPF
|
|||||||
|
|
||||||
private void StartNewGame()
|
private void StartNewGame()
|
||||||
{
|
{
|
||||||
gameState = new RabiGameState();
|
inGameState = new InGameState();
|
||||||
gameStatus = GameStatus.INGAME;
|
gameStatus = GameStatus.INGAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReturnToMenu()
|
private void ReturnToMenu()
|
||||||
{
|
{
|
||||||
gameStatus = GameStatus.MENU;
|
gameStatus = GameStatus.MENU;
|
||||||
gameState = null;
|
inGameState = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool InGame()
|
private bool InGame()
|
||||||
@ -266,7 +266,7 @@ namespace rabi_splitter_WPF
|
|||||||
ptr += StaticData.EnenyEntitySize[mainContext.veridx];
|
ptr += StaticData.EnenyEntitySize[mainContext.veridx];
|
||||||
}
|
}
|
||||||
|
|
||||||
debugContext.BossEvent = gameState.currentActivity == GameActivity.BOSS_BATTLE;
|
debugContext.BossEvent = inGameState.currentActivity == InGameActivity.BOSS_BATTLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DebugLog(string log)
|
private void DebugLog(string log)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user