private void OnCityAdd(SocketAsyncEventArgs args, byte[] bytes) { CityAdd input = CityAdd.Parser.ParseFrom(bytes); if (input.RoomId != RoomId) { return; // 不是自己房间的消息,略过 } // 删除建造城市的开拓者 { bool ret = ActorManager.RemoveActor(input.CreatorId); ActorRemoveReply output = new ActorRemoveReply() { RoomId = input.RoomId, OwnerId = input.OwnerId, ActorId = input.CreatorId, Ret = ret, }; BroadcastMsg(ROOM_REPLY.ActorRemoveReply, output.ToByteArray()); } if (input.CellIndex == 0) { Debug.LogError("OnCityAdd F**k!!! City position is lost!!!"); } bool isCapiirtal = UrbanManager.CountOfThePlayer(input.OwnerId) == 0; // 第一座城市是都城 UrbanCity city = new UrbanCity() { RoomId = input.RoomId, OwnerId = input.OwnerId, CityId = input.CityId, PosX = input.PosX, PosZ = input.PosZ, CellIndex = input.CellIndex, CityName = input.CityName, CitySize = input.CitySize, IsCapital = isCapiirtal, }; UrbanManager.AddCity(city); { CityAddReply output = new CityAddReply() { RoomId = input.RoomId, OwnerId = input.OwnerId, CityId = input.CityId, PosX = input.PosX, PosZ = input.PosZ, CellIndex = input.CellIndex, CityName = input.CityName, CitySize = input.CitySize, IsCapital = isCapiirtal, Ret = true, }; BroadcastMsg(ROOM_REPLY.CityAddReply, output.ToByteArray()); } }
private static void DOWNLOAD_CITIES_REPLY(byte[] bytes) { DownloadCitiesReply input = DownloadCitiesReply.Parser.ParseFrom(bytes); if (!input.Ret) { string msg = $"查询城市信息失败!"; GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY Error - " + msg); return; } GameRoomManager.Instance.Log($"MSG: DOWNLOAD_CITIES_REPLY OK - 城市个数:{input.MyCount}/{input.TotalCount}"); // 如果我一个城市都没有,则主动创建一个城市 if (input.MyCount == 0) { UrbanCity city = GameRoomManager.Instance.RoomLogic.UrbanManager.CreateRandomCity(); if (city == null) { string msg = "自动创建城市失败!"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY - " + msg); } else { CityAdd output = new CityAdd() { RoomId = city.RoomId, OwnerId = city.OwnerId, CityId = city.CityId, PosX = city.PosX, PosZ = city.PosZ, CellIndex = city.CellIndex, CityName = city.CityName, CitySize = city.CitySize, }; GameRoomManager.Instance.SendMsg(ROOM.CityAdd, output.ToByteArray()); GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY OK - 申请创建城市..."); } } { string msg = $"查询城市信息成功!"; GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY OK - " + msg + $"City Count:{input.MyCount}/{input.TotalCount}"); } // 进入房间整体流程完成 UIManager.Instance.EndLoading(); }
public static void Runbase() { var _country = CountryAdd.country(); var _district = DistrictAdd.districts(); var _city = CityAdd.CityList(); var _neighborhood = NeighborhoodAdd.neighborhoods(); var _query = from country in _country join district in _district on country.District equals district.DistrictName join city in _city on district.City equals city.NeighborhoodCity join neighborhood in _neighborhood on city.Neighborhood equals neighborhood.NeighborhoodName select new { neighborhood.StreetName }; foreach (var item in _query) { Console.WriteLine($"Street: {item.StreetName}"); } //var _query = from country in _country // group country by country.CountryName into newGroup // select new // { // countryname = newGroup.Key, // streetname = from fdCountry in newGroup // join district in _district on fdCountry.District equals district.DistrictName // join city in _city on district.City equals city.NeighborhoodCity // join neighborhood in _neighborhood on city.Neighborhood equals neighborhood.NeighborhoodName // select new { neighborhood.StreetName } // }; //foreach (var item in _query) // { // Console.WriteLine($"Country: {item.countryname}"); // Console.WriteLine(""); // foreach (var subitem in item.streetname) // { // Console.WriteLine($"Street: {subitem.StreetName}"); // } // Console.WriteLine(Environment.NewLine); // } }
public async Task <ActionResult <CityAdd> > AddCityInfo([FromBody] CityAdd cityToAdd) { var duplicate = await _service.FindDuplicate(cityToAdd.Name, cityToAdd.RegionName); if (duplicate == null) { var cityModel = _mapper.Map <City>(cityToAdd); _service.AddNewCity(cityModel); _service.SaveChanges(); return(Ok()); } else { return(BadRequest($"{cityToAdd.RegionName} already contains {cityToAdd.Name}.")); } }
bool AskBuildCity() { HexCell cell = GetCellUnderCursor(); if (cell && cell.Unit) { string msg = $"这里有部队存在,不能创建城市!"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); GameRoomManager.Instance.Log("AskBuildCity - " + msg); return(false); } UrbanCity city = GameRoomManager.Instance.RoomLogic.UrbanManager.CreateCityHere(cell); if (city == null) { string msg = "无法创建城市!"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); GameRoomManager.Instance.Log("AskBuildCity - " + msg); return(false); } else { CityAdd output = new CityAdd() { RoomId = city.RoomId, OwnerId = city.OwnerId, CityId = city.CityId, PosX = city.PosX, PosZ = city.PosZ, CellIndex = city.CellIndex, CityName = city.CityName, CitySize = city.CitySize, }; GameRoomManager.Instance.SendMsg(ROOM.CityAdd, output.ToByteArray()); GameRoomManager.Instance.Log("AskBuildCity - 申请创建城市..."); } return(true); }
public void Run() { var pi = CommandManager.Instance.CurrentExecuter; if (pi == null || !pi.CurrentActor) { string msg = $"没有选中任何部队!"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); GameRoomManager.Instance.Log("CmdBuildCity Error - " + msg); return; } long creatorId = 0; var av = pi.CurrentActor; if (av != null) { creatorId = av.ActorId; } else { string msg = "没有找到开拓者,无法创建城市!"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); GameRoomManager.Instance.Log("CmdBuildCity Error - " + msg); return; } UrbanCity city = GameRoomManager.Instance.RoomLogic.UrbanManager.CreateCityHere(av.HexUnit.Location); if (city == null) { string msg = "这个位置无法创建城市!"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); GameRoomManager.Instance.Log("CmdBuildCity Error - " + msg); return; } // 看看行动点够不够 if (!CmdAttack.IsActionPointGranted()) { string msg = "行动点数不够, 本操作无法执行! "; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); Debug.Log("CmdBuildCity Run Error - " + msg); return; } { CityAdd output = new CityAdd() { RoomId = city.RoomId, OwnerId = city.OwnerId, CityId = city.CityId, PosX = city.PosX, PosZ = city.PosZ, CellIndex = city.CellIndex, CityName = city.CityName, CitySize = city.CitySize, CreatorId = creatorId, }; GameRoomManager.Instance.SendMsg(ROOM.CityAdd, output.ToByteArray()); GameRoomManager.Instance.Log("AskBuildCity - 申请创建城市..."); // 消耗行动点 CmdAttack.TryCommand(); } }