public void createMinionAndTowerButtons() { var children = new System.Collections.Generic.List <GameObject>(); foreach (Transform child in createMinionTowerContainer.transform) { children.Add(child.gameObject); } children.ForEach(child => GameObject.Destroy(child)); int btnIndex = 0; button_CreateTower.SetActive(true); button_CreateMinion.SetActive(true); // sort minions order by cost List <Type> minionsSortedByCost = new List <Type>(); for (int j = 0; j < PlayerMe.availableMinionTypes.Count; j++) { if (TypeIdGeneratorGUI.minionGuiInst.ContainsKey(TypeIdGenerator.getMinionId(PlayerMe.availableMinionTypes[j]))) { minionsSortedByCost.Add(PlayerMe.availableMinionTypes[j]); } } minionsSortedByCost.Sort(delegate(Type t1, Type t2) { Minion m1 = TypeIdGenerator.getMinionClass(TypeIdGenerator.getMinionId(t1)); Minion m2 = TypeIdGenerator.getMinionClass(TypeIdGenerator.getMinionId(t2)); if (m1.getCost() < m2.getCost()) { return(-1); } else { return(1); } }); foreach (Type minionType in minionsSortedByCost) { int minionTypeId = TypeIdGenerator.getMinionId(minionType); if (TypeIdGeneratorGUI.minionGuiInst.ContainsKey(minionTypeId)) { GameObject button = (GameObject)GameObject.Instantiate(button_CreateMinion); button.transform.parent = createMinionTowerContainer.transform; button.transform.localScale = new Vector3(1, 1, 1); button.transform.localPosition = button_CreateMinion.transform.localPosition + new Vector3(50 * btnIndex, 0, 0); UIButtonMessage[] button_messages = button.GetComponents <UIButtonMessage>(); foreach (var btn_msg in button_messages) { btn_msg.parameter = minionTypeId.ToString(); } IMinionGUI minionGUI = TypeIdGeneratorGUI.minionGuiInst[minionTypeId]; minionGUI.drawCreateMinionButtonGUI(button); towerAndMinionButtons.Add(minionType, button); btnIndex++; } } // sort towers order by cost List <Type> towersSortedByCost = new List <Type>(); for (int j = 0; j < PlayerMe.availableTowerTypes.Count; j++) { if (TypeIdGeneratorGUI.towerGuiInst.ContainsKey(TypeIdGenerator.getTowerId(PlayerMe.availableTowerTypes[j]))) { towersSortedByCost.Add(PlayerMe.availableTowerTypes[j]); } } towersSortedByCost.Sort(delegate(Type t1, Type t2) { Tower m1 = TypeIdGenerator.getTowerClass(TypeIdGenerator.getTowerId(t1)); Tower m2 = TypeIdGenerator.getTowerClass(TypeIdGenerator.getTowerId(t2)); if (m1.getCost() < m2.getCost()) { return(-1); } else { return(1); } }); btnIndex = 0; foreach (Type towerType in towersSortedByCost) { int towerTypeId = TypeIdGenerator.getTowerId(towerType); if (TypeIdGeneratorGUI.towerGuiInst.ContainsKey(towerTypeId)) { GameObject button = (GameObject)GameObject.Instantiate(button_CreateTower); button.transform.parent = createMinionTowerContainer.transform; button.transform.localScale = new Vector3(1, 1, 1); button.transform.localPosition = button_CreateTower.transform.localPosition + new Vector3(50 * btnIndex, 0, 0); UIButtonMessage[] button_messages = button.GetComponents <UIButtonMessage>(); foreach (var btn_msg in button_messages) { btn_msg.parameter = towerTypeId.ToString(); } ITowerGUI towerGUI = TypeIdGeneratorGUI.towerGuiInst[towerTypeId]; towerGUI.drawCreateTowerButtonGUI(button); towerAndMinionButtons.Add(towerType, button); btnIndex++; } } button_CreateTower.SetActive(false); button_CreateMinion.SetActive(false); }
public virtual void drawInfoPanelGUI() { UIControllerGame controller = UIControllerGame.getInstance(); Tower towerTmp; if (this.tower == null) //gercek bir kule degil demek. ikonlari gostermek icin vs. tutulan dummy kule demek. { towerTmp = TypeIdGenerator.getTowerInsts(TypeIdGenerator.getTowerId(this.towerType)); } else { towerTmp = this.tower; } controller.label_TowerCost.text = towerTmp.getCost().ToString(); controller.label_TowerTitle.text = towerTmp.getName(); controller.label_TowerDescription.text = getInfo(); controller.label_TowerAttackCD.text = towerTmp.getAttackCooldown().ToString(); controller.label_TowerRange.text = (towerTmp.getRange() * 100).ToString(); controller.sprite_TowerIcon.mainTexture = childStaticTowerIcon; //remove all upgrade buttons remaining from previous var children = new List <GameObject>(); foreach (Transform child in controller.panel_UpgradeTowerContainer.transform) { children.Add(child.gameObject); } children.ForEach(child => GameObject.Destroy(child)); // eger bu cizim sadece bilgi gostermek icinse veya bu kule sana aitse upgrade'leri ekle if (this.tower == null || this.tower.board == PlayerMe.self.board) { var i = 0; foreach (TowerNode node in TypeIdGenerator.getTowerNodeInsts(towerType).children) { if (UserMe.unlockedTowers[TypeIdGenerator.getTowerId(node.towerType)]) { Tower child = TypeIdGenerator.getTowerInsts(TypeIdGenerator.getTowerId(node.towerType)); ITowerGUI childGUI = TypeIdGeneratorGUI.towerGuiInst[TypeIdGenerator.getTowerId(node.towerType)]; GameObject button = (GameObject)GameObject.Instantiate(controller.button_UpgradeTowerSample); button.transform.parent = controller.panel_UpgradeTowerContainer.transform; button.transform.localScale = new Vector3(1, 1, 1); button.transform.localPosition = controller.button_UpgradeTowerSample.transform.localPosition + new Vector3(60 * i, 0, 0); button.GetComponentsInChildren <UIButtonMessage>(true)[0].parameter = TypeIdGenerator.getTowerId(towerType).ToString() + " " + TypeIdGenerator.getTowerId(node.towerType).ToString(); button.GetComponentsInChildren <UILabel>(true)[0].text = child.getCost().ToString(); button.GetComponentsInChildren <Tooltiper>(true)[0].text = childGUI.getUpgradeInfo(); childGUI.drawCreateTowerButtonGUI(button); if (child.getCost() > PlayerMe.cash) { button.GetComponentsInChildren <UISlicedSprite>(true)[0].color = Color.red; } button.SetActive(true); i++; } } } controller.panel_TowerInfo.SetActive(true); }