protected virtual void ShowFoodPreferenceMessage() { if (!isFinishEating) { string preferredFoodID = MiniPetManager.Instance.GetFoodPreference(minipetId); Item item = DataLoaderItems.GetItem(preferredFoodID); miniPetSpeechAI.ShowFoodPreferenceMsg(item.TextureName); } }
public void SetDecoration(string itemID, bool isPlacedFromDecoMode) { // Do one last check if (!CanPlaceDecoration(itemID)) { Debug.LogError("Illegal deco placement for " + itemID + " on node " + gameObject); return; } if (nodeType == DecorationTypes.Wallpaper) // Wallpapers always needs to be removed { RemoveDecoration(); } else if (HasDecoration()) // If there was already a decoration here, remove it { RemoveDecoration(); } placedDecoID = itemID; // update the save data with the new decoration id DataManager.Instance.GameData.Decorations.PlacedDecorations[nodeID] = itemID; // Notify inventory logic that this item is being used InventoryManager.Instance.UsePetItem(itemID); _SetDecoration(itemID, isPlacedFromDecoMode); // Play a sound DecorationItem itemDeco = (DecorationItem)DataLoaderItems.GetItem(itemID); if (isPlacedFromDecoMode) { if (itemDeco.DecorationType == DecorationTypes.Poster || itemDeco.DecorationType == DecorationTypes.Wallpaper) { AudioManager.Instance.PlayClip("decoPlacePaper"); } else { AudioManager.Instance.PlayClip("decoPlaceFurniture"); } // play an FX Vector3 particlePos = transform.position; string particlePrefabName = Constants.GetConstant <string>("Deco_PlaceParticle"); ParticleUtils.CreateParticle(particlePrefabName, particlePos); } //Check for badge unlock int totalNumOfDecorations = DataManager.Instance.GameData.Decorations.PlacedDecorations.Count; BadgeManager.Instance.CheckSeriesUnlockProgress(BadgeType.Decoration, totalNumOfDecorations, true); }
private bool CanPlaceDecoration(string itemID) { bool isPlaceable = true; // Start optimistic // Compare the node type to the decoration type DecorationItem itemDeco = (DecorationItem)DataLoaderItems.GetItem(itemID); DecorationTypes nodeType = GetDecoType(); DecorationTypes decoType = itemDeco.DecorationType; isPlaceable = (nodeType == decoType); return(isPlaceable); }
// Show the updated inventory bar with new item and destroy the tweening sprite private void OnBuyAnimationDone(object obj) { string itemID = ((GameObject)obj).name; ItemType type = DataLoaderItems.GetItem(itemID).Type; if (type == ItemType.Foods || type == ItemType.Usables) { InventoryUIManager.Instance.PulseInventory(); InventoryUIManager.Instance.RefreshPage(); } else if (type == ItemType.Decorations) { DecoInventoryUIManager.Instance.PulseInventory(); DecoInventoryUIManager.Instance.RefreshPage(); } Destroy((GameObject)obj); }
/// <summary> /// Checks the store button pulse. /// This does all the check by itself so dont worry when calling this /// </summary> public void CheckStoreButtonPulse() { Item neededItem = DataLoaderItems.GetItem(MiniPetManager.Instance.GetFoodPreference(SelectedMiniPetID)); bool isNeedItem = !DataManager.Instance.GameData.Inventory.InventoryItems.ContainsKey(neededItem.ID); bool isPetFed = !DataManager.Instance.GameData.MiniPets.IsPetFinishedEating(SelectedMiniPetID); if (isNeedItem && IsOpen && isPetFed) { storeButtonPulseAnim.Play(); storeButtonSunbeam.SetActive(true); } else { storeButtonPulseAnim.Stop(); GameObjectUtils.ResetLocalScale(storeButtonPulseAnim.gameObject); storeButtonSunbeam.SetActive(false); } }
/// <summary> /// Returns a dictionary of stats info on the incoming item. May return null. /// </summary> /// <returns>The stats dict.</returns> private Dictionary <StatType, int> GetStatsDict(string itemID) { Item item = DataLoaderItems.GetItem(itemID); Dictionary <StatType, int> dictStats = null; switch (item.Type) { case ItemType.Foods: FoodItem foodItem = (FoodItem)item; dictStats = foodItem.Stats; break; case ItemType.Usables: UsableItem usableItem = (UsableItem)item; dictStats = usableItem.Stats; break; } return(dictStats); }
//void OnGUI() { // if(GUI.Button(new Rect(100, 100, 100, 100), "FIRE")){ // Debug.Log("Adding"); // AddItemToInventory("Usable1", 1); // InventoryUIManager.Instance.RefreshPage(); // } //} public void AddItemToInventory(string itemID, int count = 1) { Dictionary <string, InventoryItem> specificTypeInventory = GetInventoryTypeForItem(itemID); Item itemData = DataLoaderItems.GetItem(itemID); InventoryItem invItem = null; // If item already in dictionary increment amount if (specificTypeInventory.ContainsKey(itemID)) { // Only one allowed for wallpaper/accessory if (IsWallpaperBought(itemID) || IsAccessoryBought(itemID)) { return; } specificTypeInventory[itemID].Amount += count; } else //Add InventoryItem into dict if key doesn't exist { invItem = new InventoryItem(itemID, itemData.Type, itemData.TextureName); specificTypeInventory[itemID] = invItem; //special case: keep track of bought wallpaper in another list. if (itemData.Type == ItemType.Decorations) { DecorationItem decoItem = (DecorationItem)itemData; if (decoItem.DecorationType == DecorationTypes.Wallpaper) { List <string> oneTimePurchasedInv = DataManager.Instance.GameData.Inventory.OneTimePurchasedItems; oneTimePurchasedInv.Add(itemData.ID); } } //special case: keep track of all bought accessories in another list. if (itemData.Type == ItemType.Accessories) { List <string> oneTimePurchasedInv = DataManager.Instance.GameData.Inventory.OneTimePurchasedItems; oneTimePurchasedInv.Add(itemData.ID); } } // NOTE: No need to add items to UI here, the complete buy tween will refresh by itself }
private MiniPetMerchant merchantScript; // Reference to minipet logic public void InitializeContent(string itemID, bool isBoughtAlready, ItemType itemType, MiniPetMerchant merchantScript) { this.merchantScript = merchantScript; secretItem = DataLoaderItems.GetItem(itemID); itemNameLabel.text = secretItem.Name; descriptionLabel.text = secretItem.Description; itemImage.sprite = SpriteCacheManager.GetItemSprite(secretItem.ID); cost.text = secretItem.Cost.ToString(); if (isBoughtAlready) // Enable some game components here { buyButton.gameObject.SetActive(false); } if (itemType == ItemType.Decorations) { Invoke("ShowDecoInventoryHelper", 1f); // NOTE: Special invoke delay needed for update position } HUDUIManager.Instance.ShowPanel(); // Show the hud because we are buying stuff }
/// <summary> /// Gets the type of the accessory node. /// Given a accessory(ID), check the xml to see which type it is. /// </summary> /// <returns>The accessory node type.</returns> /// <param name="accessoryID">Accessory ID.</param> public string GetAccessoryNodeType(string accessoryID) { AccessoryItem itemDeco = (AccessoryItem)DataLoaderItems.GetItem(accessoryID); return(itemDeco.AccessoryType.ToString()); }