diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 666bc85de542867f55fd2acd96375822da6060e2..ad69db95e10dd196b7cd5f0175fe04e6b22fb1c1 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -78,6 +78,7 @@ public class GameManager : MonoBehaviour public void BackToMainMenu() { + GameOverManager.ResetSession(); UnityEngine.SceneManagement.SceneManager.LoadScene("Main Menu"); } diff --git a/Assets/Scripts/Managers/GameOverManager.cs b/Assets/Scripts/Managers/GameOverManager.cs index 5863b7c14845c9e0e7ac5a185cb43fecbdf345df..a671dd6ae793e022a25e24018fc9edc53ae5e5d3 100644 --- a/Assets/Scripts/Managers/GameOverManager.cs +++ b/Assets/Scripts/Managers/GameOverManager.cs @@ -66,7 +66,7 @@ public class GameOverManager : MonoBehaviour } } - public void ResetSession() + public static void ResetSession() { // time ScoreManager.reset(); @@ -78,7 +78,7 @@ public class GameOverManager : MonoBehaviour //CheatManager.isTheFlast = false; //player - PlayerMoney.money = 0; + PlayerMoney.money = 300; QuestGiver.QuestData = null; // pet, weapon ShopPetManager.currentPetName = null; diff --git a/Assets/Scripts/Pet/Chicken/ChickenHealth.cs b/Assets/Scripts/Pet/Chicken/ChickenHealth.cs index 8a9e5d5c7cd36645fb9c38f98744ee726d6c0128..b6e298cc53273cc14f0322d912383a74daf50d6c 100644 --- a/Assets/Scripts/Pet/Chicken/ChickenHealth.cs +++ b/Assets/Scripts/Pet/Chicken/ChickenHealth.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -88,7 +89,7 @@ public class ChickenHealth : MonoBehaviour currentHealth -= CheatManager.isImmortalPet ? 0 : amount; - HealthSliderPet.value = currentHealth; + HealthSliderPet.value = 100f*currentHealth/startingHealth; chickenAudio.Play(); @@ -139,4 +140,9 @@ public class ChickenHealth : MonoBehaviour navMeshAgent.enabled = true; EnemyAttack.petAlive = true; } + + internal void UpdateSlider() + { + HealthSliderPet.value = 100f * currentHealth / startingHealth; + } } diff --git a/Assets/Scripts/Pet/Fox/FoxHealth.cs b/Assets/Scripts/Pet/Fox/FoxHealth.cs index 86e2007a44a3f9d96dfb35a273baf9096d0bc4db..c881ee6459b00bc4099f017d1f34055f8b35c846 100644 --- a/Assets/Scripts/Pet/Fox/FoxHealth.cs +++ b/Assets/Scripts/Pet/Fox/FoxHealth.cs @@ -1,4 +1,5 @@ using Assets.Scripts.Player; +using System; using System.Collections; using UnityEngine; using UnityEngine.AI; @@ -69,7 +70,7 @@ namespace Assets.Scripts.Pet.Fox damaged = true; currentHealth -= CheatManager.isImmortalPet ? 0 : amount; - healthSlider.value = currentHealth; + healthSlider.value = 100f*currentHealth/startingHealth; foxAudio.Play(); if (currentHealth <= 0 && !isDead) @@ -126,5 +127,10 @@ namespace Assets.Scripts.Pet.Fox playerBowing.attackMultiplier = 1f; swordAttack.attackMultiplier = 1f; } + + internal void UpdateSlider() + { + healthSlider.value = 100f*currentHealth/startingHealth; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerHealth.cs b/Assets/Scripts/Player/PlayerHealth.cs index b271aab454255836c10bd964af68a1517fe31ec9..209929765205aac463b581c86b7c5e274bc72bdd 100644 --- a/Assets/Scripts/Player/PlayerHealth.cs +++ b/Assets/Scripts/Player/PlayerHealth.cs @@ -64,7 +64,7 @@ public class PlayerHealth : MonoBehaviour, ISaveAble currentHealth -= CheatManager.isCheatNoDamage ? 0 : amount; // Set the health bar's value to the current health. - healthSlider.value = currentHealth; + healthSlider.value = 100f * currentHealth / startingHealth; // Play the hurt sound effect. playerAudio.Play (); @@ -117,6 +117,6 @@ public class PlayerHealth : MonoBehaviour, ISaveAble public void LoadFromSaveFile(SaveFile saveFile) { currentHealth = saveFile.Health; - healthSlider.value = currentHealth; + healthSlider.value = 100f * currentHealth / startingHealth; } } \ No newline at end of file diff --git a/Assets/Scripts/Quest/QuestGiver.cs b/Assets/Scripts/Quest/QuestGiver.cs index 5ee47a086b1a9ebc5081f32477ca101fff1401b7..9606b3842f36859cfc09ee900dcb6b83af574c50 100644 --- a/Assets/Scripts/Quest/QuestGiver.cs +++ b/Assets/Scripts/Quest/QuestGiver.cs @@ -24,11 +24,11 @@ public class QuestGiver : MonoBehaviour QuestData = new Dictionary<string, Quest[]>(); // QuestData.Clear(); QuestData.Add("Scene 1 Opening", new Quest[] { - new Quest("title 1", "description 1", 100, new QuestGoal(1,0,0,0)), - new Quest("title 2", "description 2", 200, new QuestGoal(0,1,0,0)) + new Quest("title 1", "description 1", 100, new QuestGoal(3,0,0,0)), + new Quest("title 2", "description 2", 200, new QuestGoal(0,3,0,0)) }); QuestData.Add("Scene 2 Middle", new Quest[] { - new Quest("title 3 middle", "description 3", 100, new QuestGoal(0,0,1,0)), + new Quest("title 3 middle", "description 3", 100, new QuestGoal(0,0,3,0)), new Quest("title 4 middle", "description 4", 200, new QuestGoal(0,0,0,1)) }); finalQuestSceneName = "Scene 2 Middle"; diff --git a/Assets/Scripts/SaveLoad/SaveLoadFacade.cs b/Assets/Scripts/SaveLoad/SaveLoadFacade.cs index 47fac816d325034409a9a57ed7361a9ce6cd29c7..d553c13f4441e8ce81025502c7ec0f5a0019bb45 100644 --- a/Assets/Scripts/SaveLoad/SaveLoadFacade.cs +++ b/Assets/Scripts/SaveLoad/SaveLoadFacade.cs @@ -93,7 +93,7 @@ public class SaveLoadFacade : MonoBehaviour player.GetComponent<Command>().LoadFromSaveFile(LoadedSaveFile); - var shop = GameObject.Find("Shopkeeper").GetComponent<Shop>().shopUI; + var shop = GameObject.Find("Environment").transform.Find("Shopkeeper").GetComponent<Shop>().shopUI; shop.transform.Find("ScrollRect").Find("PetContents").GetComponent<ShopPetManager>().LoadFromSaveFile(LoadedSaveFile); } FirstLoad = false; diff --git a/Assets/ShopPetManager.cs b/Assets/ShopPetManager.cs index 5e6afd3f9e83c7f00dbc7c57d6fddc8ae8d7b0d4..3d0b3911c619d684bf3c8fd32f755d0da446a7a6 100644 --- a/Assets/ShopPetManager.cs +++ b/Assets/ShopPetManager.cs @@ -35,17 +35,17 @@ public class ShopPetManager : MonoBehaviour, ISaveAble if (currentPetName == petList[0]) { pet.GetComponent<TurtleHealth>().currentHealth = petHealth; - pet.GetComponent<TurtleHealth>().healthSlider.value = petHealth; + pet.GetComponent<TurtleHealth>().UpdateSlider(); } else if (currentPetName == petList[1]) { pet.GetComponent<ChickenHealth>().currentHealth = petHealth; - pet.GetComponent<ChickenHealth>().HealthSliderPet.value = petHealth; + pet.GetComponent<ChickenHealth>().UpdateSlider(); } else if (currentPetName == petList[2]) { pet.GetComponent<FoxHealth>().currentHealth = petHealth; - pet.GetComponent<FoxHealth>().healthSlider.value = petHealth; + pet.GetComponent<FoxHealth>().UpdateSlider(); } } } @@ -87,17 +87,17 @@ public class ShopPetManager : MonoBehaviour, ISaveAble if (currentPetName == petList[0]) { pet.GetComponent<TurtleHealth>().currentHealth = petHealth; - pet.GetComponent<TurtleHealth>().healthSlider.value = petHealth; + pet.GetComponent<TurtleHealth>().UpdateSlider(); } else if (currentPetName == petList[1]) { pet.GetComponent<ChickenHealth>().currentHealth = petHealth; - pet.GetComponent<ChickenHealth>().HealthSliderPet.value = petHealth; + pet.GetComponent<ChickenHealth>().UpdateSlider(); } else if (currentPetName == petList[2]) { pet.GetComponent<FoxHealth>().currentHealth = petHealth; - pet.GetComponent<FoxHealth>().healthSlider.value = petHealth; + pet.GetComponent<FoxHealth>().UpdateSlider(); } } diff --git a/Assets/TurtleHealth.cs b/Assets/TurtleHealth.cs index 562b91ce11fd6e66fa78097a0ba010360c0b921a..3e8d713d2b424618d57c6cbf9b2a05cc2e5c2c57 100644 --- a/Assets/TurtleHealth.cs +++ b/Assets/TurtleHealth.cs @@ -2,6 +2,7 @@ using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; +using System; public class TurtleHealth : MonoBehaviour { @@ -69,7 +70,7 @@ public class TurtleHealth : MonoBehaviour damaged = true; currentHealth -= amount; - healthSlider.value = currentHealth; + healthSlider.value = 100f * currentHealth / startingHealth; if(currentHealth <= 0 && !isDead) { @@ -103,4 +104,9 @@ public class TurtleHealth : MonoBehaviour turtleMovement.enabled = true; EnemyAttack.petAlive = true; } + + internal void UpdateSlider() + { + healthSlider.value = 100f * currentHealth / startingHealth; + } }