diff --git a/GGJ21/Assets/Scripts/Game.cs b/GGJ21/Assets/Scripts/Game.cs index 57f4971..2c0ea7e 100644 --- a/GGJ21/Assets/Scripts/Game.cs +++ b/GGJ21/Assets/Scripts/Game.cs @@ -104,7 +104,14 @@ void OnNewClient() { StartLevel(); } else { - Client = new Client(PetType.None, AccessoryType.None, "Dialog text"); + Array pets = Enum.GetValues(typeof(PetType)); + Array accessory = Enum.GetValues(typeof(AccessoryType)); + + Client = new Client( + (PetType)pets.GetValue(Random.Range(0, pets.Length)), + (AccessoryType)accessory.GetValue(Random.Range(0, pets.Length)), + "Dialog text" + ); cardsSelector.IsCanSelect = true; @@ -123,21 +130,38 @@ void OnNewClient() { } void OnSelectLeft() { - OnSelectAnyCard(); + bool isRight = CheckCard(0); + OnSelectAnyCard(isRight); } void OnSelectRight() { - OnSelectAnyCard(); + bool isRight = CheckCard(1); + OnSelectAnyCard(isRight); + } + + bool CheckCard(int id) { + bool isRight = true; + + if (Client.wantedPet != PetType.None) + isRight = Client.wantedPet == cards[id].petType; + + if (isRight && Client.wantedAccessory != AccessoryType.None) + isRight = Client.wantedAccessory == cards[id].accessoryType; + + Debug.Log($"Is right: {isRight}"); + return isRight; } - void OnSelectAnyCard() { - clientLeftUI.UpdateValue(currClientId + 1, Level.clients); + void OnSelectAnyCard(bool isRight) { + if(isRight) + clientLeftUI.UpdateValue(currClientId + 1, Level.clients); dialog.Hide(); cardsSelector.IsCanSelect = false; LeanTween.delayedCall(1.0f, () => { - ++currClientId; + if(isRight) + ++currClientId; OnNewClient(); }); } diff --git a/GGJ21/Assets/Scripts/Pet/PetCard.cs b/GGJ21/Assets/Scripts/Pet/PetCard.cs index 819f04a..e878962 100644 --- a/GGJ21/Assets/Scripts/Pet/PetCard.cs +++ b/GGJ21/Assets/Scripts/Pet/PetCard.cs @@ -10,6 +10,8 @@ public class PetCard : MonoBehaviour { public bool IsSelected { private set; get; } + public PetType petType { private set; get; } + public AccessoryType accessoryType { private set; get; } [Header("Data")] [SerializeField] PetData[] pets; @@ -22,13 +24,18 @@ public class PetCard : MonoBehaviour { #region Data - public void SetCard(PetType petType, AccessoryType accessoryType) { + public void SetCard(PetType _petType, AccessoryType _accessoryType) { + petType = _petType; + accessoryType = _accessoryType; + PetData petData; PetSpriteData petSprites; Sprite accessorySprite; if(petType == PetType.None) { - petData = pets.Random(); + int randomNum = Random.Range(0, pets.Length); + petData = pets[randomNum]; + petType = (PetType)(randomNum); } else { petData = pets[(int)(petType) - 1]; @@ -36,7 +43,9 @@ public void SetCard(PetType petType, AccessoryType accessoryType) { petSprites = petData.sprites.Random(); if (accessoryType == AccessoryType.None) { - accessorySprite = petData.accessories.Random(); + int randomNum = Random.Range(0, petData.accessories.Length); + accessorySprite = petData.accessories[randomNum]; + accessoryType = (AccessoryType)(randomNum); } else { accessorySprite = petData.accessories[(int)(accessoryType) - 1]; ;