public void UpdateConsumePanel() { if (characterReader == null) { characterReader = FindObjectOfType <GameManager>().characterReader; } if (itemManager == null) { itemManager = FindObjectOfType <GameManager>().itemManager; } monster = upgradePanel.currentMonster; if (monster.GetLevel() >= Pawn.MaxLevel) { for (int i = 0; i < content.childCount; i++) { Transform child = content.GetChild(i); GameObject.Destroy(child.gameObject); } return; } int unlocklevel = Mathf.CeilToInt((float)((Monster)monster).monsterType / 3); items = new List <Vector2>(); items = characterReader.GetCharacterUpgrade(unlocklevel, monster.Name, monster.GetLevel() + 1); itemcount = items.Count; if (content.childCount > itemcount) { for (int i = content.childCount - 1; i >= itemcount; i--) { Transform child = content.GetChild(i); GameObject.DestroyImmediate(child.gameObject); } } for (int i = 0; i < itemcount; i++) { Upgrade_Item item; if (content.childCount <= i) { item = GenItem(i); } else { item = content.GetChild(i).GetComponent <Upgrade_Item>(); } item.type = (ItemType)items[i].x; if (itemManager.ItemsOwn.ContainsKey(item.type)) { item.num = itemManager.ItemsOwn[item.type]; } else { item.num = 0; } item.numneed = (int)items[i].y; UpdateItem(item, i); } content.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemcount * width * UnityEngine.Screen.height); }
public void UpdateSpawnPanel() { ClearSpawnPanel(); if (monsterPallete.currentType == MonsterType.NUM) { return; } int unlocklevel = Mathf.CeilToInt((float)monsterPallete.currentType / 3); items = characterReader.GetCharacterUpgrade(unlocklevel, monsterPallete.currentType.ToString(), 1); // items to spawn monster at level 1 itemcount = items.Count; for (int i = 0; i < itemcount; i++) { Upgrade_Item item = GenItem(i); item.type = (ItemType)items[i].x; if (monsterPallete.gameManager.itemManager.ItemsOwn.ContainsKey((ItemType)items[i].x)) { item.num = monsterPallete.gameManager.itemManager.ItemsOwn[(ItemType)items[i].x]; } else { item.num = 0; } item.numneed = (int)items[i].y; UpdateItem(item, i); item.UpdateItemDisplay(); } if (IsSpawnOK()) { monsterPallete.monsterSpawnButton.GetComponent <Button>().interactable = true; } else { monsterPallete.monsterSpawnButton.GetComponent <Button>().interactable = false; } content.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemcount * width * UnityEngine.Screen.height); }