public static void make(string text, ScreenPosition position, float duration, float fontSize = 30.0f) { Debug.Log(UIControllerGame.getInstance().announcementSampleObject); UILabel gameObject = (UILabel)GameObject.Instantiate(UIControllerGame.getInstance().announcementSampleObject); gameObject.text = text; switch (position) { case ScreenPosition.MiddleBottom: gameObject.transform.parent = UIControllerGame.getInstance().panel_AnnouncementsMiddleBottom.transform; break; case ScreenPosition.MiddleCenter: gameObject.transform.parent = UIControllerGame.getInstance().panel_AnnouncementsMiddleCenter.transform; break; case ScreenPosition.MiddleTop: gameObject.transform.parent = UIControllerGame.getInstance().panel_AnnouncementsMiddleTop.transform; break; } gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localScale = new Vector3(fontSize, fontSize, 1); GameObject.Destroy(gameObject.gameObject, duration); }
// deselect functions private static void onTowerSlotDeselected() { if (!guiClicked) { selectedTowerType = null; UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); } }
private static void onTowerDeselected() { if (!guiClicked) { if (lastSelectedTower != null) { lastSelectedTower.onTowerUnselected(); } lastSelectedTower = null; UIControllerGame.getInstance().alwaysActiveInfoPanel = false; UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); } }
private static void onMinionDeselected() { if (!guiClicked) { if (lastSelectedMinion != null) { lastSelectedMinion.onMinionUnselected(); } lastSelectedMinion = null; if (!towerClicked) { UIControllerGame.getInstance().alwaysActiveInfoPanel = false; UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); } } }
private static void onMinionSelected(GameObject obje) { string objName = obje.name; string instanceIDstr = obje.name.Substring(2); int instanceID = System.Int32.Parse(instanceIDstr); Minion minion = Game.getMinionById(instanceID); if (lastSelectedMinion != null) { lastSelectedMinion.onMinionUnselected(); } lastSelectedMinion = (IMinionGUI)minion.tag; graphics.activateMinionInfo(lastSelectedMinion); lastSelectedMinion.onMinionSelected(); UIControllerGame.getInstance().alwaysActiveInfoPanel = true; }
public virtual void createTower(Tower t) { tower = t; t.tag = this; towerObject = (GameObject)GameObject.Instantiate(childStaticTowerObject); towerObject.name = "t_" + tower.board.instanceId + "_" + tower.indexOnBoard; towerObject.transform.position = tower.board.getTowerPosition(tower.indexOnBoard); rangeProjector = (Projector)GameObject.Instantiate(childStaticRangeProjector); rangeProjector.transform.parent = towerObject.transform; rangeProjector.transform.localPosition = new Vector3(0, 0.2f, 0); rangeProjector.orthographicSize = tower.stats.baseRange; rangeProjector.enabled = false; GameObject.Instantiate(UIControllerGame.getInstance().createTowerEffect, towerObject.transform.position, Quaternion.identity); soundPlayer = towerObject.AddComponent <AudioSource>(); soundPlayer.volume = 1; soundPlayer.PlayOneShot((AudioClip)Resources.Load("Sound/tower_build")); }
private static void onTowerSelected(GameObject obje) { string objName = obje.name; string boardStr = obje.name.Substring(2, objName.LastIndexOf("_") - 2); string indexStr = obje.name.Substring(objName.LastIndexOf("_") + 1); int boardId = System.Int32.Parse(boardStr); int indexOnBoard = System.Int32.Parse(indexStr); Board board = Game.getBoardById(boardId); Tower tower = board.towers[indexOnBoard]; // daha once bir kuleye tiklanmissa unselect'ini cagir. if (lastSelectedTower != null) { lastSelectedTower.onTowerUnselected(); } lastSelectedTower = (ITowerGUI)tower.tag; graphics.activateTowerInfo(lastSelectedTower); lastSelectedTower.onTowerSelected(); UIControllerGame.getInstance().alwaysActiveInfoPanel = true; }
private void enterState_Game() { foreach (Player player in Game.players) { Board board = player.board; IBoardGUI gui = (IBoardGUI)Activator.CreateInstance(Type.GetType("Assets.Scripts.GUI.Boards." + board.GetType().Name + "GUI, Assembly-CSharp")); gui.createBoard(board); } uiControllerGame = UIControllerGame.getInstance(); uiControllerGame.createMinionAndTowerButtons(); MouseHandler.initialize(this); // Game sinifindan bilgileri alarak oyun icin gerekli yuklemeleri ve atamalari yap. Announcement.make("Welcome to the Summoner's rift!", Announcement.ScreenPosition.MiddleTop, 2.0f); updateCashAndIncome(); loadGameFlag = true; StartCoroutine(sendLoadReadyMessage()); }
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 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); }