protected virtual IActuatorX CreateWallDecoration(int currentIdentifer, List <IGrabableItem> items) { var descriptor = builder.CurrentMap.WallDecorations[currentIdentifer]; var texture = builder.WallTextures[currentIdentifer]; switch (descriptor.Type) { case GraphicsItemState.GraphicOnly: var decoration = new DecorationItem(); decoration.Renderer = builder.Factories.RenderersSource.GetRandomDecorationRenderer(decoration, texture); return(decoration); case GraphicsItemState.Alcove: var alcove = new Alcove(items); items.Clear(); alcove.Renderer = builder.Factories.RenderersSource.GetAlcoveDecorationRenderer(alcove, texture); return(alcove); case GraphicsItemState.ViAltair: var altair = new ViAltairAlcove(items); items.Clear(); altair.Renderer = builder.Factories.RenderersSource.GetAlcoveDecorationRenderer(altair, texture); return(altair); case GraphicsItemState.Fountain: var fountain = new Fountain(builder.Factories); fountain.Renderer = builder.Factories.RenderersSource.GetFountainDecoration(fountain, texture); return(fountain); default: throw new ArgumentOutOfRangeException(); } }
protected async Task SetupFloorInitializer(SensorInitializer <IActuatorX> initializer, ActuatorItemData data) { if (data.Decoration > 0) { var texture = builder.FloorTextures[data.Decoration - 1]; var decoration = new DecorationItem(); decoration.Renderer = builder.Factories.RenderersSource.GetRandomDecorationRenderer(decoration, texture); initializer.Graphics = decoration; } await SetupInitializer(initializer, data); }
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); }
public void SaveDecortaion(Vector2Int position, DecorationItem decorationItem) { // Need to make sure StartPosition is not the same foreach (var buildPos in BuildPositions) { if (buildPos.Equals(position)) { return; } } BuildPositions.Add(position); DecorationItems.Add(decorationItem); }
public void BuyButtonStateCheck() { //Check if wallpaper has already been bought. Disable the buy button if so if (itemData.Type == ItemType.Decorations) { DecorationItem decoItem = (DecorationItem)itemData; if (decoItem.DecorationType == DecorationTypes.Wallpaper) { if (InventoryManager.Instance.IsWallpaperBought(decoItem.ID)) { button.interactable = false; button.GetComponent <Image>().sprite = SpriteCacheManager.GetSprite("ButtonGray"); } } } }
//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 }
/// <summary> /// Gets the name of the deco item material. /// </summary> /// <returns>The deco item material name.</returns> /// <param name="itemID">Item ID.</param> public static string GetDecoItemMaterialName(string itemID) { DecorationItem item = (DecorationItem)GetItem(itemID); return(item.MaterialName); }
/// <summary> /// Gets the name of the deco item prefab. /// </summary> /// <returns>The deco item prefab name.</returns> /// <param name="itemID">Item ID.</param> public static string GetDecoItemPrefabName(string itemID) { DecorationItem item = (DecorationItem)GetItem(itemID); return(item.PrefabName); }
public static void SetupData() { allItems = new Dictionary <ItemType, Dictionary <string, Item> >(); //Load all item xml files UnityEngine.Object[] files = Resources.LoadAll("Items", typeof(TextAsset)); foreach (TextAsset file in files) { string xmlString = file.text; //Create XMLParser instance XMLParser xmlParser = new XMLParser(xmlString); //Call the parser to build the IXMLNode objects XMLElement xmlElement = xmlParser.Parse(); //Get item type ItemType itemType = (ItemType)Enum.Parse(typeof(ItemType), xmlElement.value); //Create dictionary to store data Dictionary <string, Item> categoryItem = new Dictionary <string, Item>(); //Go through all child node of xmlElement (the parent of the file) for (int i = 0; i < xmlElement.Children.Count; i++) { IXMLNode childNode = xmlElement.Children[i]; //Get id Hashtable hashAttr = XMLUtils.GetAttributes(childNode); string itemID = (string)hashAttr["ID"]; //Get Item properties from xml node Hashtable hashItemData = XMLUtils.GetChildren(childNode); Item item = null; switch (itemType) { case ItemType.Foods: item = new FoodItem(itemID, itemType, hashItemData); break; case ItemType.Usables: item = new UsableItem(itemID, itemType, hashItemData); break; case ItemType.Decorations: item = new DecorationItem(itemID, itemType, hashItemData); break; case ItemType.Accessories: item = new AccessoryItem(itemID, itemType, hashItemData); break; } if (!categoryItem.ContainsKey(itemID)) { categoryItem.Add(itemID, item); } else { Debug.LogError(itemID + " already in items dict"); } } //Store dictionary into all Items allItems.Add(itemType, categoryItem); } }
public void OnMinus(DecorationItem item) { decorationItems.Remove(item); RefreshList(); }
////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Raises the decoration picked up event. /// </summary> private void OnDecorationPickedUp(object sender, EventArgs args) { DecorationItem decoItem = (DecorationItem)InventoryTokenDragElement.itemBeingDragged.GetComponent <InventoryTokenDragElement>().InventoryData.ItemData; SetState(decoItem.DecorationType.ToString()); }