private void ContinueGame() { Player.instance.gameObject.SetActive(true); CheckPointSave.LoadPlayer(Player.instance.gameObject); //SceneManager.LoadScene(PlayerPrefs.GetInt("SceneIndex")); // LoadSceneMode.Single is the Default // // Make sure it loads Player prefs and works with the checkpoint system }
public void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player")) { return; } CheckPointSave.LoadPlayer(other.gameObject); }
public void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player")) { return; } if (CheckPointSave.currentCheckpointIndex <= checkpointIndex) { Debug.Log("Saved"); CheckPointSave.SavePlayer(other.gameObject); CheckPointSave.currentCheckpointIndex = checkpointIndex; } }
public void BikeRace_Save_SavesBikeRace() { // Arrange BikeRace race = new BikeRace(new string[] { "Tom", "Dick", "Harry" }); // Act race.RunToCheckPoint(); CheckPointSave checkpointOne = new CheckPointSave(race.Save()); race.RunToCheckPoint(); // Assert Assert.AreNotSame(race.GetRace(), checkpointOne.Restore()); }
public static void Run() { Console.WriteLine($"{Environment.NewLine}*** MEMENTO PATTERN ***{Environment.NewLine}"); BikeRace race = new BikeRace(new string[] { "Tom", "Dick", "Harry", "Bill", "Jim", "Rick", "Fred", "Joe", "Dan", "Gav", "Mark", "Henry" }); // Run to first checkpoint race.RunToCheckPoint(); race.DisplayTheRace(); CheckPointSave checkpointOne = new CheckPointSave(race.Save()); race.RunToCheckPoint(); race.DisplayTheRace(); // Return to the saved state race.Restore(checkpointOne.Restore()); race.DisplayTheRace(); }
public void LoadCheckpoint() { CheckPointSave.LoadPlayer(gameObject); }