public static void Load_and_Post_Load() { if (SceneManager.GetActiveScene().name == playerData.current_scene) { ////////////////////////////////////////////////////////// koda = GameObject.FindGameObjectWithTag("Player"); if (koda != null) { koda_health = koda.GetComponent <PlayerHealth>(); koda_power = koda.GetComponent <KodaController>(); ////////////////////////////////////////////////////////// Load(); koda_health.SetHealthCurrent(playerData.hp); koda_health.SetHealthMax(playerData.hp_max); koda_power.SetRespawnPointPosition(playerData.check_point_x, playerData.check_point_y, playerData.check_point_z); //SceneManager.SetActiveScene(playerData.current_scene); // Working ONLY if the saved scene IS IN the SceneManager ! koda_power.SetPowerJump(playerData.lightBoss1); koda_power.SetPowerLure(playerData.lightBoss2); koda_power.SetPowerBall(playerData.power_ball); koda_power.SetPowerShrink(playerData.power_shrink); //koda_score.SetnbYokai(playerData.caught_yokai); selected_slot = playerData.selected_slot; Debug.Log("Game Loaded !"); } } else { Debug.Log("Trying to load a scene that is not supposed to exist in this game."); } }
public static void Update_Game() { ////////////////////////////////////////////////////////// koda = GameObject.FindGameObjectWithTag("Player"); if (koda != null) { koda_health = koda.GetComponent <PlayerHealth>(); koda_power = koda.GetComponent <KodaController>(); ////////////////////////////////////////////////////////// playerData.hp_max = koda_health.GetHealthMax(); playerData.hp = koda_health.GetHealthCurrent(); Transform check_point = koda_power.GetRespawnPointPosition(); playerData.check_point_x = check_point.position.x; playerData.check_point_y = check_point.position.y; playerData.check_point_z = check_point.position.z; playerData.current_scene = SceneManager.GetActiveScene().name; if (!playerData.lightBoss1) { playerData.power_jump = koda_power.GetPowerJump(); } else { playerData.power_jump = playerData.lightBoss1; koda_power.SetPowerJump(playerData.lightBoss1); } if (!playerData.lightBoss2) { playerData.power_lure = koda_power.GetPowerLure(); } else { playerData.power_lure = playerData.lightBoss2; koda_power.SetPowerLure(playerData.lightBoss2); } playerData.power_ball = koda_power.GetPowerBall(); playerData.power_shrink = koda_power.GetPowerShrink(); CountCollectableYokai(); playerData.caught_yokaiZ1P1 = score_valueZ1P1; playerData.caught_yokaiZ1P2 = score_valueZ1P2; playerData.caught_yokaiZ1P3 = score_valueZ1P3; playerData.caught_yokaiZ2P1 = score_valueZ2P1; playerData.caught_yokaiZ2P2 = score_valueZ2P2; playerData.caught_yokaiZ2P3 = score_valueZ2P3; switch (playerData.current_scene) { case "Z1-P1-complete": //playerData.caught_yokaiZ1P1 = koda_score.GetnbYokai(); playerData.caught_yokai = score_valueZ1P1; break; case "Z1-P2-complete": //playerData.caught_yokaiZ1P2 = koda_score.GetnbYokai(); playerData.caught_yokai = score_valueZ1P2; break; case "Z1-P3-complete": //playerData.caught_yokaiZ1P3 = koda_score.GetnbYokai(); playerData.caught_yokai = score_valueZ1P3; break; case "Z2-P1-complete": //playerData.caught_yokaiZ2P1 = koda_score.GetnbYokai(); playerData.caught_yokai = score_valueZ2P1; break; case "Z2-P2-complete": //playerData.caught_yokaiZ2P2 = koda_score.GetnbYokai(); playerData.caught_yokai = score_valueZ2P2; break; case "Z2-P3-complete": //playerData.caught_yokaiZ2P3 = koda_score.GetnbYokai(); playerData.caught_yokai = score_valueZ2P3; break; default: break; } playerData.selected_slot = selected_slot; scene_path = Application.persistentDataPath + "/savedGames_slot_" + playerData.selected_slot.ToString() + ".gs"; } }