We introduce a new class, PlayerData
, to track the current level and points accrued of the player. To make use of this new functionality, we need to update some systems by performing the following steps:
Switch to the
LEVEL1
scene. Double-click on thePlayerData
script to begin editing it.Add a
public int score
and apublic GameState
level; note that in order to create an instance of the enumeration defined inside theGameMgr
class, we need to prefix withGameMgr
as shown in the following code:public class playerData : MonoBehaviour { public int score; public GameMgr eGameState;
Add a public method called
addScore(int dScore)
. This method will be used by the different systems (primarilyMissionMgr
), to add score to the player's record. Note that since we use an integer for score, we could use this same method to add score or penalize the player (by adding negative scores) as shown in the following code:public void AddScore(int dScore) { score += dScore; }
Add a public...