From fa3ec6f467dac4a9b143752f72effa67f66aa16b Mon Sep 17 00:00:00 2001 From: wserver/wangdisen <1065498738@qq.com> Date: Wed, 24 Aug 2022 13:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E5=B1=8B=E6=94=B6?= =?UTF-8?q?=E5=89=B2=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=B0=8F=E5=B1=8B=E6=92=AD=E7=A7=8D=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Proto/OuterMessage.proto | 13 +++++++ .../Cabin/Handler/C2M_CabinHarvestHandler.cs | 35 +++++++++++++++++++ Server/Model/Base/MongoRegister.cs | 2 ++ Server/Model/Generate/Message/OuterMessage.cs | 28 +++++++++++++++ Server/Model/Generate/Message/OuterOpcode.cs | 2 ++ Server/Model/Server.Model.csproj | 4 +++ Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs | 26 +++++++++++++- .../Codes/Hotfix/Demo/Operate/CabinOperate.cs | 33 +++++++++++++++++ .../Hotfix/Demo/Operate/FarmlandOperate.cs | 1 + Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs | 2 +- Unity/Codes/Model/Demo/Weather/Weather.cs | 28 +++++++++++++++ .../Model/Generate/Message/OuterMessage.cs | 28 +++++++++++++++ .../Model/Generate/Message/OuterOpcode.cs | 2 ++ 13 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 Server/Hotfix/Demo/Cabin/Handler/C2M_CabinHarvestHandler.cs create mode 100644 Unity/Codes/Model/Demo/Weather/Weather.cs diff --git a/Proto/OuterMessage.proto b/Proto/OuterMessage.proto index fc0fc7c..f93cef3 100644 --- a/Proto/OuterMessage.proto +++ b/Proto/OuterMessage.proto @@ -1429,3 +1429,16 @@ message M2C_CabinUpdateFarmlands // IActorLocationResponse } +//ResponseType M2C_CabinHarvest +message C2M_CabinHarvest // IActorLocationRequest +{ + int32 RpcId = 90; + int64 FarmlandId = 1; +} + +message M2C_CabinHarvest // IActorLocationResponse +{ + int32 RpcId = 90; + int32 Error = 91; + string Message = 92; +} \ No newline at end of file diff --git a/Server/Hotfix/Demo/Cabin/Handler/C2M_CabinHarvestHandler.cs b/Server/Hotfix/Demo/Cabin/Handler/C2M_CabinHarvestHandler.cs new file mode 100644 index 0000000..93d99b1 --- /dev/null +++ b/Server/Hotfix/Demo/Cabin/Handler/C2M_CabinHarvestHandler.cs @@ -0,0 +1,35 @@ +using System; + +namespace ET +{ + + + public class C2M_CabinHarvestHandler: AMActorLocationRpcHandler + { + protected async override ETTask Run(Unit unit, C2M_CabinHarvest request, M2C_CabinHarvest response, Action reply) + { + try + { + Farmland farmland = unit.GetGrandChild(request.FarmlandId); + if (farmland == null) + { + response.Error = ErrorCode.ERR_FarmlandNotFound; + } + else + { + response.Error = CabinOperate.CabinHarvest(unit, farmland); + 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/Model/Base/MongoRegister.cs b/Server/Model/Base/MongoRegister.cs index 4aa9e6e..15e38d7 100644 --- a/Server/Model/Base/MongoRegister.cs +++ b/Server/Model/Base/MongoRegister.cs @@ -22,11 +22,13 @@ namespace ET BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(ExtraOut), new StructBsonSerialize()); + BsonSerializer.RegisterSerializer(typeof(WatherInfo), new StructBsonSerialize()); #elif ROBOT BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(Vector4), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize()); + BsonSerializer.RegisterSerializer(typeof(ExtraOut), new StructBsonSerialize()); #else BsonSerializer.RegisterSerializer(typeof (Vector4), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof (Vector3), new StructBsonSerialize()); diff --git a/Server/Model/Generate/Message/OuterMessage.cs b/Server/Model/Generate/Message/OuterMessage.cs index 8830152..b9f2d4f 100644 --- a/Server/Model/Generate/Message/OuterMessage.cs +++ b/Server/Model/Generate/Message/OuterMessage.cs @@ -2971,4 +2971,32 @@ namespace ET } + [ResponseType(nameof(M2C_CabinHarvest))] + [Message(OuterOpcode.C2M_CabinHarvest)] + [ProtoContract] + public partial class C2M_CabinHarvest: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public long FarmlandId { get; set; } + + } + + [Message(OuterOpcode.M2C_CabinHarvest)] + [ProtoContract] + public partial class M2C_CabinHarvest: 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 90191d7..115d4f6 100644 --- a/Server/Model/Generate/Message/OuterOpcode.cs +++ b/Server/Model/Generate/Message/OuterOpcode.cs @@ -177,5 +177,7 @@ namespace ET public const ushort M2C_CabinSeed = 10174; public const ushort C2M_CabinUpdateFarmlands = 10175; public const ushort M2C_CabinUpdateFarmlands = 10176; + public const ushort C2M_CabinHarvest = 10177; + public const ushort M2C_CabinHarvest = 10178; } } diff --git a/Server/Model/Server.Model.csproj b/Server/Model/Server.Model.csproj index 7a3178a..84c55c7 100644 --- a/Server/Model/Server.Model.csproj +++ b/Server/Model/Server.Model.csproj @@ -191,6 +191,10 @@ Demo\ValleyRandom.cs + + Weather\Weather.cs + + Generate\ConfigPartial\SkillUpConfig.cs diff --git a/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs b/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs index 879f2e8..9ab15a3 100644 --- a/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs +++ b/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs @@ -88,7 +88,7 @@ namespace ET M2C_CabinSeed resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CabinSeed; if (resp.Error == ErrorCode.ERR_Success) { - FarmlandOperate.FarmlandSeed(unit, farmland, cropCfgId); + CabinOperate.CabinSeed(unit, farmland, cropCfgId); } else { @@ -127,5 +127,29 @@ namespace ET throw; } } + + public static async ETTask CabinHarvest(Unit unit, Farmland farmland) + { + try + { + C2M_CabinHarvest msg = new C2M_CabinHarvest() { FarmlandId = farmland.Id}; + M2C_CabinHarvest resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CabinHarvest; + if (resp.Error == ErrorCode.ERR_Success) + { + CabinOperate.CabinHarvest(unit,farmland); + } + else + { + Log.Error(resp.Error.ToString()); + } + + 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/CabinOperate.cs b/Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs index 522ca4c..6baccf5 100644 --- a/Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs +++ b/Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs @@ -4,6 +4,7 @@ namespace ET { [FriendClass(typeof(People))] [FriendClass(typeof(Cabin))] + [FriendClass(typeof(Farmland))] public static class CabinOperate { public static void CabinUpdateFarmlands(Unit unit,Cabin cabin, List farmlandIds) @@ -28,5 +29,37 @@ namespace ET cabin.FarmlandIds = farmlandIds; } + + public static int CabinSeed(Unit unit, Farmland farmland, int CropCfgId) + { + var cropCfg = CropConfigCategory.Instance.Get(CropCfgId); + var sc = unit.GetComponent(); + if (sc.Remove(cropCfg.SeedNeed, cropCfg.SeedNum)) + { + farmland.Seed(cropCfg.Id); + farmland.Plant(); + return ErrorCode.ERR_Success; + } + + return ErrorCode.ERR_OperateFail; + } + + public static int CabinHarvest(Unit unit, Farmland farmland) + { + if (farmland.FarmlandState == FarmlandState.FARMLAND_STATE_RIPE) + { + var storeNc = unit.GetComponent(); + storeNc.Add(farmland.Config.ProductID, farmland.Config.BasicProduction); + if (farmland.Config.ByProduct > 0) + { + storeNc.Add(farmland.Config.ByProduct, farmland.Config.ByProductNum); + } + + storeNc.Add(farmland.CropCfgId, farmland.Config.SeedProduce); + farmland.Harvest(); + return ErrorCode.ERR_Success; + } + return ErrorCode.ERR_FarmlandNotRipe; + } } } \ No newline at end of file diff --git a/Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs b/Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs index b5806b8..67c7095 100644 --- a/Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs +++ b/Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs @@ -77,5 +77,6 @@ namespace ET return ErrorCode.ERR_OperateFail; } + } } \ No newline at end of file diff --git a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs index 3f7262c..4d0aff8 100644 --- a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs @@ -103,7 +103,7 @@ namespace ET Log.Info($"----------------day: {self.Day}, nightTime: {nightTime}"); self.Day++; self.updateSeason(); - time -= self.SeasonConfig.DayTime[0]; + time = self.SeasonConfig.DayTime[0]; self.EventSeed = 1; UnitOperate.NightEvent(self, nightTime, time); //每天长大一岁 diff --git a/Unity/Codes/Model/Demo/Weather/Weather.cs b/Unity/Codes/Model/Demo/Weather/Weather.cs new file mode 100644 index 0000000..ee8c968 --- /dev/null +++ b/Unity/Codes/Model/Demo/Weather/Weather.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; + +namespace ET +{ + public struct WatherInfo + { + public int ConfigId; + public int Cd; + public int StartTime; //game day + } + public class Weather:Entity,IAwake,ISerializeToEntity + { + public int ConfigId; + public int Times; //当前季节触发次数 + public int Cd; + public List SpringList; //春天列表 + public List SummerList; + public List AutumnList; + public List WinterList; + public int StartTime;//开始时间,游戏时间 + public int RealStartTime; //实际时间 + public int Duration; //持续 + + + + + } +} \ 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 8830152..b9f2d4f 100644 --- a/Unity/Codes/Model/Generate/Message/OuterMessage.cs +++ b/Unity/Codes/Model/Generate/Message/OuterMessage.cs @@ -2971,4 +2971,32 @@ namespace ET } + [ResponseType(nameof(M2C_CabinHarvest))] + [Message(OuterOpcode.C2M_CabinHarvest)] + [ProtoContract] + public partial class C2M_CabinHarvest: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public long FarmlandId { get; set; } + + } + + [Message(OuterOpcode.M2C_CabinHarvest)] + [ProtoContract] + public partial class M2C_CabinHarvest: 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 90191d7..115d4f6 100644 --- a/Unity/Codes/Model/Generate/Message/OuterOpcode.cs +++ b/Unity/Codes/Model/Generate/Message/OuterOpcode.cs @@ -177,5 +177,7 @@ namespace ET public const ushort M2C_CabinSeed = 10174; public const ushort C2M_CabinUpdateFarmlands = 10175; public const ushort M2C_CabinUpdateFarmlands = 10176; + public const ushort C2M_CabinHarvest = 10177; + public const ushort M2C_CabinHarvest = 10178; } }