public void activateTowerInfoPanel(string towerTypeId) { if (!alwaysActiveInfoPanel) { alwaysActiveInfoPanel = false; panel_MinionInfo.SetActive(false); ITowerGUI towerGUI = TypeIdGeneratorGUI.towerGuiInst[Int32.Parse(towerTypeId)]; towerGUI.drawInfoPanelGUI(); } }
/* // bu fonksiyonu kullanmiyoruz. MouseHandler'i kullaniyoruz. private void ingameClickHandler() { if (Input.GetKeyDown(KeyCode.Mouse0) && GUIUtility.hotControl == 0) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; bool towerSlotClicked = false; bool towerClicked = false; bool minionClicked = false; if (Physics.Raycast(ray, out hitInfo, 1000.0f)) { GameObject obje = hitInfo.collider.gameObject; if (obje.name.StartsWith("towerSlot_")) { towerSlotClicked = true; int towerSlot = System.Int32.Parse(obje.name.Substring("towerSlot_".Length)) - 1; int boardId = System.Int32.Parse(obje.transform.parent.parent.parent.gameObject.name.Substring("board_".Length)); Board board = Game.getBoardById(boardId); if (board == PlayerMe.self.board) { if (board.towers[towerSlot] == null) { if (selectedTowerType != null) sendCreateTowerRequest(selectedTowerType, towerSlot); else { if (lastSelectedTower != null) { lastSelectedTower.onTowerUnselected(); UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); } lastSelectedTower = null; } } else { if (lastSelectedTower != null) lastSelectedTower.onTowerUnselected(); lastSelectedTower = (ITowerGUI)board.towers[towerSlot].tag; activateTowerInfo(lastSelectedTower); lastSelectedTower.onTowerSelected(); selectedTowerType = null; UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); } //((Assets.Scripts.GUI.Interfaces.IBoardGUI) board.tag).onMouseOverTower(towerSlot); } if (lastSelectedMinion != null) { lastSelectedMinion.onMinionUnselected(); UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); } lastSelectedMinion = null; } else if (obje.name.StartsWith("t_")) { minionClicked = true; try { 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; activateTowerInfo(lastSelectedTower); lastSelectedTower.onTowerSelected(); selectedTowerType = null; UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); } catch (UnityException e) { Debug.Log("Mouse Handler::objeNameStartsWith:t_ \t -inappropriate name: '" + obje.name +"'"); } if (lastSelectedMinion != null) { lastSelectedMinion.onMinionUnselected(); UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); } lastSelectedMinion = null; } else if (obje.name.StartsWith("m_")) { minionClicked = true; try { 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; activateMinionInfo(lastSelectedMinion); lastSelectedMinion.onMinionSelected(); } catch (UnityException e) { Debug.Log("Mouse Handler::objeNameStartsWith:m_"); } // Unselected tower if (lastSelectedTower != null) { lastSelectedTower.onTowerUnselected(); UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); } lastSelectedTower = null; selectedTowerType = null; UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); } else { Ray rayNGUI = GameObject.Find ("NGUICamera").camera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfoNGUI; // eger ekranda bos bir yere tiklamissam if (!Physics.Raycast(rayNGUI, out hitInfoNGUI, 1000.0f)) { // 9: GUI Layer // Unselected tower if (lastSelectedTower != null) { lastSelectedTower.onTowerUnselected(); UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); } lastSelectedTower = null; selectedTowerType = null; UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); if(lastSelectedMinion != null) { lastSelectedMinion.onMinionUnselected(); UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); } lastSelectedMinion = null; } } } else // collider'i olmayan bir seye tiklamissak ya da hicbir seye tiklamamissak { if (lastSelectedTower != null) { lastSelectedTower.onTowerUnselected(); UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); } lastSelectedTower = null; selectedTowerType = null; UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); if (lastSelectedMinion != null) { lastSelectedMinion.onMinionUnselected(); UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); } lastSelectedMinion = null; } } } */ public void activateTowerInfo(ITowerGUI towerGUI) { uiControllerGame.alwaysActiveInfoPanel = true; uiControllerGame.panel_MinionInfo.SetActive(false); towerGUI.drawInfoPanelGUI(); }
/* * // bu fonksiyonu kullanmiyoruz. MouseHandler'i kullaniyoruz. * private void ingameClickHandler() * { * if (Input.GetKeyDown(KeyCode.Mouse0) && GUIUtility.hotControl == 0) * { * Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); * RaycastHit hitInfo; * bool towerSlotClicked = false; * bool towerClicked = false; * bool minionClicked = false; * * if (Physics.Raycast(ray, out hitInfo, 1000.0f)) * { * GameObject obje = hitInfo.collider.gameObject; * * if (obje.name.StartsWith("towerSlot_")) * { * towerSlotClicked = true; * * int towerSlot = System.Int32.Parse(obje.name.Substring("towerSlot_".Length)) - 1; * int boardId = System.Int32.Parse(obje.transform.parent.parent.parent.gameObject.name.Substring("board_".Length)); * * Board board = Game.getBoardById(boardId); * if (board == PlayerMe.self.board) * { * if (board.towers[towerSlot] == null) * { * if (selectedTowerType != null) * sendCreateTowerRequest(selectedTowerType, towerSlot); * else * { * if (lastSelectedTower != null) * { * lastSelectedTower.onTowerUnselected(); * UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); * } * lastSelectedTower = null; * } * } * else * { * if (lastSelectedTower != null) * lastSelectedTower.onTowerUnselected(); * * lastSelectedTower = (ITowerGUI)board.towers[towerSlot].tag; * activateTowerInfo(lastSelectedTower); * * lastSelectedTower.onTowerSelected(); * * selectedTowerType = null; * UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); * } * //((Assets.Scripts.GUI.Interfaces.IBoardGUI) board.tag).onMouseOverTower(towerSlot); * } * * if (lastSelectedMinion != null) * { * lastSelectedMinion.onMinionUnselected(); * UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); * } * lastSelectedMinion = null; * } * else if (obje.name.StartsWith("t_")) * { * minionClicked = true; * * try * { * 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; * activateTowerInfo(lastSelectedTower); * * lastSelectedTower.onTowerSelected(); * * selectedTowerType = null; * UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); * } * catch (UnityException e) * { * Debug.Log("Mouse Handler::objeNameStartsWith:t_ \t -inappropriate name: '" + obje.name +"'"); * } * if (lastSelectedMinion != null) * { * lastSelectedMinion.onMinionUnselected(); * UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); * } * lastSelectedMinion = null; * } * else if (obje.name.StartsWith("m_")) * { * minionClicked = true; * * try * { * 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; * * activateMinionInfo(lastSelectedMinion); * * lastSelectedMinion.onMinionSelected(); * * } * catch (UnityException e) * { * Debug.Log("Mouse Handler::objeNameStartsWith:m_"); * } * * // Unselected tower * if (lastSelectedTower != null) * { * lastSelectedTower.onTowerUnselected(); * UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); * } * lastSelectedTower = null; * * selectedTowerType = null; * UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); * } * else * { * Ray rayNGUI = GameObject.Find ("NGUICamera").camera.ScreenPointToRay(Input.mousePosition); * RaycastHit hitInfoNGUI; * // eger ekranda bos bir yere tiklamissam * if (!Physics.Raycast(rayNGUI, out hitInfoNGUI, 1000.0f)) { // 9: GUI Layer * // Unselected tower * if (lastSelectedTower != null) * { * lastSelectedTower.onTowerUnselected(); * UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); * } * lastSelectedTower = null; * selectedTowerType = null; * UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); * * if(lastSelectedMinion != null) * { * lastSelectedMinion.onMinionUnselected(); * UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); * } * lastSelectedMinion = null; * } * } * } * else // collider'i olmayan bir seye tiklamissak ya da hicbir seye tiklamamissak * { * if (lastSelectedTower != null) * { * lastSelectedTower.onTowerUnselected(); * UIControllerGame.getInstance().panel_TowerInfo.SetActive(false); * } * lastSelectedTower = null; * selectedTowerType = null; * UIControllerGame.getInstance().selectedTowerOverlayObject.SetActive(false); * * if (lastSelectedMinion != null) * { * lastSelectedMinion.onMinionUnselected(); * UIControllerGame.getInstance().panel_MinionInfo.SetActive(false); * } * lastSelectedMinion = null; * } * } * } */ public void activateTowerInfo(ITowerGUI towerGUI) { uiControllerGame.alwaysActiveInfoPanel = true; uiControllerGame.panel_MinionInfo.SetActive(false); towerGUI.drawInfoPanelGUI(); }