Skip to content

Commit f1792d7

Browse files
authored
Merge pull request #665 from Nicky-Nice-Games/TimeTrialDataFix
Time trial data fix
2 parents bda32dd + 878cc5e commit f1792d7

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

GGK/Assets/Scripts/API/PlayerInfo.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class PlayerInfo : ScriptableObject
4444
public PlayerKart PlayerCharacter; // should probably be an enum referencing each character
4545
public Color PlayerColor;
4646
public ulong clientID;
47+
public GameModes curGameMode;
4748

4849
//Default constructor
4950
public PlayerInfo()
@@ -159,10 +160,27 @@ public PlayerInfo(PlayerInfo other)
159160
collisionWithWalls = other.collisionWithWalls;
160161
characterUsed = other.characterUsed;
161162
fellOffMap = other.fellOffMap;
163+
curGameMode = other.curGameMode;
162164

163165
boostUsage = new Dictionary<string, int>(other.boostUsage);
164166
offenceUsage = new Dictionary<string, int>(other.offenceUsage);
165167
trapUsage = new Dictionary<string, int>(other.trapUsage);
166168
defenseUsage = new Dictionary<string, int>(other.defenseUsage);
167169
}
170+
171+
/// <summary>
172+
/// Gets rid of unneeded data for time trial
173+
/// </summary>
174+
public void DeleteDataForTimeTrial()
175+
{
176+
Debug.Log("Called DeleteDataForTimeTrial");
177+
racePos = 0;
178+
collisionsWithPlayers = 0;
179+
collisionWithWalls = 0;
180+
fellOffMap = 0;
181+
boostUsage.Clear();
182+
offenceUsage.Clear();
183+
trapUsage.Clear();
184+
defenseUsage.Clear();
185+
}
168186
}

GGK/Assets/Scripts/DriverScripts/NEWDriver.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,11 @@ public void Recover()
11401140
public void SendThisPlayerData()
11411141
{
11421142
//client sending their own data
1143-
if (!playerInfo.isGuest)
1143+
if (!playerInfo.isGuest )
11441144
{
11451145
playerInfo.fellOffMap /= 2;
1146+
Debug.Log("Is on time trial? " + playerInfo.curGameMode);
1147+
if (playerInfo.curGameMode == GameModes.timeTrial) { playerInfo.DeleteDataForTimeTrial(); }
11461148
gameManagerObj.GetComponent<APIManager>().PostPlayerData(playerInfo);
11471149
}
11481150

GGK/Assets/Scripts/GameManagers/GameManager.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ public void LoadedGameModeRpc()
197197

198198
public void ChangeGameMode(GameModes gameMode)
199199
{
200+
playerInfo.curGameMode = gameMode;
200201
curGameMode = gameMode;
202+
Debug.Log("Changing game mode to " + gameMode);
201203
}
202204

203205
/// <summary>
@@ -428,22 +430,30 @@ public void FillMapRaced(NEWDriver player)
428430
{
429431
switch (SceneManager.GetActiveScene().name)
430432
{
431-
case "LD_RITOuterLoop":
433+
case "TT_RITOuterLoop":
434+
case "LD_RITOuterLoop-Backup":
432435
Debug.Log("Map data: Outer Loop (1)");
433436
player.playerInfo.mapRaced = 1;
434437
break;
435-
case "LD_RITDorm":
438+
439+
case "TT_RITDorm":
440+
case "GSP_RITDorm":
436441
Debug.Log("Map data: Dorm (2)");
437442
player.playerInfo.mapRaced = 2;
438443
break;
444+
445+
case "TT_Golisano":
439446
case "GSP_Golisano":
440447
Debug.Log("Map data: Golisano (3)");
441448
player.playerInfo.mapRaced = 3;
442449
break;
450+
451+
case "TT_FinalsBrickRoad":
443452
case "GSP_FinalsBrickRoad":
444453
Debug.Log("Map data: Finals Brick (4)");
445454
player.playerInfo.mapRaced = 4;
446455
break;
456+
447457
default:
448458
break;
449459
}

0 commit comments

Comments
 (0)