private void InteractWithBoard(BuildingAction action) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, 1000.0f)) { Vector3 gridPosition = _board.CalculateGridPosition(hit.point); // UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() => UI 오브젝트를 눌렀는지 판단 if (!UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) { if (action == BuildingAction.Build && _board.CheckForBuildingAtPosition(gridPosition) == null) { if (_city.Cash >= _selectedBuilding.cost) { _city.DepositCash(-_selectedBuilding.cost); _uiController.UpdateCityData(); _city.buildingCounts[_selectedBuilding.id]++; _board.AddBuilding(_selectedBuilding, gridPosition); } } else if (action == BuildingAction.Remove && _board.CheckForBuildingAtPosition(gridPosition) != null) { _city.DepositCash(_board.CheckForBuildingAtPosition(gridPosition).cost / 2); _uiController.UpdateCityData(); _board.RemoveBuilding(gridPosition); } } } }
public void EndTurn() { ++Day; CalculateCash(); CalculatePopulation(); CalculateJob(); CalculateFood(); _uiController.UpdateCityData(); _uiController.UpdateDayCount(); }
// Use this for initialization void Start() { _uiController = GetComponent <CUIController>(); Cash = 1000; Food = 0.0f; JobsCeiling = 0.0f; buildingCounts[0] = 0; buildingCounts[1] = 0; buildingCounts[2] = 0; buildingCounts[3] = 0; _uiController.UpdateCityData(); _uiController.UpdateDayCount(); }