void PriceField(Rect rect, CustomizationItemData item) { var priceRect = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width - ImageSize, EditorGUIUtility.singleLineHeight); Undo.RecordObject(economyConfig, "EconomyConfig: change item price"); item.price = EditorGUI.IntField(priceRect, "Price:", item.price); }
bool TryBuyItem(CustomizationID id) { CustomizationItemData itemData = null; switch ((GameGroups.GameGroupGameType)GameGroups.GameCtrl.instance.SelectGameNumber) { case GameGroups.GameGroupGameType.Cat: if (economyConfig_cat == null) { return(false); } itemData = economyConfig_cat.GetItemData(id); break; case GameGroups.GameGroupGameType.Gun: if (economyConfig_gun == null) { return(false); } itemData = economyConfig_gun.GetItemData(id); break; case GameGroups.GameGroupGameType.Orbit: if (economyConfig_orbit == null) { return(false); } itemData = economyConfig_orbit.GetItemData(id); break; case GameGroups.GameGroupGameType.Slame: if (economyConfig_slame == null) { return(false); } itemData = economyConfig_slame.GetItemData(id); break; } if (itemData == null) { return(false); } var price = itemData.price; if (price == 0 || SoftCurrency >= price) { UnlockCustomizationItem(id); SoftCurrency -= price; return(true); } OnCustomizationUnlockFailed.Dispatch(id); return(false); }
void IdField(Rect idRect, CustomizationItemData item) { Undo.RecordObject(economyConfig, "EconomyConfig: change item id"); var newId = EditorGUI.TextField(idRect, "Id:", item.id); if (newId != item.id) { RenameItemInAssetConfig(item.id, newId); item.id = newId; } }
void ImageField(Rect rect, CustomizationItemData item) { var imageRect = new Rect(rect.x + (rect.width - ImageSize), rect.y, ImageSize, ImageSize); var assetItem = assetsConfig.itemsIcons.FirstOrDefault(x => ItemEquals(x, item.id)); if (assetItem != null) { Undo.RecordObject(assetsConfig, "EconomyAssetsConfig: record change sprite"); assetItem.icon = EditorGUI.ObjectField(imageRect, assetItem.icon, typeof(Sprite), false) as Sprite; } else if (GUI.Button(imageRect, "Add")) { assetsConfig.AddItemIcon(CategoryId, item.id); } }
void CleanAndValidateIcon(List <CustomizationItemAssetsData> redundantIcons, CustomizationCategoryData categoryData, CustomizationItemData item) { var machingIcons = redundantIcons.Where(x => HasSameId(x, categoryData.id, item.id)).ToList(); if (machingIcons.Count == 0) { economyAssetsConfig.AddItemIcon(categoryData.id, item.id); } else { foreach (var machingIcon in machingIcons) { redundantIcons.Remove(machingIcon); } } }