private void CreateTrending() { if (Week == 4) { foreach (List <PuppetModificationBase> lpmb in AvailableModifications) { foreach (PuppetModificationBase pmb in lpmb) { foreach (Month m in pmb.TrendOfTheseMonthsEvent) { if (m == month) { trending = pmb; break; } } } } if (trending == null) { trending = PickRandomFromList(AvailableModifications[UnityEngine.Random.Range(0, Enum.GetNames(typeof(ModificationCategory)).Length)]); } } if (Week == 1) { trending = null; } UIManager.SetTrending(trending); }
public void SetTrending(PuppetModificationBase mod) { if (mod) { trendingImage.sprite = mod.OnHandleGO.GetComponent <Image>().sprite; } else { trendingImage.sprite = noTrendSprite; } }
public static void AModificationHasBeenTakenFromDrawer(PuppetModificationBase mod, int value = 1) { if (mod.Amount > 0) { mod.Amount -= value; } else { Debug.LogError($"(Negative amount of {mod.gameObject.name}) InventoryController isn't in control."); } }
/// <summary> /// Only keep one /// </summary> /// <param name="pmb"></param> public void RegisterNewModification(PuppetModificationBase pmb) { //PuppetModificationBase isItRegistered = AllModifications[(int)pmb.Category].Find(x => x.GetType() == pmb.GetType()); PuppetModificationBase isItRegistered = AllModifications[(int)pmb.Category].Find(x => x.Modification == pmb.Modification); if (isItRegistered == null) { Debug.Log("A new modification as been registered: " + pmb.name); AllModifications[(int)pmb.Category].Add(pmb); } else { Debug.LogError($"{pmb.name} has already been registered. From Gameobject: {GameManager.GetFullParentList(pmb.transform)}"); } }
public void SubstractCoins(PuppetModificationBase mod, bool isQuickBuy = false) { var value = isQuickBuy ? mod.cost * 2 : mod.cost; if (instance.Enough(value)) { instance.coins -= value; mod.Amount++; instance._UIManager.UpdateCoins(instance.coins); instance._audioManager.Play("Buying"); } else { instance._audioManager.Play("Invalid"); Debug.Log("Not Enough Coins"); } }
/// <summary> /// Add or swap a modification /// </summary> /// <param name="pm"> null if the modification slot was empty</param> /// <returns></returns> public void ApplyModification(PuppetModificationBase pm) { int pos = (int)pm.Category; PuppetModificationBase swap = _ModificationSlot[pos]; if (swap != null) { InventoryController.AModificationGoesBackToTheDrawer(swap); Destroy(transform.Find("Puppet").Find(((ModificationCategory)pos).ToString()).gameObject); } _audioManager.Play("Swap"); InventoryController.AModificationHasBeenTakenFromDrawer(pm); _ModificationSlot[pos] = pm; pm.PutOnhandle(transform); //pm.changestate... or maybe this should be managed in inventory /* Obsolete * * // The following is not necessary. * if (pm.Category == ModificationCategory.Dye) * { * if (dye != null /*&& dye != blank) * { * return pm; * } * else dye = (DyeModification)pm; * } * else if (pm.Category == ModificationCategory.Hair) * { * PuppetModificationBase h = hair; * hair = (HairModification)pm; * return h; * } * else if(pm.Category == ModificationCategory.Eyes) * { * * } * //Debug.LogError("Something went wrong while applying a modification. Check if the category is managed and if PuppetModification set its Category properly"); * return null; // if nothing been swapped */ }
public void ClearPuppetStand() { if (DragAndDrop.itemBeingDragged != null) { return; } for (int pos = 0; pos < System.Enum.GetValues(typeof(ModificationCategory)).Length; pos++) { PuppetModificationBase swap = _ModificationSlot[pos]; if (swap != null) { InventoryController.AModificationGoesBackToTheDrawer(swap); Destroy(transform.Find("Puppet").Find(((ModificationCategory)pos).ToString()).gameObject); } _ModificationSlot[pos] = null; } Destroy(transform.GetChild(0).GetComponent <DragAndDrop>()); }
public static void AModificationGoesBackToTheDrawer(PuppetModificationBase mod, int value = 1) { mod.Amount += value; }
public static bool Enough(PuppetModificationBase mod, int value = 1) { return(mod.Amount >= value); }