diff --git a/Proto/OuterMessage.proto b/Proto/OuterMessage.proto index c1e1a85..64a2545 100644 --- a/Proto/OuterMessage.proto +++ b/Proto/OuterMessage.proto @@ -1230,6 +1230,20 @@ message C2M_FarmlandHarvest // IActorLocationRequest } message M2C_FarmlandHarvest // IActorLocationResponse +{ + int32 RpcId = 90; + int32 Error = 91; + string Message = 92; +} + +//ResponseType M2C_ConstructFinish +message C2M_ConstructFinish // IActorLocationRequest +{ + int32 RpcId = 90; + int64 ConstructId = 1; +} + +message M2C_ConstructFinish // IActorLocationResponse { int32 RpcId = 90; int32 Error = 91; diff --git a/Server/Hotfix/Demo/Construct/Handler/C2M_ConstructFinishHandler.cs b/Server/Hotfix/Demo/Construct/Handler/C2M_ConstructFinishHandler.cs new file mode 100644 index 0000000..7fe4f7d --- /dev/null +++ b/Server/Hotfix/Demo/Construct/Handler/C2M_ConstructFinishHandler.cs @@ -0,0 +1,24 @@ +using System; +namespace ET +{ + public class C2M_ConstructFinishHandler: AMActorLocationRpcHandler + { + protected async override ETTask Run(Unit unit, C2M_ConstructFinish request, M2C_ConstructFinish response, Action reply) + { + try + { + ConstructOperate.ConstructFinish(unit, request.ConstructId); + response.Error = ErrorCode.ERR_Success; + reply(); + } + catch (Exception e) + { + response.Message = e.ToString(); + response.Error = ErrorCode.ERR_OperateFail; + reply(); + } + + await ETTask.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Server/Hotfix/Demo/Unit/UnitFactory.cs b/Server/Hotfix/Demo/Unit/UnitFactory.cs index aef8417..0fade23 100644 --- a/Server/Hotfix/Demo/Unit/UnitFactory.cs +++ b/Server/Hotfix/Demo/Unit/UnitFactory.cs @@ -87,7 +87,7 @@ namespace ET people.Name = role.Name; people.Level = 1; people.Exp = 0; - people.LaborLevel = 1; + people.Labor = 1; people.LaborExp = 0; people.Age = role.Age; if (role.AttributesGroup > 0) @@ -109,7 +109,7 @@ namespace ET hero.Name = roleInfo.Name; hero.Level = 1; hero.Exp = 0; - hero.LaborLevel = 1; + hero.Labor = 1; hero.LaborExp = 0; hero.Age = heroConfig.Age; if (heroConfig.AttributesGroup > 0) diff --git a/Server/Model/Generate/Message/OuterMessage.cs b/Server/Model/Generate/Message/OuterMessage.cs index 7143b05..e4be3c4 100644 --- a/Server/Model/Generate/Message/OuterMessage.cs +++ b/Server/Model/Generate/Message/OuterMessage.cs @@ -2576,4 +2576,32 @@ namespace ET } + [ResponseType(nameof(M2C_ConstructFinish))] + [Message(OuterOpcode.C2M_ConstructFinish)] + [ProtoContract] + public partial class C2M_ConstructFinish: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public long ConstructId { get; set; } + + } + + [Message(OuterOpcode.M2C_ConstructFinish)] + [ProtoContract] + public partial class M2C_ConstructFinish: Object, IActorLocationResponse + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(91)] + public int Error { get; set; } + + [ProtoMember(92)] + public string Message { get; set; } + + } + } diff --git a/Server/Model/Generate/Message/OuterOpcode.cs b/Server/Model/Generate/Message/OuterOpcode.cs index 2639765..d2e3bbd 100644 --- a/Server/Model/Generate/Message/OuterOpcode.cs +++ b/Server/Model/Generate/Message/OuterOpcode.cs @@ -152,5 +152,7 @@ namespace ET public const ushort M2C_FarmlandPlant = 10149; public const ushort C2M_FarmlandHarvest = 10150; public const ushort M2C_FarmlandHarvest = 10151; + public const ushort C2M_ConstructFinish = 10152; + public const ushort M2C_ConstructFinish = 10153; } } diff --git a/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs b/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs index 2557a7c..ca2ac6f 100644 --- a/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs +++ b/Unity/Codes/Hotfix/Demo/Helper/ConstructHelper.cs @@ -5,16 +5,16 @@ namespace ET { public static class ConstructHelper { - public static async ETTask CreateConstruct(Unit unit, int configId, float x, float y,long buildingId=0) + public static async ETTask CreateConstruct(Unit unit, int configId, float x, float y, long buildingId = 0) { try { - C2M_CreateConstruct msg = new C2M_CreateConstruct(){ConfigId = configId, X = x,Y = y,BuildingId = buildingId}; - M2C_CreateConstruct resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CreateConstruct; + C2M_CreateConstruct msg = new C2M_CreateConstruct() { ConfigId = configId, X = x, Y = y, BuildingId = buildingId }; + 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); - Game.EventSystem.Publish(new EventType.AfterCreateConstruct(){Unit = unit, Construct = construct, IsNew = true}); + var construct = unit.GetOrAddComponent().CreateConstruct(unit, configId, x, y, resp.Id); + Game.EventSystem.Publish(new EventType.AfterCreateConstruct() { Unit = unit, Construct = construct, IsNew = true }); } else { @@ -28,7 +28,6 @@ namespace ET Log.Error(e.ToString()); throw; } - } public static async ETTask CancelConstruct(Unit unit, long id) @@ -51,17 +50,18 @@ namespace ET throw; } } - + public static async ETTask GoConstruct(Unit unit, long id, List peopleIdList) { try { M2C_GoConstruct resp = - await unit.ZoneScene().GetComponent().Session.Call(new C2M_GoConstruct() { Id = id,PeopleIdList = peopleIdList}) as + await unit.ZoneScene().GetComponent().Session + .Call(new C2M_GoConstruct() { Id = id, PeopleIdList = peopleIdList }) as M2C_GoConstruct; if (resp.Error == ErrorCode.ERR_Success) { - ConstructOperate.GoConstruct(unit,id,peopleIdList); + ConstructOperate.GoConstruct(unit, id, peopleIdList); } return resp.Error; @@ -78,12 +78,14 @@ namespace ET try { M2C_StartConstruct resp = - await unit.ZoneScene().GetComponent().Session.Call(new C2M_StartConstruct() { Id = id,peopleId = peopleId }) as + await unit.ZoneScene().GetComponent().Session + .Call(new C2M_StartConstruct() { Id = id, peopleId = peopleId }) as M2C_StartConstruct; if (resp.Error == ErrorCode.ERR_Success) { - ConstructOperate.StartConstruct(unit,id,peopleId); + ConstructOperate.StartConstruct(unit, id, peopleId); } + return resp.Error; } catch (Exception e) @@ -92,17 +94,18 @@ namespace ET throw; } } - + public static async ETTask StopConstruct(Unit unit, long id, long peopleId) { try { M2C_StopConstruct resp = - await unit.ZoneScene().GetComponent().Session.Call(new C2M_StopConstruct() { Id = id,peopleId = peopleId}) as + await unit.ZoneScene().GetComponent().Session + .Call(new C2M_StopConstruct() { Id = id, peopleId = peopleId }) as M2C_StopConstruct; if (resp.Error == ErrorCode.ERR_Success) { - ConstructOperate.StopConstruct(unit,id,peopleId); + ConstructOperate.StopConstruct(unit, id, peopleId); } return resp.Error; @@ -113,6 +116,22 @@ namespace ET throw; } } - + + public static async ETTask ConstructFinish(Unit unit, long id) + { + try + { + M2C_ConstructFinish resp = + await unit.ZoneScene().GetComponent().Session.Call(new C2M_ConstructFinish() { ConstructId = id }) as + M2C_ConstructFinish; + + return resp.Error; + } + catch (Exception e) + { + Log.Error(e.ToString()); + throw; + } + } } } \ No newline at end of file diff --git a/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs b/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs index 73ef218..48a7b15 100644 --- a/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs +++ b/Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs @@ -151,6 +151,7 @@ namespace ET if (construct.IsUpgrade) { build = unit.GetOrAddComponent().GetChild(construct.BuildingId); + build.ConfigId = construct.Config.MixtureID; build.IsUpgrade = 0; } else @@ -158,6 +159,7 @@ namespace ET build = unit.GetOrAddComponent().AddChild(); build.Position.x = construct.X; build.Position.y = construct.Y; + build.ConfigId = construct.Config.MixtureID; //如果是农场 if (build.Config.Special == (int)StructureSpecialEnum.FARMLAND) { @@ -166,7 +168,7 @@ namespace ET } } - build.ConfigId = construct.Config.MixtureID; + StructureConfig structureConfig = StructureConfigCategory.Instance.Get(build.ConfigId); if (structureConfig != null) { diff --git a/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs b/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs index 797e4cf..01e74b1 100644 --- a/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs +++ b/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs @@ -19,7 +19,7 @@ namespace ET self.Id = peopleProto.Id; self.Name = peopleProto.Name; self.ConfigId = peopleProto.ConfigId; - self.LaborLevel = peopleProto.LaborLevel; + self.Labor = peopleProto.LaborLevel; self.LaborExp = peopleProto.LaborExp; self.Level = peopleProto.Level; self.Exp = peopleProto.Exp; @@ -45,7 +45,7 @@ namespace ET peopleProto.Id = self.Id; peopleProto.Name = self.Name; peopleProto.ConfigId = self.ConfigId; - peopleProto.LaborLevel = self.LaborLevel; + peopleProto.LaborLevel = self.Labor; peopleProto.LaborExp = self.LaborExp; peopleProto.Level = self.Level; peopleProto.Exp = self.Exp; @@ -146,6 +146,7 @@ namespace ET return nc.GetAsInt(NumericType.Labor); } + //建造相关 public static int GetLaborWithCoefficient(this People self) { int labor = self.GetLabor(); @@ -153,6 +154,15 @@ namespace ET return labor * laborCoefficientBuild; } + //农民类型才会成长 + public static void GrowUp(this People self) + { + if (self.PeopleType != (int)RoleTypeEnum.VILLAGERS) + { + return; + } + } + } } diff --git a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs index cb7b5b6..122c713 100644 --- a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs @@ -156,9 +156,8 @@ namespace ET return; } self.Season = self.SeasonConfig.Id; -#if SERVER UnitHelper.NofityUpdateValley(self, new List { NumericType.Season }, new List { self.Season }); -#endif + //如果是春天,长大一岁 } public static void SetEmbattle(this Unit self, Dictionary FighterDic) diff --git a/Unity/Codes/Model/Demo/People/People.cs b/Unity/Codes/Model/Demo/People/People.cs index 7f8886b..df458bb 100644 --- a/Unity/Codes/Model/Demo/People/People.cs +++ b/Unity/Codes/Model/Demo/People/People.cs @@ -11,9 +11,9 @@ namespace ET public class People: Entity, IAwake, ISerializeToEntity { public string Name; - public int ConfigId; - public int LaborLevel; - public int LaborExp; + public int ConfigId; + public int Labor; //劳力值,受年龄段限制 + public int LaborExp; //劳力经验 public int Exp; public int Level; public int Age; @@ -22,6 +22,13 @@ namespace ET public int CurrSkillId; public float PosX; public float PosY; + public int Disease; //疾病值 + public int PeopleType; //主角,伙伴,村民 + public int Gender; //性别 + public int Life; //生命 + public int Wisdom; //智慧 + public int MoveSpeed; //移动速度 + [BsonIgnore] public RoleConfig Config => RoleConfigCategory.Instance.Get(this.ConfigId); diff --git a/Unity/Codes/Model/Generate/Message/OuterMessage.cs b/Unity/Codes/Model/Generate/Message/OuterMessage.cs index 7143b05..e4be3c4 100644 --- a/Unity/Codes/Model/Generate/Message/OuterMessage.cs +++ b/Unity/Codes/Model/Generate/Message/OuterMessage.cs @@ -2576,4 +2576,32 @@ namespace ET } + [ResponseType(nameof(M2C_ConstructFinish))] + [Message(OuterOpcode.C2M_ConstructFinish)] + [ProtoContract] + public partial class C2M_ConstructFinish: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public long ConstructId { get; set; } + + } + + [Message(OuterOpcode.M2C_ConstructFinish)] + [ProtoContract] + public partial class M2C_ConstructFinish: Object, IActorLocationResponse + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(91)] + public int Error { get; set; } + + [ProtoMember(92)] + public string Message { get; set; } + + } + } diff --git a/Unity/Codes/Model/Generate/Message/OuterOpcode.cs b/Unity/Codes/Model/Generate/Message/OuterOpcode.cs index 2639765..d2e3bbd 100644 --- a/Unity/Codes/Model/Generate/Message/OuterOpcode.cs +++ b/Unity/Codes/Model/Generate/Message/OuterOpcode.cs @@ -152,5 +152,7 @@ namespace ET public const ushort M2C_FarmlandPlant = 10149; public const ushort C2M_FarmlandHarvest = 10150; public const ushort M2C_FarmlandHarvest = 10151; + public const ushort C2M_ConstructFinish = 10152; + public const ushort M2C_ConstructFinish = 10153; } }