/// <summary> Function called when Building is supposed to be placed. </summary> private void OnBuildingBuildIconClick() { // check whether the place is not occupied. foreach (Tile tile in m_tilesHighlighted) { if (tile.IsOccupied()) { return; } } UT_Pair <int, int> cost = M_BuildingManager.SGetBuildingCost(m_tempBuildingComp.GetData().id); // Apply cost to the resources M_InGameResourcesManager.SAddFood(-cost.first); M_InGameResourcesManager.SAddResearch(-cost.second); // Mark highlighted tiles as occupied foreach (Tile tile in m_tilesHighlighted) { tile.SetOccupied(true); tile.Highlight(false); } // set final building position Vector3 pos = m_currentMiddleTile.transform.position; pos.y = M_MapManager.SGetYDepthValue(pos.z); m_tempBuildingObj.transform.position = pos; // Move to the BUILDINGS group M_GameHelper.AddToGroup(m_tempBuildingObj, M_GameHelper.Group.BUILDINGS); m_tempBuildingComp.SetActionOnBuildingFinished(ActionOnBuildingFinished); // Start in-game building process m_tempBuildingComp.StartBuilding(); m_onBuildingPlacedAction(m_tempBuildingComp); // reset values m_tempBuildingObj.GetComponent <IBuilding>().GetBuildButton().SetActive(false); m_tempBuildingObj = null; m_tempBuildingComp = null; m_currentMiddleTile = null; m_tilesHighlighted.Clear(); M_MiscManager.ShowCancelButton(false); }