diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 8363cb6381175b9b33b31c41d1a9961d62474a47..b1a15b7eca97fbc597a65abddab0c9b54d1979b6 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -99,9 +99,9 @@ public class GameManager : MonoBehaviour } } - public void NewPet(string name) + public void NewPet(PetData petData) { - petFactory.FactoryMethod(name); + petFactory.FactoryMethod(petData); } public void NewWeapon(int id) diff --git a/Assets/Scripts/Pet/PetFactory.cs b/Assets/Scripts/Pet/PetFactory.cs index cb125b35c9b0474baf60b159419c39b20d778f82..ddab77aee9a85bff1e4b71f067d25a0fdde4d597 100644 --- a/Assets/Scripts/Pet/PetFactory.cs +++ b/Assets/Scripts/Pet/PetFactory.cs @@ -16,17 +16,17 @@ public class PetFactory : MonoBehaviour GameObject pet; - public void FactoryMethod(string name) + public void FactoryMethod(PetData petData) { - if (name == "rabbit") + if (petData.name == "rabbit") { pet = Instantiate(petRabbitPrefab, PlayerTransform); } - else if (name == "sparrow") + else if (petData.name == "sparrow") { pet = Instantiate(petSparrowPrefab, PlayerTransform); } - else if (name == "cultist") + else if (petData.name == "cultist") { pet = Instantiate(petCultistPrefab, PlayerTransform); } @@ -46,5 +46,8 @@ public class PetFactory : MonoBehaviour petHealth.pawImage = pawImage; petHealth.petHealthSliderObj = petHealthSlider; } + + // Integrate new pet with GameManager + GameManager.gameManager.currentPet = petData; } } diff --git a/Assets/Scripts/Pet/PetHealth.cs b/Assets/Scripts/Pet/PetHealth.cs index 7dee5bc589bc01602bfb5bb8a1835f7ff675e199..f1e32dedf4e42e0888e7c0b5bf44865da9c567b8 100644 --- a/Assets/Scripts/Pet/PetHealth.cs +++ b/Assets/Scripts/Pet/PetHealth.cs @@ -28,6 +28,9 @@ public class PetHealth : MonoBehaviour void Start() { + // Set isPetAlive in GameManager to true + GameManager.gameManager.isPetAlive = true; + anim = GetComponent <Animator> (); petAudio = GetComponent <AudioSource> (); petMovement = GetComponent<PetMovement>(); @@ -87,6 +90,9 @@ public class PetHealth : MonoBehaviour { isDead = true; + // Set isPetAlive in gameManager to false + GameManager.gameManager.isPetAlive = false; + // Hide GameObject UI petHealthSliderObj.SetActive(false); pawImage.SetActive(false); diff --git a/Assets/Scripts/Shop/ShopManager.cs b/Assets/Scripts/Shop/ShopManager.cs index ac61e5cc9749a8e11f3f37d79966f79b3de1b4ac..f983aad9886bcb9cccc8329dd9562364a98cc5b3 100644 --- a/Assets/Scripts/Shop/ShopManager.cs +++ b/Assets/Scripts/Shop/ShopManager.cs @@ -13,7 +13,7 @@ public class ShopManager : MonoBehaviour public GameObject petPanelPrefab; public GameObject weaponPanelPrefab; public GameObject parent; - + public HUDManager hudManager; // Coins @@ -129,14 +129,14 @@ public class ShopManager : MonoBehaviour coins.text = GameManager.gameManager.coins.ToString(); // Update pet - GameManager.gameManager.NewPet(petData.name); + GameManager.gameManager.NewPet(petData); GameManager.gameManager.currentPet = petData; GameManager.gameManager.isPetAlive = true; this.petData.Remove(petData); GenerateShopPanel(); } - + } - + }