From 7255ef175512e44a7a77ec050d47b7038e8532ed Mon Sep 17 00:00:00 2001 From: wserver/wangdisen <1065498738@qq.com> Date: Tue, 16 Aug 2022 13:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0FarmlandDic=E7=9A=84=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Proto/OuterMessage.proto | 13 ++++++++ Server/Hotfix/Demo/Unit/UnitFactory.cs | 15 +++++++++ Server/Model/Generate/Message/OuterMessage.cs | 31 +++++++++++++++++++ Server/Model/Generate/Message/OuterOpcode.cs | 2 ++ .../Hotfix/Demo/Farmland/FarmlandSystem.cs | 2 +- Unity/Codes/Hotfix/Demo/Helper/CheatHelper.cs | 31 ++++++++++++++++--- .../Codes/Hotfix/Demo/People/PeopleSystem.cs | 18 ++++++++++- .../Model/Generate/Message/OuterMessage.cs | 31 +++++++++++++++++++ .../Model/Generate/Message/OuterOpcode.cs | 2 ++ 9 files changed, 139 insertions(+), 6 deletions(-) diff --git a/Proto/OuterMessage.proto b/Proto/OuterMessage.proto index fb8077a..b8f9c15 100644 --- a/Proto/OuterMessage.proto +++ b/Proto/OuterMessage.proto @@ -1271,4 +1271,17 @@ message M2C_ChangeBehave // IActorLocationResponse } +//ResponseType M2C_CheatItemList +message C2M_CheatItemList // IActorLocationRequest +{ + int32 RpcId = 90; + repeated int32 ConfigIds = 1; + repeated int32 Nums = 2; +} +message M2C_CheatItemList // IActorLocationResponse +{ + int32 RpcId = 90; + int32 Error = 91; + string Message = 92; +} diff --git a/Server/Hotfix/Demo/Unit/UnitFactory.cs b/Server/Hotfix/Demo/Unit/UnitFactory.cs index 0fade23..701f109 100644 --- a/Server/Hotfix/Demo/Unit/UnitFactory.cs +++ b/Server/Hotfix/Demo/Unit/UnitFactory.cs @@ -57,6 +57,7 @@ namespace ET unit.SeasonConfig = SeasonConfigCategory.Instance.Get(unit.Season); unitComponent.AddChild(unit); + InitNoDb(unit); } else { @@ -193,5 +194,19 @@ namespace ET menuComponent.Add(v, 0); }*/ } + + public static void InitNoDb(Unit unit) + { + foreach (var v in unit.GetComponent().Children.Values) + { + foreach (var c in v.Children.Values) + { + if (c.GetType() == typeof (Farmland)) + { + unit.FarmlandDic[c.Id] = (Farmland) c; + } + } + } + } } } \ No newline at end of file diff --git a/Server/Model/Generate/Message/OuterMessage.cs b/Server/Model/Generate/Message/OuterMessage.cs index f9d633c..5a35482 100644 --- a/Server/Model/Generate/Message/OuterMessage.cs +++ b/Server/Model/Generate/Message/OuterMessage.cs @@ -2650,4 +2650,35 @@ namespace ET } + [ResponseType(nameof(M2C_CheatItemList))] + [Message(OuterOpcode.C2M_CheatItemList)] + [ProtoContract] + public partial class C2M_CheatItemList: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public List ConfigIds = new List(); + + [ProtoMember(2)] + public List Nums = new List(); + + } + + [Message(OuterOpcode.M2C_CheatItemList)] + [ProtoContract] + public partial class M2C_CheatItemList: 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 cc51059..bb6bbe3 100644 --- a/Server/Model/Generate/Message/OuterOpcode.cs +++ b/Server/Model/Generate/Message/OuterOpcode.cs @@ -156,5 +156,7 @@ namespace ET public const ushort M2C_FarmlandSeed = 10153; public const ushort C2M_ChangeBehave = 10154; public const ushort M2C_ChangeBehave = 10155; + public const ushort C2M_CheatItemList = 10156; + public const ushort M2C_CheatItemList = 10157; } } diff --git a/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs b/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs index 56e556b..d8c419b 100644 --- a/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs @@ -12,7 +12,7 @@ { public override void Awake(Farmland self) { - self.Parent.Parent.GetParent().AddFarmland(self); + } } diff --git a/Unity/Codes/Hotfix/Demo/Helper/CheatHelper.cs b/Unity/Codes/Hotfix/Demo/Helper/CheatHelper.cs index 42d3367..bae68a2 100644 --- a/Unity/Codes/Hotfix/Demo/Helper/CheatHelper.cs +++ b/Unity/Codes/Hotfix/Demo/Helper/CheatHelper.cs @@ -1,8 +1,9 @@ using System; +using System.Collections.Generic; namespace ET { - [FriendClass(typeof(Unit))] + [FriendClass(typeof (Unit))] public static class CheatHelper { public static async ETTask AddItem(Unit unit, int id, int type, uint num) @@ -22,18 +23,18 @@ namespace ET } else { - storeComponent.Remove(id, (int)Math.Abs(num)); + storeComponent.Remove(id, (int) Math.Abs(num)); } } else if (type == 2) { if (id == NumericType.Water) { - unit.Water += num; + unit.Water += num; } else if (id == NumericType.Food) { - unit.Food += num; + unit.Food += num; } else if (id == NumericType.SilverTael) { @@ -109,5 +110,27 @@ namespace ET throw; } } + + public static async ETTask AddItemList(Unit unit, List configIds, List nums) + { + try + { + C2M_CheatItemList msg = new C2M_CheatItemList() { ConfigIds = configIds, Nums = nums }; + M2C_CheatItemList resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CheatItemList; + if (resp.Error == ErrorCode.ERR_Success) + { + for (int i = 0; i < configIds.Count; i++) + { + unit.GetComponent().Add(configIds[i], nums[i]); + } + } + return resp.Error; + } + catch (Exception e) + { + Log.Error(e.ToString()); + throw; + } + } } } \ No newline at end of file diff --git a/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs b/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs index d4aaa9f..aa90b09 100644 --- a/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs +++ b/Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs @@ -165,7 +165,23 @@ namespace ET self.Age += 1; } - //public static void Add + + //增加体质经验 + public static void AddPhysiqueExp(this People self, int exp) + { + + } + + //增加寿命经验 + public static void AddLifeExp(this People self, int exp) + { + + } + //增加劳力经验 + public static void AddLaborExp(this People self, int exp) + { + + } } diff --git a/Unity/Codes/Model/Generate/Message/OuterMessage.cs b/Unity/Codes/Model/Generate/Message/OuterMessage.cs index f9d633c..5a35482 100644 --- a/Unity/Codes/Model/Generate/Message/OuterMessage.cs +++ b/Unity/Codes/Model/Generate/Message/OuterMessage.cs @@ -2650,4 +2650,35 @@ namespace ET } + [ResponseType(nameof(M2C_CheatItemList))] + [Message(OuterOpcode.C2M_CheatItemList)] + [ProtoContract] + public partial class C2M_CheatItemList: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public List ConfigIds = new List(); + + [ProtoMember(2)] + public List Nums = new List(); + + } + + [Message(OuterOpcode.M2C_CheatItemList)] + [ProtoContract] + public partial class M2C_CheatItemList: 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 cc51059..bb6bbe3 100644 --- a/Unity/Codes/Model/Generate/Message/OuterOpcode.cs +++ b/Unity/Codes/Model/Generate/Message/OuterOpcode.cs @@ -156,5 +156,7 @@ namespace ET public const ushort M2C_FarmlandSeed = 10153; public const ushort C2M_ChangeBehave = 10154; public const ushort M2C_ChangeBehave = 10155; + public const ushort C2M_CheatItemList = 10156; + public const ushort M2C_CheatItemList = 10157; } }