// 建筑升级结束 private void OnBuildingLevelupFinish(long buildingID) { CityBuilding building = GetBuilding(buildingID); if (building != null) { building.Refresh(); building.OnLevelUp(); } // 正在工作的工人结束建筑 foreach (var item in _citizens) { if (item.IsWorking()) { item.WorkFinish(); } } CityBuildingUI buildingUI = GetBuildingUI(buildingID); if (buildingUI != null) { buildingUI.Refresh(); } // 刷新生产建筑的图标(资源满、未满的提示区分) foreach (var item in _buildingUIList) { item.UpdatePanel(); } }
private void OnBuildingRefresh(long buildingID) { CityBuilding building = GetBuilding(buildingID); if (building != null) { building.Refresh(); } CityBuildingUI buildingUI = GetBuildingUI(buildingID); if (buildingUI != null) { buildingUI.Refresh(); } }
// 建筑开始升级 private void OnBuildingLevelup(long buildingID) { CityBuilding building = GetBuilding(buildingID); if (building != null) { building.Refresh(); // 遍历所有的工人,选三个最近的 List <CityCitizen> list = new List <CityCitizen>(); foreach (var item in _citizens) { if (item.CouldWork()) { list.Add(item); } } list.Sort((a, b) => { float disA = Vector3.Distance(gameObject.transform.position, a.transform.position); float disB = Vector3.Distance(gameObject.transform.position, b.transform.position); return(disA.CompareTo(disB)); }); list = list.GetRange(0, Mathf.Min(3, list.Count)); foreach (var item in list) { item.RunToBuilding(building); } } CityBuildingUI buildingUI = GetBuildingUI(buildingID); if (buildingUI != null) { buildingUI.Refresh(); } }