private void OnHarvestStopReply(byte[] bytes) { HarvestStopReply input = HarvestStopReply.Parser.ParseFrom(bytes); if (input.ActorId != ActorId) { return; // 不是自己,略过 } if (!input.Ret) { return; } HexResource.RESOURCE_TYPE resType = (HexResource.RESOURCE_TYPE)input.ResType; HexCell currentCell = HexUnit.Location; HexResource res = currentCell.Res; int level = res.GetLevel(resType); res.SetAmount(resType, input.ResRemain); int levelNew = res.GetLevel(resType); if (level != levelNew) { res.Refresh(currentCell); } string [] resTypes = { "木材", "粮食", "铁矿" }; string msg = $"获取了 {input.ResHarvest} 的 {resTypes[input.ResType]} 资源"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Success); GameRoomManager.Instance.Log("MSG: HarvestStop OK - " + msg + $" - 剩余资源{input.ResRemain}"); // 必要的时候, 刷新地面上的资源数字 PanelRoomMain.Instance.UpdateResInCell(currentCell.Index); }
public void SetSelector(PickInfo pickInfo) { ClearCommands(); GameRoomManager.Instance.CommandManager.CurrentExecuter = pickInfo; //从“command_set”表格中读取对应于该单位的指令菜单集 CsvStreamReader CommandSet = CsvDataManager.Instance.GetTable("command_set"); if (CommandSet == null) { return; } string strCmdSet = ""; string toggleRootName = ""; if (pickInfo.CurrentCity != null) { if (pickInfo.CurrentCity.OwnerId == GameRoomManager.Instance.CurrentPlayer.TokenId) // 只有是自己的城市,才会出现[命令菜单] { strCmdSet = CommandSet.GetValue(2001, "CommandSet"); } toggleRootName = "城市"; } else if (pickInfo.CurrentActor != null) { var av = pickInfo.CurrentActor; if (av.OwnerId == GameRoomManager.Instance.CurrentPlayer.TokenId) // 只有是自己的部队,才会出现[命令菜单] { strCmdSet = CommandSet.GetValue(av.ActorInfoId, "CommandSet"); } CsvStreamReader csv = CsvDataManager.Instance.GetTable("actor_info"); toggleRootName = csv.GetValue(av.ActorInfoId, "Name"); } else if (pickInfo.CurrentCell != null) { HexResource res = pickInfo.CurrentCell.Res; if (res.GetAmount(res.ResType) > 0) { string[] resNames = { "木材", "粮食", "铁矿" }; toggleRootName = $"{resNames[(int) res.ResType]}:{res.GetLevel(res.ResType)}"; } else if (pickInfo.CurrentCell.IsUnderwater) { toggleRootName = "水"; } else {// Sand-0; Grass-1; Mud-2; Stone-3; Snow-4 string[] terrainNames = { "沙漠", "草原", "沃土", "山区", "雪地" }; toggleRootName = terrainNames[(int)pickInfo.CurrentCell.TerrainTypeIndex]; } } int countCmd = LoadCommandMenu(strCmdSet); //gameObject.SetActive(countCmd > 0); _toggleText.text = toggleRootName; gameObject.SetActive(true); }
/// <summary> /// 从资源层[Res]的数据更新到farm Level,plantLevel,mineLevel /// </summary> public void UpdateFeatureLevelFromRes() { int level = Res.GetLevel(Res.ResType); if (level >= 0) { switch (Res.ResType) { case HexResource.RESOURCE_TYPE.WOOD: plantLevel = level; break; case HexResource.RESOURCE_TYPE.FOOD: farmLevel = level; break; case HexResource.RESOURCE_TYPE.IRON: mineLevel = level; break; } } }