public void upgradeMinion(Type oldMinionType, Type upgradedMinionType) { GameObject button = uiControllerGame.towerAndMinionButtons[oldMinionType]; int minionId = TypeIdGenerator.getMinionId(upgradedMinionType); IMinionGUI minionGUI = TypeIdGeneratorGUI.minionGuiInst[minionId]; UIButtonMessage[] button_messages = button.GetComponents <UIButtonMessage>(); foreach (var btn_msg in button_messages) { btn_msg.parameter = minionId.ToString(); } minionGUI.drawCreateMinionButtonGUI(button); uiControllerGame.towerAndMinionButtons.Remove(oldMinionType); uiControllerGame.towerAndMinionButtons.Add(upgradedMinionType, button); minionGUI.drawInfoPanelGUI(); }
public virtual void drawInfoPanelGUI() { UIControllerGame controller = UIControllerGame.getInstance(); Minion minion; if (this.minion == null) { minion = TypeIdGenerator.getMinionInsts(TypeIdGenerator.getMinionId(this.minionType)); } else { minion = this.minion; } controller.label_MinionCost.text = minion.getCost().ToString(); controller.label_MinionFireRes.text = "-"; controller.label_MinionPhysRes.text = "-"; controller.label_MinionPoisonRes.text = "-"; controller.label_MinionIncome.text = minion.getIncome().ToString(); controller.label_MinionReward.text = minion.getKillGold().ToString(); controller.label_MinionHealth.text = minion.stats.healthTotal.ToString(); controller.label_MinionMS.text = minion.stats.baseMovementSpeed.ToString(); controller.label_MinionTitle.text = minion.getName(); controller.label_MinionDescription.text = getInfo(); controller.sprite_MinionIcon.mainTexture = childStaticMinionIcon; //remove all upgrade buttons remaining from previous var children = new List <GameObject>(); foreach (Transform child in controller.panel_UpgradeMinionContainer.transform) { children.Add(child.gameObject); } children.ForEach(child => GameObject.Destroy(child)); // eger bu cizim sadece bilgi gostermek icinse veya bu minion sana aitse upgrade'leri ekle if (this.minion == null) { var i = 0; foreach (MinionNode node in TypeIdGenerator.getMinionNodeInsts(minionType).children) { if (UserMe.unlockedMinions[TypeIdGenerator.getMinionId(node.minionType)]) { Minion child = TypeIdGenerator.getMinionInsts(TypeIdGenerator.getMinionId(node.minionType)); IMinionGUI childGUI = TypeIdGeneratorGUI.minionGuiInst[TypeIdGenerator.getMinionId(node.minionType)]; GameObject button = (GameObject)GameObject.Instantiate(controller.button_UpgradeMinionSample); button.transform.parent = controller.panel_UpgradeMinionContainer.transform; button.transform.localScale = new Vector3(1, 1, 1); button.transform.localPosition = controller.button_UpgradeMinionSample.transform.localPosition + new Vector3(60 * i, 0, 0); button.GetComponentsInChildren <UILabel>(true)[0].text = child.getUpgradeCost().ToString(); button.GetComponentsInChildren <Tooltiper>(true)[0].text = childGUI.getUpgradeInfo(); childGUI.drawCreateMinionButtonGUI(button); UIButtonMessage msg = button.GetComponentsInChildren <UIButtonMessage>(true)[0]; if (child.getCost() > PlayerMe.cash) { button.GetComponentsInChildren <UISlicedSprite>(true)[0].color = Color.red; button.GetComponentsInChildren <UIButtonColor>(true)[0].enabled = false; msg.enabled = false; } else { msg.parameter = TypeIdGenerator.getMinionId(minionType).ToString() + " " + TypeIdGenerator.getMinionId(node.minionType).ToString(); } button.SetActive(true); i++; } } } controller.panel_MinionInfo.SetActive(true); }
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); }