From 772a9f772a42a6c4b5fc2efef9c89fce01fd4124 Mon Sep 17 00:00:00 2001 From: wserver/wangdisen <1065498738@qq.com> Date: Mon, 15 Aug 2022 18:02:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A7=8D=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hotfix/Demo/Farmland/FarmlandSystem.cs | 17 ++++++------ .../Hotfix/Demo/Helper/FarmlandHelper.cs | 18 +++++++++++-- .../Hotfix/Demo/Operate/FarmlandOperate.cs | 2 +- .../Hotfix/Demo/Operate/PeopleOperate.cs | 2 +- Unity/Codes/Model/Demo/ConstValue.cs | 7 +++-- Unity/Codes/Model/Demo/Farmland/Farmland.cs | 7 +++-- Unity/Codes/Model/Demo/People/People.cs | 26 ++++++++++++++----- 7 files changed, 54 insertions(+), 25 deletions(-) diff --git a/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs b/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs index 055970d..c3523c7 100644 --- a/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs @@ -29,10 +29,10 @@ public static void FromMessage(this Farmland self, FarmlandProto farmlandProto) { self.Id = farmlandProto.id; - self.SeedCfgId = farmlandProto.SeedCfgId; + self.CropCfgId = farmlandProto.SeedCfgId; self.Duration = farmlandProto.duration; self.ExProduct = farmlandProto.exProduct; - self.PlanSeedCfgId = farmlandProto.plantCfgId; + self.PlanCropCfgId = farmlandProto.plantCfgId; self.FarmlandState = farmlandProto.farmlandState; } @@ -40,10 +40,10 @@ { FarmlandProto proto = new FarmlandProto(); proto.id = self.Id; - proto.SeedCfgId = self.SeedCfgId; + proto.SeedCfgId = self.CropCfgId; proto.duration = self.Duration; proto.exProduct = self.ExProduct; - proto.plantCfgId = self.PlanSeedCfgId; + proto.plantCfgId = self.PlanCropCfgId; proto.farmlandState = self.FarmlandState; return proto; } @@ -72,18 +72,17 @@ public static void Harvest(this Farmland self) { self.Duration = 0; - self.SeedCfgId = 0; - self.PlanSeedCfgId = 0; + self.CropCfgId = 0; self.ExProduct = 0; self.FarmlandState = FarmlandState.FARMLAND_STATE_FREE; } - public static void Seed(this Farmland self,int seedCfgId) + public static void Seed(this Farmland self,int cropCfgId) { - self.SeedCfgId = seedCfgId; + self.CropCfgId = cropCfgId; self.FarmlandState = FarmlandState.FARMLAND_STATE_SEED; - self.PlanSeedCfgId = seedCfgId; + self.PlanCropCfgId = cropCfgId; } diff --git a/Unity/Codes/Hotfix/Demo/Helper/FarmlandHelper.cs b/Unity/Codes/Hotfix/Demo/Helper/FarmlandHelper.cs index 87f4344..8dede60 100644 --- a/Unity/Codes/Hotfix/Demo/Helper/FarmlandHelper.cs +++ b/Unity/Codes/Hotfix/Demo/Helper/FarmlandHelper.cs @@ -28,7 +28,7 @@ namespace ET throw; } } - public static async ETTask FarmlandPlant(Unit unit, long farmlandId, int cropId) + public static async ETTask FarmlandPlant(Unit unit, long farmlandId) { try { @@ -76,6 +76,20 @@ namespace ET } } - + public static async ETTask FarmlandPlantFinish(Unit unit,long peopleId) + { + return await PeopleHelper.ChangeBehave(unit, peopleId, 0, ConstBehaveType.BEHAVE_IDLE); + } + + public static async ETTask FarmlandHarvestFinish(Unit unit,long peopleId) + { + return await PeopleHelper.ChangeBehave(unit, peopleId, 0, ConstBehaveType.BEHAVE_IDLE); + } + + + + + + } } \ 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 dea82cd..0268d9e 100644 --- a/Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs +++ b/Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs @@ -37,7 +37,7 @@ namespace ET storeNc.Add(farmland.Config.ByProduct, farmland.Config.ByProductNum); } - storeNc.Add(farmland.SeedCfgId, farmland.Config.SeedProduce); + storeNc.Add(farmland.CropCfgId, farmland.Config.SeedProduce); farmland.Harvest(); return ErrorCode.ERR_Success; } diff --git a/Unity/Codes/Hotfix/Demo/Operate/PeopleOperate.cs b/Unity/Codes/Hotfix/Demo/Operate/PeopleOperate.cs index 6b18686..66f3edf 100644 --- a/Unity/Codes/Hotfix/Demo/Operate/PeopleOperate.cs +++ b/Unity/Codes/Hotfix/Demo/Operate/PeopleOperate.cs @@ -46,7 +46,7 @@ namespace ET } people.TargetId = targetId; - people.BehaveType = behaveType; + people.SetBehaveType(behaveType); return ErrorCode.ERR_Success; } } diff --git a/Unity/Codes/Model/Demo/ConstValue.cs b/Unity/Codes/Model/Demo/ConstValue.cs index 4800116..f6c9f60 100644 --- a/Unity/Codes/Model/Demo/ConstValue.cs +++ b/Unity/Codes/Model/Demo/ConstValue.cs @@ -31,8 +31,11 @@ namespace ET public const int BEHAVE_GATHER = 2; //正在采集 public const int BEHAVE_PREPARE_CONSTRUCT = 3; //去建造 public const int BEHAVE_CONSTRUCT = 4; //建造 - public const int BEHAVE_PLANT = 5; //种植 - public const int BEHAVE_Harvest = 6;//收获 + public const int BEHAVE_PREPARE_PLANT = 5; //去种植 + public const int BEHAVE_PLANT = 6; //正在种植 + public const int BEHAVE_PREPARE_HARVEST = 7;//去收割 + public const int BEHAVE_HARVEST = 8;//收割 + } public static class ConstPeopleType diff --git a/Unity/Codes/Model/Demo/Farmland/Farmland.cs b/Unity/Codes/Model/Demo/Farmland/Farmland.cs index 5266eb5..bd050f9 100644 --- a/Unity/Codes/Model/Demo/Farmland/Farmland.cs +++ b/Unity/Codes/Model/Demo/Farmland/Farmland.cs @@ -5,15 +5,14 @@ namespace ET { public class Farmland: Entity, IAwake,IUpdate, IDestroy,ISerializeToEntity { - public int SeedCfgId; //农作物configid + public int CropCfgId; //农作物configid public int Duration; //种植时间 public int ExProduct; //额外产量 public int FarmlandState; //农田状态 - public int PlanSeedCfgId; //计划种植的东西 - public int ConfigId; + public int PlanCropCfgId; //计划种植的东西 [BsonIgnore] - public CropConfig Config =>CropConfigCategory.Instance.Get(this.ConfigId); + public CropConfig Config =>CropConfigCategory.Instance.Get(this.CropCfgId); } diff --git a/Unity/Codes/Model/Demo/People/People.cs b/Unity/Codes/Model/Demo/People/People.cs index 83ef42a..e78692d 100644 --- a/Unity/Codes/Model/Demo/People/People.cs +++ b/Unity/Codes/Model/Demo/People/People.cs @@ -11,15 +11,15 @@ namespace ET public class People: Entity, IAwake, ISerializeToEntity { public string Name; - public int ConfigId; - public int Labor; //劳力值,受年龄段限制 - public int LaborExp; //劳力经验 - public int Physique; //体质 + public int ConfigId; + public int Labor; //劳力值,受年龄段限制 + public int LaborExp; //劳力经验 + public int Physique; //体质 public int PhysiqueExp; //体质经验 public int Exp; public int Level; public int Age; - public int BehaveType; + public long TargetId; public int CurrSkillId; public float PosX; @@ -30,7 +30,21 @@ namespace ET public int Life; //生命 public int Wisdom; //智慧 public int MoveSpeed; //移动速度 - + + public int BehaveType + { + set + { + this.BehaveType = value; +#if !SERVER + Game.EventSystem.Publish(new EventType.BehaveTypeChanged() { People = this }); +#endif + } + get + { + return this.BehaveType; + } + } [BsonIgnore] public RoleConfig Config => RoleConfigCategory.Instance.Get(this.ConfigId);