Browse Source

修改种植

master
wserver/wangdisen 3 years ago
parent
commit
772a9f772a
  1. 17
      Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs
  2. 18
      Unity/Codes/Hotfix/Demo/Helper/FarmlandHelper.cs
  3. 2
      Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs
  4. 2
      Unity/Codes/Hotfix/Demo/Operate/PeopleOperate.cs
  5. 7
      Unity/Codes/Model/Demo/ConstValue.cs
  6. 7
      Unity/Codes/Model/Demo/Farmland/Farmland.cs
  7. 26
      Unity/Codes/Model/Demo/People/People.cs

17
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;
}

18
Unity/Codes/Hotfix/Demo/Helper/FarmlandHelper.cs

@ -28,7 +28,7 @@ namespace ET
throw;
}
}
public static async ETTask<int> FarmlandPlant(Unit unit, long farmlandId, int cropId)
public static async ETTask<int> FarmlandPlant(Unit unit, long farmlandId)
{
try
{
@ -76,6 +76,20 @@ namespace ET
}
}
public static async ETTask<int> FarmlandPlantFinish(Unit unit,long peopleId)
{
return await PeopleHelper.ChangeBehave(unit, peopleId, 0, ConstBehaveType.BEHAVE_IDLE);
}
public static async ETTask<int> FarmlandHarvestFinish(Unit unit,long peopleId)
{
return await PeopleHelper.ChangeBehave(unit, peopleId, 0, ConstBehaveType.BEHAVE_IDLE);
}
}
}

2
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;
}

2
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;
}
}

7
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

7
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);
}

26
Unity/Codes/Model/Demo/People/People.cs

@ -11,15 +11,15 @@ namespace ET
public class People: Entity, IAwake<int>, 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);

Loading…
Cancel
Save