From ce0a5fc5dfce390ed44f027bed216f8e617d2432 Mon Sep 17 00:00:00 2001 From: "star\\zhenghan" Date: Fri, 12 Aug 2022 17:53:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BB=BA=E7=AD=91=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Proto/OuterMessage.proto | 3 ++- .../Handler/C2M_ConstructFinishHandler.cs | 4 +-- Server/Hotfix/Demo/Helper/ConstructHelper.cs | 4 +-- Server/Hotfix/Server.Hotfix.csproj | 2 +- Server/Model/Generate/Message/OuterMessage.cs | 6 +++++ Unity/Animancer.FSM.csproj | 2 +- Unity/Animancer.csproj | 2 +- .../Construct/ConstructComponentSystem.cs | 4 +-- .../Hotfix/Demo/Construct/ConstructSystem.cs | 2 ++ .../M2C_NofityConstructFinishHandler.cs | 2 +- .../Hotfix/Demo/Helper/ConstructHelper.cs | 2 +- .../Hotfix/Demo/Operate/ConstructOperate.cs | 24 +++++++++++++----- Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs | 5 +++- .../AfterCreateBuilding_AddComponent.cs | 10 ++++++-- .../Building/ConstructFinish_RefreshWindow.cs | 25 +++++++++++++++++++ ...FUIBuildingUpgradeWindowComponentSystem.cs | 3 ++- ...FUIPrepareBuildingWindowComponentSystem.cs | 6 +++-- .../Demo/People/PeopleViewComponentSystem.cs | 2 +- .../Demo => Model/Demo/Config}/WorldParam.cs | 0 .../Demo/Config/WorldParametersConfig.cs | 10 ++++++++ .../Model/Generate/Message/OuterMessage.cs | 6 +++++ 21 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 Unity/Codes/HotfixView/Demo/FUI/Logic/Building/ConstructFinish_RefreshWindow.cs rename Unity/Codes/{Hotfix/Demo => Model/Demo/Config}/WorldParam.cs (100%) create mode 100644 Unity/Codes/Model/Demo/Config/WorldParametersConfig.cs diff --git a/Proto/OuterMessage.proto b/Proto/OuterMessage.proto index 64a2545..9de46c7 100644 --- a/Proto/OuterMessage.proto +++ b/Proto/OuterMessage.proto @@ -67,7 +67,6 @@ message BuildingProto int32 Durable = 5; FarmlandProto Farmland = 6; int32 IsUpgrade = 7; - } message PeopleProto @@ -137,6 +136,7 @@ message ConstructProto int32 Progress = 8; repeated int64 PeopleIdList = 9; repeated int64 PreparePeopleIdList = 10; + int64 BuildingId = 11; } message SynthesisProto @@ -771,6 +771,7 @@ message M2C_NotifyUpdatePeople // IActorMessage message M2C_NotifyConstructFinish // IActorMessage { int64 ConstructId = 1; + int64 BuildingId = 2; } message M2C_NotifyUpdateValley // IActorMessage diff --git a/Server/Hotfix/Demo/Construct/Handler/C2M_ConstructFinishHandler.cs b/Server/Hotfix/Demo/Construct/Handler/C2M_ConstructFinishHandler.cs index 970d53f..5809f64 100644 --- a/Server/Hotfix/Demo/Construct/Handler/C2M_ConstructFinishHandler.cs +++ b/Server/Hotfix/Demo/Construct/Handler/C2M_ConstructFinishHandler.cs @@ -7,10 +7,10 @@ namespace ET { try { - ConstructOperate.ConstructFinish(unit, request.ConstructId); + var building = ConstructOperate.ConstructFinish(unit, request.ConstructId); response.Error = ErrorCode.ERR_Success; reply(); - ConstructHelper.NofityConstructFinish(unit,request.ConstructId); + ConstructHelper.NofityConstructFinish(unit,request.ConstructId, building.Id); } catch (Exception e) { diff --git a/Server/Hotfix/Demo/Helper/ConstructHelper.cs b/Server/Hotfix/Demo/Helper/ConstructHelper.cs index d618c03..3165457 100644 --- a/Server/Hotfix/Demo/Helper/ConstructHelper.cs +++ b/Server/Hotfix/Demo/Helper/ConstructHelper.cs @@ -21,9 +21,9 @@ namespace ET } } - public static void NofityConstructFinish(Unit unit, long id) + public static void NofityConstructFinish(Unit unit, long id, long buildingId) { - MessageHelper.SendToClient(unit,new M2C_NotifyConstructFinish(){ConstructId = id}); + MessageHelper.SendToClient(unit,new M2C_NotifyConstructFinish(){ConstructId = id, BuildingId = buildingId}); } } } \ No newline at end of file diff --git a/Server/Hotfix/Server.Hotfix.csproj b/Server/Hotfix/Server.Hotfix.csproj index 39e2171..157ba76 100644 --- a/Server/Hotfix/Server.Hotfix.csproj +++ b/Server/Hotfix/Server.Hotfix.csproj @@ -150,7 +150,7 @@ Demo\Unit\UnitSystem.cs - + Demo\WorldParam.cs diff --git a/Server/Model/Generate/Message/OuterMessage.cs b/Server/Model/Generate/Message/OuterMessage.cs index e4be3c4..275ee7f 100644 --- a/Server/Model/Generate/Message/OuterMessage.cs +++ b/Server/Model/Generate/Message/OuterMessage.cs @@ -308,6 +308,9 @@ namespace ET [ProtoMember(10)] public List PreparePeopleIdList = new List(); + [ProtoMember(11)] + public long BuildingId { get; set; } + } [Message(OuterOpcode.SynthesisProto)] @@ -1601,6 +1604,9 @@ namespace ET [ProtoMember(1)] public long ConstructId { get; set; } + [ProtoMember(2)] + public long BuildingId { get; set; } + } [Message(OuterOpcode.M2C_NotifyUpdateValley)] diff --git a/Unity/Animancer.FSM.csproj b/Unity/Animancer.FSM.csproj index d414345..8c724c1 100644 --- a/Unity/Animancer.FSM.csproj +++ b/Unity/Animancer.FSM.csproj @@ -53,7 +53,7 @@ 2021.3.7f1c1 - + diff --git a/Unity/Animancer.csproj b/Unity/Animancer.csproj index 2233100..779372b 100644 --- a/Unity/Animancer.csproj +++ b/Unity/Animancer.csproj @@ -53,7 +53,7 @@ 2021.3.7f1c1 - + diff --git a/Unity/Codes/Hotfix/Demo/Construct/ConstructComponentSystem.cs b/Unity/Codes/Hotfix/Demo/Construct/ConstructComponentSystem.cs index 2608b5e..09a2c44 100644 --- a/Unity/Codes/Hotfix/Demo/Construct/ConstructComponentSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Construct/ConstructComponentSystem.cs @@ -57,8 +57,8 @@ namespace ET ConstructHelper.NtfUpdateConstructProgress(unit, self); foreach (var v in finishConstructs) { - ConstructOperate.ConstructFinish(unit, v.Id); - ConstructHelper.NofityConstructFinish(unit,v.Id); + var building = ConstructOperate.ConstructFinish(unit, v.Id); + ConstructHelper.NofityConstructFinish(unit,v.Id, building.Id); } if (finishConstructs.Count > 0) diff --git a/Unity/Codes/Hotfix/Demo/Construct/ConstructSystem.cs b/Unity/Codes/Hotfix/Demo/Construct/ConstructSystem.cs index 6393049..120e10e 100644 --- a/Unity/Codes/Hotfix/Demo/Construct/ConstructSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Construct/ConstructSystem.cs @@ -15,6 +15,7 @@ namespace ET self.ConfigId = constructProto.ConfigId; self.PeopleIdList = constructProto.PeopleIdList; self.PreparePeopleIdList = constructProto.PreparePeopleIdList; + self.BuildingId = constructProto.BuildingId; } public static ConstructProto ToMessage(this Construct self) @@ -28,6 +29,7 @@ namespace ET proto.ConfigId = self.ConfigId; proto.PeopleIdList = self.PeopleIdList; proto.PreparePeopleIdList = self.PreparePeopleIdList; + proto.BuildingId = self.BuildingId; return proto; } diff --git a/Unity/Codes/Hotfix/Demo/Construct/Handler/M2C_NofityConstructFinishHandler.cs b/Unity/Codes/Hotfix/Demo/Construct/Handler/M2C_NofityConstructFinishHandler.cs index 0fe40c1..d6a0393 100644 --- a/Unity/Codes/Hotfix/Demo/Construct/Handler/M2C_NofityConstructFinishHandler.cs +++ b/Unity/Codes/Hotfix/Demo/Construct/Handler/M2C_NofityConstructFinishHandler.cs @@ -5,7 +5,7 @@ { protected override void Run(Session session, M2C_NotifyConstructFinish message) { - var building = ConstructOperate.ConstructFinish(UnitComponent.unit,message.ConstructId); + var building = ConstructOperate.ConstructFinish(UnitComponent.unit,message.ConstructId, message.BuildingId); UnitOperate.InitProsperity(UnitComponent.unit); if (building != null) { diff --git a/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs b/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs index ca2ac6f..2cf9319 100644 --- a/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs +++ b/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs @@ -13,7 +13,7 @@ namespace ET M2C_CreateConstruct resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CreateConstruct; if (resp.Error == ErrorCode.ERR_Success) { - var construct = unit.GetOrAddComponent().CreateConstruct(unit, configId, x, y, resp.Id); + var construct = unit.GetOrAddComponent().CreateConstruct(unit, configId, x, y, resp.Id, buildingId); Game.EventSystem.Publish(new EventType.AfterCreateConstruct() { Unit = unit, Construct = construct, IsNew = true }); } else diff --git a/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs b/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs index 48a7b15..235f706 100644 --- a/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs +++ b/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs @@ -139,7 +139,7 @@ namespace ET return ErrorCode.ERR_Success; } - public static Building ConstructFinish(Unit unit, long constructId) + public static Building ConstructFinish(Unit unit, long constructId, long buildingId = 0) { var construct = unit.GetComponent().GetChild(constructId); Building build; @@ -150,13 +150,26 @@ namespace ET if (construct.IsUpgrade) { - build = unit.GetOrAddComponent().GetChild(construct.BuildingId); - build.ConfigId = construct.Config.MixtureID; + var buildingComp = unit.GetOrAddComponent(); + build = buildingComp.GetChild(construct.BuildingId); + if (build == null) + { + Log.Error($"Can't find building:{construct.BuildingId} for construct:{construct.Id}"); + } build.IsUpgrade = 0; + build.ConfigId = construct.Config.MixtureID; } else { - build = unit.GetOrAddComponent().AddChild(); + if (buildingId > 0) + { + build = unit.GetOrAddComponent().AddChildWithId(buildingId); + } + else + { + build = unit.GetOrAddComponent().AddChild(); + } + build.Position.x = construct.X; build.Position.y = construct.Y; build.ConfigId = construct.Config.MixtureID; @@ -167,8 +180,7 @@ namespace ET farmland.FarmlandState = FarmlandState.FARMLAND_STATE_FREE; } } - - + StructureConfig structureConfig = StructureConfigCategory.Instance.Get(build.ConfigId); if (structureConfig != null) { diff --git a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs index 122c713..69d38db 100644 --- a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs @@ -156,7 +156,10 @@ namespace ET return; } self.Season = self.SeasonConfig.Id; - UnitHelper.NofityUpdateValley(self, new List { NumericType.Season }, new List { self.Season }); +#if SERVER + UnitHelper.NofityUpdateValley(self, new List { NumericType.Season }, new List { self.Season }); +#endif + //如果是春天,长大一岁 } diff --git a/Unity/Codes/HotfixView/Demo/Building/AfterCreateBuilding_AddComponent.cs b/Unity/Codes/HotfixView/Demo/Building/AfterCreateBuilding_AddComponent.cs index 964b35d..6763631 100644 --- a/Unity/Codes/HotfixView/Demo/Building/AfterCreateBuilding_AddComponent.cs +++ b/Unity/Codes/HotfixView/Demo/Building/AfterCreateBuilding_AddComponent.cs @@ -2,14 +2,20 @@ namespace ET { + [FriendClass(typeof(Building))] public class AfterCreateBuilding_AddComponent : AEvent { protected override void Run(AfterCreateBuilding args) { var unit = args.Unit; var building = args.Building; - var buildingViewComp = building.AddComponent(); - buildingViewComp.CreateName().Coroutine(); + // 升级的过程中不显示原先的建筑 + if (building.IsUpgrade == 0) + { + var buildingViewComp = building.AddComponent(); + buildingViewComp.CreateName().Coroutine(); + } + // update map info } } diff --git a/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/ConstructFinish_RefreshWindow.cs b/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/ConstructFinish_RefreshWindow.cs new file mode 100644 index 0000000..ad9c322 --- /dev/null +++ b/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/ConstructFinish_RefreshWindow.cs @@ -0,0 +1,25 @@ +using ET.EventType; + +namespace ET +{ + using FUIBuilding; + public class ConstructFinish_RefreshWindow : AEvent + { + protected override void Run(AfterCreateBuilding args) + { + var unit = args.Unit; + var building = args.Building; + + var win = FUIComponent.Instance.GetWindow(FUI_BuildingInfoWindow.UIResName); + if (win != null) + { + var BuildingWin = win as FUIBuildingInfoWindowComponent; + if (BuildingWin.Window.isShowing) + { + BuildingWin.ShowInfo(building); + } + } + + } + } +} \ No newline at end of file diff --git a/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIBuildingUpgradeWindowComponentSystem.cs b/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIBuildingUpgradeWindowComponentSystem.cs index 395abf3..dab4619 100644 --- a/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIBuildingUpgradeWindowComponentSystem.cs +++ b/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIBuildingUpgradeWindowComponentSystem.cs @@ -76,9 +76,10 @@ namespace ET self.CurUpgradeSynthesisConfigId = synthesisConfig.Id; if (synthesisConfig != null) { + float discount = WorldParametersConfigCategory.Instance.GetUpgradePercent(); for (int i = 0; i < synthesisConfig.ItemId.Length; i++) { - self.SetMaterialData(self.MaterialButtons[i], synthesisConfig.ItemId[i], synthesisConfig.ItemNum[i]); + self.SetMaterialData(self.MaterialButtons[i], synthesisConfig.ItemId[i], (int)(synthesisConfig.ItemNum[i] * discount)); } for (int j = synthesisConfig.ItemId.Length; j < 4; j++) diff --git a/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIPrepareBuildingWindowComponentSystem.cs b/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIPrepareBuildingWindowComponentSystem.cs index 831d622..38d126c 100644 --- a/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIPrepareBuildingWindowComponentSystem.cs +++ b/Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIPrepareBuildingWindowComponentSystem.cs @@ -58,7 +58,7 @@ namespace ET // init event self.FUIPrepareBuildingWindow.m_AddSpeedButton.FGComp.onClick.Add(self.OnAddSpeedButtonClick); - self.FUIPrepareBuildingWindow.m_CompleteButton.FGComp.onClick.Add(self.OnCompleteButtonClick); + self.FUIPrepareBuildingWindow.m_CompleteButton.FGComp.AddClickListenerAsync(self.OnCompleteButtonClick); self.FUIPrepareBuildingWindow.m_CancelBuildingButton.FGComp.AddClickListenerAsync(self.OnCancelBuildingButtonClick); } @@ -153,8 +153,10 @@ namespace ET Log.Debug("AddSpeed Button Click"); } - public static void OnCompleteButtonClick(this FUIPrepareBuildingWindowComponent self) + public static async ETTask OnCompleteButtonClick(this FUIPrepareBuildingWindowComponent self) { + Unit unit = UnitHelper.GetMyUnitFromZoneScene(self.ZoneScene()); + await ConstructHelper.ConstructFinish(unit, self.Construct.Id); Log.Debug("Complete Button Click"); } diff --git a/Unity/Codes/HotfixView/Demo/People/PeopleViewComponentSystem.cs b/Unity/Codes/HotfixView/Demo/People/PeopleViewComponentSystem.cs index 7bb654d..2fd6e46 100644 --- a/Unity/Codes/HotfixView/Demo/People/PeopleViewComponentSystem.cs +++ b/Unity/Codes/HotfixView/Demo/People/PeopleViewComponentSystem.cs @@ -132,7 +132,7 @@ namespace ET { if (!self.Agent.hasPath || self.Agent.velocity.sqrMagnitude == 0f) { - Log.Info("Reach Dest"); + // Log.Info("Reach Dest"); self.Stop(); } } diff --git a/Unity/Codes/Hotfix/Demo/WorldParam.cs b/Unity/Codes/Model/Demo/Config/WorldParam.cs similarity index 100% rename from Unity/Codes/Hotfix/Demo/WorldParam.cs rename to Unity/Codes/Model/Demo/Config/WorldParam.cs diff --git a/Unity/Codes/Model/Demo/Config/WorldParametersConfig.cs b/Unity/Codes/Model/Demo/Config/WorldParametersConfig.cs new file mode 100644 index 0000000..1c56629 --- /dev/null +++ b/Unity/Codes/Model/Demo/Config/WorldParametersConfig.cs @@ -0,0 +1,10 @@ +namespace ET +{ + public partial class WorldParametersConfigCategory + { + public float GetUpgradePercent() + { + return Get(WorldParam.UpgratePercent).Value[0] / 100.0f; + } + } +} \ No newline at end of file diff --git a/Unity/Codes/Model/Generate/Message/OuterMessage.cs b/Unity/Codes/Model/Generate/Message/OuterMessage.cs index e4be3c4..275ee7f 100644 --- a/Unity/Codes/Model/Generate/Message/OuterMessage.cs +++ b/Unity/Codes/Model/Generate/Message/OuterMessage.cs @@ -308,6 +308,9 @@ namespace ET [ProtoMember(10)] public List PreparePeopleIdList = new List(); + [ProtoMember(11)] + public long BuildingId { get; set; } + } [Message(OuterOpcode.SynthesisProto)] @@ -1601,6 +1604,9 @@ namespace ET [ProtoMember(1)] public long ConstructId { get; set; } + [ProtoMember(2)] + public long BuildingId { get; set; } + } [Message(OuterOpcode.M2C_NotifyUpdateValley)]