public void TryAddContainer(DecorationTypes decorationType) { if (inventory.Decorations.ContainsPocket(decorationType)) { TabItem tabItem = new TabItem(); tabItem.Tag = decorationType; if (previousPocket == decorationType) { previousPocketIndex = tabControlPockets.Items.Count; } Image headerImage = new Image(); headerImage.SnapsToDevicePixels = true; headerImage.UseLayoutRounding = true; headerImage.Stretch = Stretch.None; headerImage.Source = ResourceDatabase.GetImageFromName(decorationType.ToString() + "Tab"); tabItem.Header = headerImage; DecorationViewerTab inventoryTab = new DecorationViewerTab(); inventoryTab.Width = Double.NaN; inventoryTab.Height = Double.NaN; tabItem.Content = inventoryTab; tabControlPockets.Items.Add(tabItem); inventoryTab.LoadPocket(inventory.Decorations[decorationType]); tabs.Add(decorationType, inventoryTab); if (currentPocket == DecorationTypes.Unknown) { currentPocket = decorationType; } } }
public bool IsDecorationInUse(int index, DecorationTypes decorationType) { byte id = pockets[decorationType][index].ID; int idsBeforeIndex = 0; for (int i = 0; i < index; i++) { if (pockets[decorationType][i].ID == id) { idsBeforeIndex++; } } int idsInUse = 0; for (int i = 0; secretBaseDecorations != null && i < secretBaseDecorations.Count; i++) { if (secretBaseDecorations[i].ID == id) { idsInUse++; } } for (int i = 0; bedroomDecorations != null && i < bedroomDecorations.Count; i++) { if (bedroomDecorations[i].ID == id) { idsInUse++; } } return(idsInUse > idsBeforeIndex); }
public DecorationPocket(DecorationInventory inventory, DecorationTypes pocketType, uint pocketSize, uint maxStackSize) { this.inventory = inventory; this.pocketType = pocketType; this.pocketSize = pocketSize; this.maxStackSize = maxStackSize; this.decorations = new List<Decoration>(); this.listViewItems = new ObservableCollection<ListViewItem>(); }
public static string GetDecorationContainerName(DecorationTypes decorationType) { if (decorationContainerNamesMap.ContainsKey(decorationType)) { return(decorationContainerNamesMap[decorationType]); } return("Unknown"); }
public DecorationPocket this[DecorationTypes pocketType] { get { if (pockets.ContainsKey(pocketType)) { return(pockets[pocketType]); } return(null); } }
public void GotoDecoration(DecorationTypes pocket, byte decorationID) { int index = 0; foreach (object item in tabControlPockets.Items) { if (((TabItem)item).Content == tabs[pocket]) break; index++; } Dispatcher.BeginInvoke((Action)(() => tabControlPockets.SelectedIndex = index)); tabs[pocket].GotoDecoration(decorationID); }
private void AddDecorationContainer(DecorationTypes pocketType, int index, uint containerSize) { parent.Inventory.Decorations.AddPocket(pocketType, containerSize, 1); for (int i = 0; i < (int)parent.Inventory.Decorations[pocketType].TotalSlots; i++) { byte id = raw[index + i]; if (id != 0) { parent.Inventory.Decorations[pocketType].AddDecoration(id, 1); } } }
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 LoadInventory(Inventory inventory) { foreach (KeyValuePair <DecorationTypes, DecorationViewerTab> pair in tabs) { pair.Value.UnloadPocket(); } this.previousPocketIndex = tabControlPockets.SelectedIndex; this.tabs.Clear(); this.tabControlPockets.Items.Clear(); this.inventory = inventory; this.previousPocket = currentPocket; this.currentPocket = DecorationTypes.Unknown; if (inventory == null) { return; } TryAddContainer(DecorationTypes.Desk); TryAddContainer(DecorationTypes.Chair); TryAddContainer(DecorationTypes.Plant); TryAddContainer(DecorationTypes.Ornament); TryAddContainer(DecorationTypes.Mat); TryAddContainer(DecorationTypes.Poster); TryAddContainer(DecorationTypes.Doll); TryAddContainer(DecorationTypes.Cushion); this.currentPocket = (DecorationTypes)(tabControlPockets.Items[0] as TabItem).Tag; if (previousPocketIndex != -1) { Dispatcher.BeginInvoke((Action)(() => tabControlPockets.SelectedIndex = previousPocketIndex)); this.currentPocket = previousPocket; } /*secretBaseManager = new GameSecretBaseManager(); * TabItem secretBasesTab = new TabItem(); * secretBasesTab.Content = secretBaseManager; * TabItem tabItem = new TabItem(); * Image headerImage = new Image(); * headerImage.SnapsToDevicePixels = true; * headerImage.UseLayoutRounding = true; * headerImage.Stretch = Stretch.None; * headerImage.Source = ResourceDatabase.GetImageFromName("SecretBaseTab"); * * tabItem.Header = headerImage; * secretBaseManager = new GameSecretBaseManager(); * secretBaseManager.Width = Double.NaN; * secretBaseManager.Height = Double.NaN; * tabItem.Content = secretBaseManager; * tabControlPockets.Items.Add(tabItem); * secretBaseManager.LoadGame(inventory.GameSave);*/ }
private void LoadDecorationPocket(DecorationTypes pocketType, byte[] data) { DecorationPocket pocket = inventory.Decorations[pocketType]; uint count = LittleEndian.ToUInt32(data, 0); for (int i = 0; i < (int)count; i++) { pocket.AddDecoration( (byte)LittleEndian.ToUInt16(data, 4 + i * 6), LittleEndian.ToUInt32(data, 4 + i * 6 + 2) ); } }
public DecorationData(DataRow row) { this.id = (byte)(long)row["ID"]; this.name = row["Name"] as string; this.description = row["Description"] as string; this.decorationType = DecorationData.GetDecorationTypeFromString(row["Type"] as string); this.price = (uint)(long)row["Price"]; this.coinsPrice = (uint)(long)row["Coins"]; this.bpPrice = (uint)(long)row["BP"]; this.sootPrice = (uint)(long)row["Soot"]; this.sale = (bool)row["Sale"]; CompileTypeData(row["DataType"] as string); }
private void OnTabSelected(object sender, SelectionChangedEventArgs e) { if (tabControlPockets.SelectedIndex != -1) { if ((tabControlPockets.SelectedItem as TabItem).Tag is DecorationTypes) { currentPocket = (DecorationTypes)(tabControlPockets.SelectedItem as TabItem).Tag; } else { currentPocket = DecorationTypes.Unknown; } } }
public SecretBaseEditor() { InitializeComponent(); gameIndex = -1; this.decorationImages = new List <Image>(); imagePlace.Visibility = Visibility.Hidden; rectPlaceMask.Visibility = Visibility.Hidden; for (DecorationTypes i = DecorationTypes.Desk; i <= DecorationTypes.Cushion; i++) { comboBoxPockets.Items.Add(ItemDatabase.GetDecorationContainerName(i)); } }
private void SaveDecorationContainer(DecorationTypes pocketType, int index) { for (int i = 0; i < (int)parent.Inventory.Decorations[pocketType].TotalSlots; i++) { if (i < (int)parent.Inventory.Decorations[pocketType].SlotsUsed) { Decoration decoration = parent.Inventory.Decorations[pocketType][i]; raw[index + i] = decoration.ID; } else { raw[index + i] = 0; } } }
public void PutAwayDecoration(int index, DecorationTypes decorationType) { GameSave.IsChanged = true; int usageIndex = GetIndexOfDecorationInUse(index, decorationType); DecorationUsages usage = GetDecorationUsage(index, decorationType); if (usage == DecorationUsages.SecretBase) { PutAwayDecorationInSecretBaseAt(usageIndex); } else { PutAwayDecorationInBedroomAt(usageIndex); } }
public static DecorationData GetDecorationTypeAt(int index, DecorationTypes decorationType) { for (int i = 1; i < gen3ItemList.Count; i++) { if (decorationList[i].DecorationType == decorationType) { if (index == 0) { return(decorationList[i]); } index--; } } return(decorationList[0]); }
public void GotoDecoration(DecorationTypes pocket, byte decorationID) { int index = 0; foreach (object item in tabControlPockets.Items) { if (((TabItem)item).Content == tabs[pocket]) { break; } index++; } Dispatcher.BeginInvoke((Action)(() => tabControlPockets.SelectedIndex = index)); tabs[pocket].GotoDecoration(decorationID); }
private byte[] SaveDecorationPocket(DecorationTypes pocketType) { DecorationPocket pocket = inventory.Decorations[pocketType]; List <byte> data = new List <byte>(); data.AddRange(BitConverter.GetBytes(pocket.SlotsUsed)); for (int i = 0; i < pocket.SlotsUsed; i++) { data.AddRange(BitConverter.GetBytes((ushort)pocket[i].ID)); data.AddRange(BitConverter.GetBytes(pocket[i].Count)); } return(data.ToArray()); }
public void LoadInventory(Inventory inventory) { foreach (KeyValuePair<DecorationTypes, DecorationViewerTab> pair in tabs) { pair.Value.UnloadPocket(); } this.previousPocketIndex = tabControlPockets.SelectedIndex; this.tabs.Clear(); this.tabControlPockets.Items.Clear(); this.inventory = inventory; this.previousPocket = currentPocket; this.currentPocket = DecorationTypes.Unknown; if (inventory == null) return; TryAddContainer(DecorationTypes.Desk); TryAddContainer(DecorationTypes.Chair); TryAddContainer(DecorationTypes.Plant); TryAddContainer(DecorationTypes.Ornament); TryAddContainer(DecorationTypes.Mat); TryAddContainer(DecorationTypes.Poster); TryAddContainer(DecorationTypes.Doll); TryAddContainer(DecorationTypes.Cushion); this.currentPocket = (DecorationTypes)(tabControlPockets.Items[0] as TabItem).Tag; if (previousPocketIndex != -1) { Dispatcher.BeginInvoke((Action)(() => tabControlPockets.SelectedIndex = previousPocketIndex)); this.currentPocket = previousPocket; } /*secretBaseManager = new GameSecretBaseManager(); TabItem secretBasesTab = new TabItem(); secretBasesTab.Content = secretBaseManager; TabItem tabItem = new TabItem(); Image headerImage = new Image(); headerImage.SnapsToDevicePixels = true; headerImage.UseLayoutRounding = true; headerImage.Stretch = Stretch.None; headerImage.Source = ResourceDatabase.GetImageFromName("SecretBaseTab"); tabItem.Header = headerImage; secretBaseManager = new GameSecretBaseManager(); secretBaseManager.Width = Double.NaN; secretBaseManager.Height = Double.NaN; tabItem.Content = secretBaseManager; tabControlPockets.Items.Add(tabItem); secretBaseManager.LoadGame(inventory.GameSave);*/ }
public DecorationItem(string id, ItemType type, Hashtable hashItemData) : base(id, type, hashItemData) { // get the type of this decoration string strType = XMLUtils.GetString(hashItemData["DecorationType"] as IXMLNode); eType = (DecorationTypes)System.Enum.Parse(typeof(DecorationTypes), strType); if (hashItemData.Contains("PrefabName")) { prefabName = XMLUtils.GetString(hashItemData["PrefabName"] as IXMLNode); } if (hashItemData.Contains("MaterialName")) { materialName = XMLUtils.GetString(hashItemData["MaterialName"] as IXMLNode); } if (hashItemData.Contains("InSeason")) { inSeason = XMLUtils.GetBool(hashItemData["InSeason"] as IXMLNode); } }
public DecorationUsages GetDecorationUsage(int index, DecorationTypes decorationType) { byte id = pockets[decorationType][index].ID; int idsBeforeIndex = 0; for (int i = 0; i < index; i++) { if (pockets[decorationType][i].ID == id) { idsBeforeIndex++; } } for (int i = 0; secretBaseDecorations != null && i < secretBaseDecorations.Count; i++) { if (secretBaseDecorations[i].ID == id) { if (idsBeforeIndex == 0) { return(DecorationUsages.SecretBase); } idsBeforeIndex--; } } for (int i = 0; bedroomDecorations != null && i < bedroomDecorations.Count; i++) { if (bedroomDecorations[i].ID == id) { if (idsBeforeIndex == 0) { return(DecorationUsages.Bedroom); } idsBeforeIndex--; } } return(DecorationUsages.Unused); }
public bool ContainsPocket(DecorationTypes pocketType) { return pockets.ContainsKey(pocketType); }
public void AddPocket(DecorationTypes pocketType, uint pocketSize, uint maxStackSize) { pockets.Add(pocketType, new DecorationPocket(this, pocketType, pocketSize, maxStackSize)); }
public DecorationPocket this[DecorationTypes pocketType] { get { if (pockets.ContainsKey(pocketType)) return pockets[pocketType]; return null; } }
public void GotoDecoration(int gameIndex, DecorationTypes pocket, byte decorationID) { if (this.gameIndex != gameIndex) LoadGame(gameIndex); Dispatcher.BeginInvoke((Action)(() => tabControl.SelectedIndex = 3)); decorationInventoryViewer.GotoDecoration(pocket, decorationID); }
public void PutAwayDecoration(int index, DecorationTypes decorationType) { GameSave.IsChanged = true; int usageIndex = GetIndexOfDecorationInUse(index, decorationType); DecorationUsages usage = GetDecorationUsage(index, decorationType); if (usage == DecorationUsages.SecretBase) PutAwayDecorationInSecretBaseAt(usageIndex); else PutAwayDecorationInBedroomAt(usageIndex); }
public ItemPocketGameTag(int gameIndex, DecorationTypes decorationType) { this.GameIndex = gameIndex; this.DecorationType = decorationType; this.ItemType = ItemTypes.Unknown; }
private byte[] SaveDecorationPocket(DecorationTypes pocketType) { DecorationPocket pocket = inventory.Decorations[pocketType]; List<byte> data = new List<byte>(); data.AddRange(BitConverter.GetBytes(pocket.SlotsUsed)); for (int i = 0; i < pocket.SlotsUsed; i++) { data.AddRange(BitConverter.GetBytes((ushort)pocket[i].ID)); data.AddRange(BitConverter.GetBytes(pocket[i].Count)); } return data.ToArray(); }
public void TryAddContainer(DecorationTypes decorationType) { if (inventory.Decorations.ContainsPocket(decorationType)) { TabItem tabItem = new TabItem(); tabItem.Tag = decorationType; if (previousPocket == decorationType) previousPocketIndex = tabControlPockets.Items.Count; Image headerImage = new Image(); headerImage.SnapsToDevicePixels = true; headerImage.UseLayoutRounding = true; headerImage.Stretch = Stretch.None; headerImage.Source = ResourceDatabase.GetImageFromName(decorationType.ToString() + "Tab"); tabItem.Header = headerImage; DecorationViewerTab inventoryTab = new DecorationViewerTab(); inventoryTab.Width = Double.NaN; inventoryTab.Height = Double.NaN; tabItem.Content = inventoryTab; tabControlPockets.Items.Add(tabItem); inventoryTab.LoadPocket(inventory.Decorations[decorationType]); tabs.Add(decorationType, inventoryTab); if (currentPocket == DecorationTypes.Unknown) currentPocket = decorationType; } }
private void OnTabSelected(object sender, SelectionChangedEventArgs e) { if (tabControlPockets.SelectedIndex != -1) { if ((tabControlPockets.SelectedItem as TabItem).Tag is DecorationTypes) currentPocket = (DecorationTypes)(tabControlPockets.SelectedItem as TabItem).Tag; else currentPocket = DecorationTypes.Unknown; } }
private void AddDecorationContainer(DecorationTypes pocketType, int index, uint containerSize) { parent.Inventory.Decorations.AddPocket(pocketType, containerSize, 1); for (int i = 0; i < (int)parent.Inventory.Decorations[pocketType].TotalSlots; i++) { byte id = raw[index + i]; if (id != 0) parent.Inventory.Decorations[pocketType].AddDecoration(id, 1); } }
public DecorationUsages GetDecorationUsage(int index, DecorationTypes decorationType) { byte id = pockets[decorationType][index].ID; int idsBeforeIndex = 0; for (int i = 0; i < index; i++) { if (pockets[decorationType][i].ID == id) idsBeforeIndex++; } for (int i = 0; secretBaseDecorations != null && i < secretBaseDecorations.Count; i++) { if (secretBaseDecorations[i].ID == id) { if (idsBeforeIndex == 0) return DecorationUsages.SecretBase; idsBeforeIndex--; } } for (int i = 0; bedroomDecorations != null && i < bedroomDecorations.Count; i++) { if (bedroomDecorations[i].ID == id) { if (idsBeforeIndex == 0) return DecorationUsages.Bedroom; idsBeforeIndex--; } } return DecorationUsages.Unused; }
public bool ContainsPocket(DecorationTypes pocketType) { return(pockets.ContainsKey(pocketType)); }
public bool IsDecorationInUse(int index, DecorationTypes decorationType) { byte id = pockets[decorationType][index].ID; int idsBeforeIndex = 0; for (int i = 0; i < index; i++) { if (pockets[decorationType][i].ID == id) idsBeforeIndex++; } int idsInUse = 0; for (int i = 0; secretBaseDecorations != null && i < secretBaseDecorations.Count; i++) { if (secretBaseDecorations[i].ID == id) idsInUse++; } for (int i = 0; bedroomDecorations != null && i < bedroomDecorations.Count; i++) { if (bedroomDecorations[i].ID == id) idsInUse++; } return idsInUse > idsBeforeIndex; }
//---------------------------------------------------- // CreateSubCategoryItemsTab() // Create items for sub category //---------------------------------------------------- public void CreateSubCategoryItemsTab(string tabName, StoreShortcutType shortcutType = StoreShortcutType.None) { // Debug.Log("OPENING STORE MODE " + shortcutType.ToString()); //Destroy existing items first DestroyGrid(); //Reset clip range so scrolling will start from beginning again ResetUIPanelClipRange(); AudioManager.Instance.PlayClip("shopChangeTab"); int itemCount = 0; //base on the tab name and the page name, create proper set of item in the store if (currentPage == "Food") { //No sub category so retrieve a list of all food List <Item> foodList = ItemManager.Instance.FoodList; foreach (Item itemData in foodList) { if (!itemData.IsSecretItem) { CreateStoreItem(grid.gameObject, itemStorePrefabStats, itemData); itemCount++; } } } else if (currentPage == "Items") { //No sub category so retrieve a list of all item List <Item> usableList = ItemManager.Instance.UsableList; foreach (Item itemData in usableList) { if (!itemData.IsSecretItem) { // Need emergency inhaler shortcut, only show emergency inhaler if (shortcutType == StoreShortcutType.SickNotification || shortcutType == StoreShortcutType.NeedEmergencyInhalerPetSpeech) { if (itemData.ID == "Usable0") { itemCount++; CreateStoreItem(grid.gameObject, itemStorePrefabStats, itemData); break; } continue; } // Default case, show everything else { CreateStoreItem(grid.gameObject, itemStorePrefabStats, itemData); itemCount++; } } } } else if (currentPage == "Decorations") { //Retrieve decoration items base on the tab name (sub category) Dictionary <DecorationTypes, List <DecorationItem> > decoDict = ItemManager.Instance.DecorationSubCatList; DecorationTypes decoType = (DecorationTypes)Enum.Parse(typeof(DecorationTypes), tabName); if (decoDict.ContainsKey(decoType)) { List <DecorationItem> decoList = decoDict[decoType]; foreach (DecorationItem decoItemData in decoList) { if (!decoItemData.IsSecretItem) { CreateStoreItem(grid.gameObject, itemStorePrefab, (Item)decoItemData); itemCount++; } } } } // Adjust the grid width based on the width of the cell and spacing itemCount = (itemCount % 2 == 1) ? itemCount + 1 : itemCount; // Dividing by 2 later, so make sure even float gridWidth = itemCount * 0.5f * (grid.cellSize.x + grid.spacing.x); grid.GetComponent <RectTransform>().sizeDelta = new Vector2(gridWidth, grid.GetComponent <RectTransform>().sizeDelta.y); }
public static Sprite GetDecoIconSprite(DecorationTypes decoType) { return(Resources.Load <Sprite>("iconDeco" + decoType.ToString())); }