Browse Source

小屋相关逻辑

master
wserver/wangdisen 3 years ago
parent
commit
6023b9c9b4
  1. 5
      Config/StructureConfigCategory.bytes
  2. 1
      Excel/Json/c/StructureConfig.txt
  3. 1
      Excel/Json/s/StructureConfig.txt
  4. BIN
      Excel/StructureConfig.xlsx
  5. 77
      Proto/OuterMessage.proto
  6. 51
      Server/Hotfix/Demo/Cabin/Handler/C2M_ArriveCabinHandler.cs
  7. 52
      Server/Hotfix/Demo/Cabin/Handler/C2M_CabinAddFarmlandHandler.cs
  8. 53
      Server/Hotfix/Demo/Cabin/Handler/C2M_CabinSeedHandler.cs
  9. 43
      Server/Hotfix/Demo/Cabin/Handler/C2M_GoCabinHandler.cs
  10. 13
      Server/Hotfix/Demo/Farmland/Handler/C2M_FarmlandSeedHandler.cs
  11. 11
      Server/Hotfix/Demo/Gather/Handler/C2M_StopGatherHandler.cs
  12. 3
      Server/Hotfix/Server.Hotfix.csproj
  13. 2
      Server/Model/Generate/ConfigEnum.cs
  14. 155
      Server/Model/Generate/Message/OuterMessage.cs
  15. 9
      Server/Model/Generate/Message/OuterOpcode.cs
  16. 8
      Server/Model/Server.Model.csproj
  17. 11
      Unity/Animancer.FSM.csproj
  18. 11
      Unity/Animancer.csproj
  19. 5
      Unity/Assets/Bundles/Config/StructureConfigCategory.bytes
  20. 17
      Unity/Codes/Hotfix/Demo/Building/BuildingSystem.cs
  21. 54
      Unity/Codes/Hotfix/Demo/Cabin/CabinSystem.cs
  22. 20
      Unity/Codes/Hotfix/Demo/Construct/ConstructSystem.cs
  23. 7
      Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs
  24. 32
      Unity/Codes/Hotfix/Demo/Gather/GatherSystem.cs
  25. 107
      Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs
  26. 6
      Unity/Codes/Hotfix/Demo/Helper/FarmlandHelper.cs
  27. 2
      Unity/Codes/Hotfix/Demo/Helper/GatherHelper.cs
  28. 9
      Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs
  29. 18
      Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs
  30. 37
      Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs
  31. 50
      Unity/Codes/Hotfix/Demo/Operate/GatherOperate.cs
  32. 40
      Unity/Codes/Hotfix/Demo/Operate/PeopleOperate.cs
  33. 6
      Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs
  34. 2
      Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs
  35. 2
      Unity/Codes/Hotfix/Demo/Unit/UnitHelper.cs
  36. 19
      Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs
  37. 7
      Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIFarmlandWindowComponentSystem.cs
  38. 2
      Unity/Codes/Model/Demo/Building/Building.cs
  39. 13
      Unity/Codes/Model/Demo/Cabin/Cabin.cs
  40. 5
      Unity/Codes/Model/Demo/Common/GameUtil.cs
  41. 2
      Unity/Codes/Model/Demo/ConstValue.cs
  42. 6
      Unity/Codes/Model/Demo/Farmland/Farmland.cs
  43. 2
      Unity/Codes/Model/Generate/ConfigEnum.cs
  44. 155
      Unity/Codes/Model/Generate/Message/OuterMessage.cs
  45. 9
      Unity/Codes/Model/Generate/Message/OuterOpcode.cs
  46. 3
      Unity/Codes/Model/Module/Message/ErrorCode.cs

5
Config/StructureConfigCategory.bytes

@ -123,4 +123,7 @@ Build_4013
Build_4013Ê武庄Ð
A®宗厅 Ä(0d8dh²
Build_4014¸Â
Build_4014Ê宗厅Ð
Build_4014Ê宗厅Ð
Q¯ ç”°é—´å°<EFBFBD>屋 Ä(0d8d@Hh²
Build_4015¸Â
Build_4015Ê ç”°é—´å°<EFBFBD>屋Ð

1
Excel/Json/c/StructureConfig.txt

@ -40,4 +40,5 @@
{"_t":"StructureConfig","_id":4012,"Name":"水车","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":0,"Function":0,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4012","CanMove":1,"Picture":"Build_4012","Describe":"水车","Remove":1},
{"_t":"StructureConfig","_id":4013,"Name":"武庄","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":0,"Function":0,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4013","CanMove":1,"Picture":"Build_4013","Describe":"武庄","Remove":1},
{"_t":"StructureConfig","_id":4014,"Name":"宗厅","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":0,"Function":0,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4014","CanMove":1,"Picture":"Build_4014","Describe":"宗厅","Remove":1},
{"_t":"StructureConfig","_id":4015,"Name":"田间小屋","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":7,"Function":5,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4015","CanMove":1,"Picture":"Build_4015","Describe":"田间小屋","Remove":1},
]}

1
Excel/Json/s/StructureConfig.txt

@ -40,4 +40,5 @@
{"_t":"StructureConfig","_id":4012,"Name":"水车","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":0,"Function":0,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4012","CanMove":1,"Picture":"Build_4012","Describe":"水车","Remove":1},
{"_t":"StructureConfig","_id":4013,"Name":"武庄","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":0,"Function":0,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4013","CanMove":1,"Picture":"Build_4013","Describe":"武庄","Remove":1},
{"_t":"StructureConfig","_id":4014,"Name":"宗厅","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":0,"Function":0,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4014","CanMove":1,"Picture":"Build_4014","Describe":"宗厅","Remove":1},
{"_t":"StructureConfig","_id":4015,"Name":"田间小屋","Type":4,"Durable":2500,"DurableCoefficient":1,"FirmCoinNum":100,"CompleteMoneyNum":100,"Special":7,"Function":5,"DwellNumber":0,"PoultryNum":0,"Comfortable":0,"Boom":20,"UpgradeSequence":0,"State":0,"StateAffection":0,"SpecificPoint":0,"ON_OFF":0,"AtcFrequency":0,"Atc":0,"TargetNum":0,"Prefab":"Build_4015","CanMove":1,"Picture":"Build_4015","Describe":"田间小屋","Remove":1},
]}

BIN
Excel/StructureConfig.xlsx

Binary file not shown.

77
Proto/OuterMessage.proto

@ -67,6 +67,7 @@ message BuildingProto
int32 Durable = 5;
FarmlandProto Farmland = 6;
int32 IsUpgrade = 7;
CabinProto Cabin = 8;
}
message PeopleProto
@ -1242,8 +1243,8 @@ message M2C_FarmlandHarvest // IActorLocationResponse
message C2M_FarmlandSeed // IActorLocationRequest
{
int32 RpcId = 90;
repeated int64 FarmlandIds = 1;
repeated int32 CropCfgIds = 2;
int64 FarmlandId = 1;
int32 CropCfgId = 2;
}
message M2C_FarmlandSeed // IActorLocationResponse
@ -1251,8 +1252,7 @@ message M2C_FarmlandSeed // IActorLocationResponse
int32 RpcId = 90;
int32 Error = 91;
string Message = 92;
repeated int64 FarmlandIds = 1;
repeated int32 CropCfgIds = 2;
}
//ResponseType M2C_ChangeBehave
@ -1341,3 +1341,72 @@ message M2C_NtfFarmlandRipeProgress // IActorMessage
repeated int64 FarmlandIds = 1;
repeated int32 Progresses = 2;
}
message CabinProto
{
int64 Id = 1;
int64 PeopleId = 2;
repeated int64 FarmlandIds = 3;
int32 ResidentState = 4;
}
//ResponseType M2C_GoCabin
message C2M_GoCabin // IActorLocationRequest
{
int32 RpcId = 90;
int64 PeopleId = 1 ;
int64 CabinId = 2;
}
message M2C_GoCabin // IActorLocationResponse
{
int32 RpcId = 90;
int32 Error = 91;
string Message = 92;
}
//ResponseType M2C_ArriveCabin
message C2M_ArriveCabin // IActorLocationRequest
{
int32 RpcId = 90;
int64 PeopleId = 1 ;
int64 CabinId = 2;
}
message M2C_ArriveCabin // IActorLocationResponse
{
int32 RpcId = 90;
int32 Error = 91;
string Message = 92;
}
//ResponseType M2C_CabinAddFarmland
message C2M_CabinAddFarmland // IActorLocationRequest
{
int32 RpcId = 90;
int64 FarmlandId = 1 ;
int64 CabinId = 2;
}
message M2C_CabinAddFarmland // IActorLocationResponse
{
int32 RpcId = 90;
int32 Error = 91;
string Message = 92;
}
//ResponseType M2C_CabinSeed
message C2M_CabinSeed // IActorLocationRequest
{
int32 RpcId = 90;
int64 FarmlandId = 1;
int32 CropCfgId = 2;
}
message M2C_CabinSeed // IActorLocationResponse
{
int32 RpcId = 90;
int32 Error = 91;
string Message = 92;
}

51
Server/Hotfix/Demo/Cabin/Handler/C2M_ArriveCabinHandler.cs

@ -0,0 +1,51 @@
using System;
namespace ET
{
public class C2M_ArriveCabinHandler: AMActorLocationRpcHandler<Unit, C2M_ArriveCabin, M2C_ArriveCabin>
{
protected async override ETTask Run(Unit unit, C2M_ArriveCabin request, M2C_ArriveCabin response, Action reply)
{
try
{
var people = unit.GetComponent<PeopleComponent>().GetChild<People>(request.PeopleId);
if (people == null)
{
response.Error = ErrorCode.ERR_PeopleNotFound;
}
else
{
var cabin = unit.GetGrandChild<Cabin>(request.CabinId);
if (cabin == null)
{
response.Error = ErrorCode.ERR_CabinNotFound;
}
else
{
if (cabin.PeopleArrive(request.PeopleId))
{
people.SetBehaveType(ConstBehaveType.BEHAVE_CABIN);
response.Error = ErrorCode.ERR_Success;
}
else
{
response.Error = ErrorCode.ERR_ArriveCabinFail;
}
}
}
reply();
}
catch (Exception e)
{
response.Message = e.ToString();
response.Error = ErrorCode.ERR_OperateFail;
reply();
}
await ETTask.CompletedTask;
}
}
}

52
Server/Hotfix/Demo/Cabin/Handler/C2M_CabinAddFarmlandHandler.cs

@ -0,0 +1,52 @@
using System;
namespace ET
{
public class C2M_CabinAddFarmlandHandler: AMActorLocationRpcHandler<Unit, C2M_CabinAddFarmland, M2C_CabinAddFarmland>
{
protected async override ETTask Run(Unit unit, C2M_CabinAddFarmland request, M2C_CabinAddFarmland response, Action reply)
{
try
{
var farmland = unit.GetGrandChild<Farmland>(request.FarmlandId);
if (farmland == null)
{
response.Error = ErrorCode.ERR_FarmlandNotFound;
}
else
{
var cabin = unit.GetGrandChild<Cabin>(request.CabinId);
if (cabin == null)
{
response.Error = ErrorCode.ERR_CabinNotFound;
}
else
{
if (cabin.AddFarmland(request.FarmlandId))
{
farmland.SetCabinId(request.CabinId);
response.Error = ErrorCode.ERR_Success;
}
else
{
response.Error = ErrorCode.ERR_OperateFail;
}
}
}
reply();
}
catch (Exception e)
{
response.Message = e.ToString();
response.Error = ErrorCode.ERR_OperateFail;
reply();
}
await ETTask.CompletedTask;
}
}
}

53
Server/Hotfix/Demo/Cabin/Handler/C2M_CabinSeedHandler.cs

@ -0,0 +1,53 @@
using System;
namespace ET
{
[FriendClass(typeof (Farmland))]
[FriendClass(typeof (Cabin))]
public class C2M_CabinSeedHandler: AMActorLocationRpcHandler<Unit, C2M_CabinSeed, M2C_CabinSeed>
{
protected async override ETTask Run(Unit unit, C2M_CabinSeed request, M2C_CabinSeed res, Action reply)
{
try
{
res.Error = ErrorCode.ERR_Success;
var farmland = unit.GetGrandChild<Farmland>(request.FarmlandId);
if (GameUtil.IsErrorSuc(res.Error) && farmland == null)
{
res.Error = ErrorCode.ERR_PeopleNotFound;
}
var cabin = unit.GetGrandChild<Cabin>(farmland.CabinId);
if (GameUtil.IsErrorSuc(res.Error) && cabin == null)
{
res.Error = ErrorCode.ERR_CabinNotFound;
}
if (GameUtil.IsErrorSuc(res.Error) && cabin.ResidentState == 0)
{
res.Error = ErrorCode.ERR_CabinNotPeople;
}
if (GameUtil.IsErrorSuc(res.Error) && farmland.FarmlandState != FarmlandState.FARMLAND_STATE_FREE)
{
res.Error = ErrorCode.ERR_FarmlandNotFree;
}
if (GameUtil.IsErrorSuc(res.Error))
{
res.Error = FarmlandOperate.FarmlandSeed(unit, farmland, request.CropCfgId);
}
reply();
}
catch (Exception e)
{
res.Message = e.ToString();
res.Error = ErrorCode.ERR_OperateFail;
reply();
}
await ETTask.CompletedTask;
}
}
}

43
Server/Hotfix/Demo/Cabin/Handler/C2M_GoCabinHandler.cs

@ -0,0 +1,43 @@
using System;
namespace ET
{
public class C2M_GoCabinHandler: AMActorLocationRpcHandler<Unit, C2M_GoCabin, M2C_GoCabin>
{
protected async override ETTask Run(Unit unit, C2M_GoCabin request, M2C_GoCabin response, Action reply)
{
try
{
var people = unit.GetComponent<PeopleComponent>().GetChild<People>(request.PeopleId);
if (people == null)
{
response.Error = ErrorCode.ERR_PeopleNotFound;
}
else
{
var cabin = unit.GetGrandChild<Cabin>(request.CabinId);
if (cabin == null)
{
response.Error = ErrorCode.ERR_CabinNotFound;
}
else
{
PeopleOperate.ChangeBehave(unit, people, ConstBehaveType.BEHAVE_PREPARE_CABIN, request.CabinId);
cabin.PeoplePrepare(request.PeopleId);
response.Error = ErrorCode.ERR_Success;
}
}
reply();
}
catch (Exception e)
{
response.Message = e.ToString();
response.Error = ErrorCode.ERR_OperateFail;
reply();
}
await ETTask.CompletedTask;
}
}
}

13
Server/Hotfix/Demo/Farmland/Handler/C2M_FarmlandSeedHandler.cs

@ -8,8 +8,17 @@ namespace ET
{
try
{
(response.FarmlandIds, response.CropCfgIds) = FarmlandOperate.FarmlandSeed(unit, request.FarmlandIds, request.CropCfgIds);
response.Error = ErrorCode.ERR_Success;
Farmland farmland = unit.GetGrandChild<Farmland>(request.FarmlandId);
if (farmland == null)
{
response.Error = ErrorCode.ERR_FarmlandNotFound;
}
else
{
response.Error = FarmlandOperate.FarmlandSeed(unit, farmland, request.CropCfgId);
response.Error = ErrorCode.ERR_Success;
}
reply();
}
catch (Exception e)

11
Server/Hotfix/Demo/Gather/Handler/C2M_StopGatherHandler.cs

@ -11,7 +11,16 @@ namespace ET
{
try
{
response.Error = GatherOperate.StopGather(unit, request.GatherId, request.PeopleId);
var people = unit.GetComponent<PeopleComponent>().GetChild<People>(request.PeopleId);
if (people == null)
{
response.Error= ErrorCode.ERR_PeopleNotFound;
}
else
{
response.Error = PeopleOperate.StopBehave(unit, people);
}
reply();
}
catch (Exception e)

3
Server/Hotfix/Server.Hotfix.csproj

@ -34,6 +34,9 @@
<Compile Include="..\..\Unity\Codes\Hotfix\Demo\Building\BuildingSystem.cs">
<Link>Demo\Building\BuildingSystem.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Codes\Hotfix\Demo\Cabin\CabinSystem.cs">
<Link>Demo\Cabin\CabinSystem.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Codes\Hotfix\Demo\Construct\ConstructComponentSystem.cs">
<Link>Demo\Construct\ConstructComponentSystem.cs</Link>
</Compile>

2
Server/Model/Generate/ConfigEnum.cs

@ -909,6 +909,8 @@ namespace ET
MAKINGMEDICINE = 5,
// 粮仓
GRANARY = 6,
// 田间小屋
FARM_CABIN = 7,
}
public enum StructureSpecificPointEnum
{

155
Server/Model/Generate/Message/OuterMessage.cs

@ -146,6 +146,9 @@ namespace ET
[ProtoMember(7)]
public int IsUpgrade { get; set; }
[ProtoMember(8)]
public CabinProto Cabin { get; set; }
}
[Message(OuterOpcode.PeopleProto)]
@ -2591,10 +2594,10 @@ namespace ET
public int RpcId { get; set; }
[ProtoMember(1)]
public List<long> FarmlandIds = new List<long>();
public long FarmlandId { get; set; }
[ProtoMember(2)]
public List<int> CropCfgIds = new List<int>();
public int CropCfgId { get; set; }
}
@ -2611,12 +2614,6 @@ namespace ET
[ProtoMember(92)]
public string Message { get; set; }
[ProtoMember(1)]
public List<long> FarmlandIds = new List<long>();
[ProtoMember(2)]
public List<int> CropCfgIds = new List<int>();
}
[ResponseType(nameof(M2C_ChangeBehave))]
@ -2795,4 +2792,146 @@ namespace ET
}
[Message(OuterOpcode.CabinProto)]
[ProtoContract]
public partial class CabinProto: Object
{
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public long PeopleId { get; set; }
[ProtoMember(3)]
public List<long> FarmlandIds = new List<long>();
[ProtoMember(4)]
public int ResidentState { get; set; }
}
[ResponseType(nameof(M2C_GoCabin))]
[Message(OuterOpcode.C2M_GoCabin)]
[ProtoContract]
public partial class C2M_GoCabin: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long PeopleId { get; set; }
[ProtoMember(2)]
public long CabinId { get; set; }
}
[Message(OuterOpcode.M2C_GoCabin)]
[ProtoContract]
public partial class M2C_GoCabin: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
[ResponseType(nameof(M2C_ArriveCabin))]
[Message(OuterOpcode.C2M_ArriveCabin)]
[ProtoContract]
public partial class C2M_ArriveCabin: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long PeopleId { get; set; }
[ProtoMember(2)]
public long CabinId { get; set; }
}
[Message(OuterOpcode.M2C_ArriveCabin)]
[ProtoContract]
public partial class M2C_ArriveCabin: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
[ResponseType(nameof(M2C_CabinAddFarmland))]
[Message(OuterOpcode.C2M_CabinAddFarmland)]
[ProtoContract]
public partial class C2M_CabinAddFarmland: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long FarmlandId { get; set; }
[ProtoMember(2)]
public long CabinId { get; set; }
}
[Message(OuterOpcode.M2C_CabinAddFarmland)]
[ProtoContract]
public partial class M2C_CabinAddFarmland: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
[ResponseType(nameof(M2C_CabinSeed))]
[Message(OuterOpcode.C2M_CabinSeed)]
[ProtoContract]
public partial class C2M_CabinSeed: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long FarmlandId { get; set; }
[ProtoMember(2)]
public int CropCfgId { get; set; }
}
[Message(OuterOpcode.M2C_CabinSeed)]
[ProtoContract]
public partial class M2C_CabinSeed: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
}

9
Server/Model/Generate/Message/OuterOpcode.cs

@ -166,5 +166,14 @@ namespace ET
public const ushort M2C_FarmlandRipe = 10163;
public const ushort M2C_NtfFarmlandRipe = 10164;
public const ushort M2C_NtfFarmlandRipeProgress = 10165;
public const ushort CabinProto = 10166;
public const ushort C2M_GoCabin = 10167;
public const ushort M2C_GoCabin = 10168;
public const ushort C2M_ArriveCabin = 10169;
public const ushort M2C_ArriveCabin = 10170;
public const ushort C2M_CabinAddFarmland = 10171;
public const ushort M2C_CabinAddFarmland = 10172;
public const ushort C2M_CabinSeed = 10173;
public const ushort M2C_CabinSeed = 10174;
}
}

8
Server/Model/Server.Model.csproj

@ -46,6 +46,14 @@
<Link>Demo\Building\Building.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Codes\Model\Demo\Cabin\Cabin.cs">
<Link>Demo\Cabin\Cabin.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Codes\Model\Demo\Common\GameUtil.cs">
<Link>Demo\Common\GameUtil.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Codes\Model\Demo\Config\SynthesisConfig.cs">
<Link>Demo\Config\SynthesisConfig.cs</Link>
</Compile>

11
Unity/Animancer.FSM.csproj

@ -53,7 +53,7 @@
<UnityVersion>2021.3.7f1c1</UnityVersion>
</PropertyGroup>
<ItemGroup>
<Analyzer Include="D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Visual Studio Tools for Unity\Analyzers\Microsoft.Unity.Analyzers.dll" />
<Analyzer Include="C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Visual Studio Tools for Unity\Analyzers\Microsoft.Unity.Analyzers.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\ThirdParty\Animancer\Utilities\FSM\StateMachine1.StateSelector.cs" />
@ -310,9 +310,6 @@
<Reference Include="UnityEditor.Graphs">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\Managed\UnityEditor.Graphs.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Android.Extensions">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\UnityEditor.Android.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.WindowsStandalone.Extensions">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\WindowsStandaloneSupport\UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
</Reference>
@ -349,12 +346,6 @@
<Reference Include="NCalc">
<HintPath>Assets\ThirdParty\NCalc\NCalc.dll</HintPath>
</Reference>
<Reference Include="Unity.Android.Types">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\Unity.Android.Types.dll</HintPath>
</Reference>
<Reference Include="Unity.Android.Gradle">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\Unity.Android.Gradle.dll</HintPath>
</Reference>
<Reference Include="mscorlib">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\UnityReferenceAssemblies\unity-4.8-api\mscorlib.dll</HintPath>
</Reference>

11
Unity/Animancer.csproj

@ -53,7 +53,7 @@
<UnityVersion>2021.3.7f1c1</UnityVersion>
</PropertyGroup>
<ItemGroup>
<Analyzer Include="D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Visual Studio Tools for Unity\Analyzers\Microsoft.Unity.Analyzers.dll" />
<Analyzer Include="C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Visual Studio Tools for Unity\Analyzers\Microsoft.Unity.Analyzers.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\ThirdParty\Animancer\Internal\Editor\Transition Preview Window\TransitionPreviewWindow.Animations.cs" />
@ -447,9 +447,6 @@
<Reference Include="UnityEditor.Graphs">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\Managed\UnityEditor.Graphs.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Android.Extensions">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\UnityEditor.Android.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.WindowsStandalone.Extensions">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\WindowsStandaloneSupport\UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
</Reference>
@ -486,12 +483,6 @@
<Reference Include="NCalc">
<HintPath>Assets\ThirdParty\NCalc\NCalc.dll</HintPath>
</Reference>
<Reference Include="Unity.Android.Types">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\Unity.Android.Types.dll</HintPath>
</Reference>
<Reference Include="Unity.Android.Gradle">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\Unity.Android.Gradle.dll</HintPath>
</Reference>
<Reference Include="mscorlib">
<HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.7f1c1\Editor\Data\UnityReferenceAssemblies\unity-4.8-api\mscorlib.dll</HintPath>
</Reference>

5
Unity/Assets/Bundles/Config/StructureConfigCategory.bytes

@ -123,4 +123,7 @@ Build_4013
Build_4013Ê武庄Ð
A®宗厅 Ä(0d8dh²
Build_4014¸Â
Build_4014Ê宗厅Ð
Build_4014Ê宗厅Ð
Q¯ ç”°é—´å°<EFBFBD>屋 Ä(0d8d@Hh²
Build_4015¸Â
Build_4015Ê ç”°é—´å°<EFBFBD>屋Ð

17
Unity/Codes/Hotfix/Demo/Building/BuildingSystem.cs

@ -17,6 +17,12 @@ namespace ET
var farmland = self.AddChildWithId<Farmland>(buildingProto.Farmland.id);
farmland.FromMessage(buildingProto.Farmland);
}
if (buildingProto.Cabin != null)
{
var cabin = self.AddChildWithId<Cabin>(buildingProto.Cabin.Id);
cabin.FromMessage(buildingProto.Cabin);
}
}
public static BuildingProto ToMessage(this Building self)
@ -39,6 +45,17 @@ namespace ET
}
}
if (self.Config.Special == (int) StructureSpecialEnum.FARM_CABIN)
{
foreach (var v in self.Children.Values)
{
if (v.GetType() == typeof (Cabin))
{
proto.Cabin = ((Cabin) v).ToMessage();
}
}
}
return proto;
}

54
Unity/Codes/Hotfix/Demo/Cabin/CabinSystem.cs

@ -0,0 +1,54 @@
namespace ET
{
[FriendClass(typeof(Cabin))]
public static class CabinSystem
{
public static void FromMessage(this Cabin self, CabinProto proto)
{
self.Id = proto.Id;
self.PeopleId = proto.PeopleId;
self.FarmlandIds = proto.FarmlandIds;
}
public static CabinProto ToMessage(this Cabin self)
{
var proto = new CabinProto();
proto.Id = self.Id;
proto.PeopleId = self.PeopleId;
proto.FarmlandIds = self.FarmlandIds;
return proto;
}
public static void PeoplePrepare(this Cabin self,long peopleId)
{
self.PeopleId = peopleId;
}
public static bool PeopleArrive(this Cabin self,long peopleId)
{
if (self.PeopleId != peopleId)
{
return false;
}
self.ResidentState = 1;
return true;
}
public static void PeopleLeave(this Cabin self)
{
self.ResidentState = 0;
self.PeopleId = 0;
}
public static bool AddFarmland(this Cabin self,long farmlandId)
{
if (self.FarmlandIds.Contains(farmlandId))
{
return false;
}
self.FarmlandIds.Add(farmlandId);
return true;
}
}
}

20
Unity/Codes/Hotfix/Demo/Construct/ConstructSystem.cs

@ -57,6 +57,26 @@ namespace ET
return labor;
}
public static void GoConstruct(this Construct self, long peopleId)
{
self.PreparePeopleIdList.Add(peopleId);
}
public static void StartConstruct(this Construct self, long peopleId)
{
if (self.PreparePeopleIdList.Contains(peopleId))
{
self.PreparePeopleIdList.Remove(peopleId);
self.PeopleIdList.Add(peopleId);
}
}
public static void StopConstruct(this Construct self, long peopleId)
{
self.PreparePeopleIdList.Remove(peopleId);
self.PeopleIdList.Remove(peopleId);
}
}
}

7
Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs

@ -102,6 +102,13 @@ namespace ET
Game.EventSystem.Publish(new FarmlandStateChanged(){Farmland = self});
#endif
}
public static void SetCabinId(this Farmland self, long cabinId)
{
self.CabinId = cabinId;
}
}

32
Unity/Codes/Hotfix/Demo/Gather/GatherSystem.cs

@ -24,6 +24,11 @@
return proto;
}
public static bool GoGather(this Gather self, long peopleId)
{
self.PreparePeopleIdList.Add(peopleId);
return true;
}
public static bool StartGather(this Gather self, long peopleId)
{
if (self.PreparePeopleIdList.Contains(peopleId) && !self.PeopleIdList.Contains(peopleId))
@ -38,31 +43,16 @@
public static bool StopGather(this Gather self, long peopleId)
{
foreach (var v in self.PeopleIdList)
bool result = self.PeopleIdList.Remove(peopleId) || self.PreparePeopleIdList.Remove(peopleId);
if (self.PeopleIdList.Count == 0 && self.PreparePeopleIdList.Count == 0)
{
if (v == peopleId)
{
self.PeopleIdList.Remove(peopleId);
return true;
}
self.Dispose();
}
return false;
return result;
}
public static bool StopReadGather(this Gather self, long peopleId)
{
foreach (var v in self.PreparePeopleIdList)
{
if (v == peopleId)
{
self.PreparePeopleIdList.Remove(peopleId);
return true;
}
}
return false;
}
public static bool IsOver(this Gather self)
{
@ -105,8 +95,6 @@
{
self.GatherTime += tick;
ResourcePoint res = unit.GetComponent<ResourcePointComponent>().GetChild<ResourcePoint>(self.ResPointId);
ResourcesPointConfig pointConfig = res.Config;
ResourcesConfig config = ResourcesConfigCategory.Instance.Get(self.ResConfigId);
int amount = 0;
if (config.OutInterval == 0 && self.PeopleIdList.Count > 0)

107
Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs

@ -0,0 +1,107 @@
using System;
namespace ET
{
public static class CabinHelper
{
public static async ETTask<int> GoCabin(Unit unit,People people,Cabin cabin)
{
try
{
C2M_GoCabin msg = new C2M_GoCabin() { PeopleId = people.Id,CabinId = cabin.Id};
M2C_GoCabin resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_GoCabin;
if (resp.Error == ErrorCode.ERR_Success)
{
cabin.PeoplePrepare(people.Id);
PeopleOperate.ChangeBehave(unit, people, ConstBehaveType.BEHAVE_PREPARE_CABIN, cabin.Id);
}
else
{
Log.Error(resp.Error.ToString());
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
public static async ETTask<int> ArriveCabin(Unit unit,People people,Cabin cabin)
{
try
{
C2M_ArriveCabin msg = new C2M_ArriveCabin() { PeopleId = people.Id,CabinId = cabin.Id};
M2C_ArriveCabin resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_ArriveCabin;
if (resp.Error == ErrorCode.ERR_Success)
{
cabin.PeopleArrive(people.Id);
people.SetBehaveType(ConstBehaveType.BEHAVE_CABIN);
}
else
{
Log.Error(resp.Error.ToString());
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
public static async ETTask<int> AddFarmland(Unit unit,Cabin cabin,Farmland farmland)
{
try
{
C2M_CabinAddFarmland msg = new C2M_CabinAddFarmland() { CabinId = cabin.Id,FarmlandId = farmland.Id};
M2C_CabinAddFarmland resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_CabinAddFarmland;
if (resp.Error == ErrorCode.ERR_Success)
{
cabin.AddFarmland(farmland.Id);
farmland.SetCabinId(cabin.Id);
}
else
{
Log.Error(resp.Error.ToString());
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
public static async ETTask<int> CabinSeed(Unit unit,Farmland farmland,int cropCfgId)
{
try
{
C2M_CabinSeed msg = new C2M_CabinSeed() { CropCfgId = cropCfgId,FarmlandId = farmland.Id};
M2C_CabinSeed resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_CabinSeed;
if (resp.Error == ErrorCode.ERR_Success)
{
FarmlandOperate.FarmlandSeed(unit, farmland, cropCfgId);
}
else
{
Log.Error(resp.Error.ToString());
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
}
}

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

@ -5,15 +5,15 @@ namespace ET
{
public static class FarmlandHelper
{
public static async ETTask<int> FarmlandSeed(Unit unit, List<long> farmlandIds, List<int> cropCfgIds)
public static async ETTask<int> FarmlandSeed(Unit unit, Farmland farmland, int cropCfgId)
{
try
{
C2M_FarmlandSeed msg = new C2M_FarmlandSeed() { FarmlandIds = farmlandIds, CropCfgIds = cropCfgIds };
C2M_FarmlandSeed msg = new C2M_FarmlandSeed() { FarmlandId = farmland.Id, CropCfgId = cropCfgId };
M2C_FarmlandSeed resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_FarmlandSeed;
if (resp.Error == ErrorCode.ERR_Success)
{
FarmlandOperate.FarmlandSeed(unit, resp.FarmlandIds, resp.CropCfgIds);
FarmlandOperate.FarmlandSeed(unit, farmland, cropCfgId);
}
else
{

2
Unity/Codes/Hotfix/Demo/Helper/GatherHelper.cs

@ -74,7 +74,7 @@ namespace ET
return resp.Error;
}
GatherOperate.StopGather(unit, gatherId, peopleId);
// GatherOperate.StopGather(unit, gatherId, peopleId);
}
catch (Exception e)
{

9
Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs

@ -0,0 +1,9 @@
namespace ET
{
[FriendClass(typeof(People))]
[FriendClass(typeof(Cabin))]
public static class CabinOperate
{
}
}

18
Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs

@ -174,13 +174,21 @@ namespace ET
build.Position.x = construct.X;
build.Position.y = construct.Y;
build.ConfigId = construct.Config.MixtureID;
//如果是农场
if (build.Config.Special == (int)StructureSpecialEnum.FARMLAND)
switch (build.Config.Special)
{
var farmland = build.AddChild<Farmland>();
farmland.SetFarmlandState(FarmlandState.FARMLAND_STATE_FREE);
unit.AddGrandChild(farmland);
case (int)StructureSpecialEnum.FARMLAND: //如果是农场
var farmland = build.AddChild<Farmland>();
farmland.SetFarmlandState(FarmlandState.FARMLAND_STATE_FREE);
unit.AddGrandChild(farmland);
break;
case 7 :
//var cabin = build.AddChild<Cabin>();
// unit.AddGrandChild(cabin);
break;
}
}
StructureConfig structureConfig = StructureConfigCategory.Instance.Get(build.ConfigId);

37
Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs

@ -12,8 +12,8 @@ namespace ET
{
return ErrorCode.ERR_FarmlandNotSeed;
}
PeopleOperate.ChangeBehave(unit,people, ConstBehaveType.BEHAVE_PREPARE_PLANT, farmland.Id);
PeopleOperate.ChangeBehave(unit, people, ConstBehaveType.BEHAVE_PREPARE_PLANT, farmland.Id);
farmland.PeopleId = people.Id;
return ErrorCode.ERR_Success;
}
@ -38,7 +38,7 @@ namespace ET
return ErrorCode.ERR_FarmlandNotSeed;
}
PeopleOperate.ChangeBehave(unit,people,ConstBehaveType.BEHAVE_PREPARE_HARVEST,farmland.Id);
PeopleOperate.ChangeBehave(unit, people, ConstBehaveType.BEHAVE_PREPARE_HARVEST, farmland.Id);
farmland.PeopleId = people.Id;
return ErrorCode.ERR_Success;
}
@ -65,34 +65,17 @@ namespace ET
return ErrorCode.ERR_FarmlandNotRipe;
}
public static (List<long>, List<int>) FarmlandSeed(Unit unit, List<long> farmlandIds, List<int> CropCfgIds)
public static int FarmlandSeed(Unit unit, Farmland farmland, int CropCfgId)
{
List<long> sucFarmlandList = new List<long>();
List<int> sucCropList = new List<int>();
for (int i = 0; i < farmlandIds.Count; i++)
var cropCfg = CropConfigCategory.Instance.Get(CropCfgId);
var sc = unit.GetComponent<StoreComponent>();
if (sc.Remove(cropCfg.SeedNeed, cropCfg.SeedNum))
{
Farmland farmland = unit.GetGrandChild<Farmland>(farmlandIds[i]);
if (farmland == null)
{
continue;
}
if (farmland.FarmlandState == FarmlandState.FARMLAND_STATE_FREE)
{
var cropCfg = CropConfigCategory.Instance.Get(CropCfgIds[i]);
var sc = unit.GetComponent<StoreComponent>();
if (sc.Remove(cropCfg.SeedNeed, cropCfg.SeedNum))
{
farmland.Seed(cropCfg.Id);
sucCropList.Add(cropCfg.Id);
sucFarmlandList.Add(farmlandIds[i]);
}
}
farmland.Seed(cropCfg.Id);
return ErrorCode.ERR_Success;
}
return (sucFarmlandList, sucCropList);
return ErrorCode.ERR_OperateFail;
}
}
}

50
Unity/Codes/Hotfix/Demo/Operate/GatherOperate.cs

@ -74,36 +74,26 @@ namespace ET
return ErrorCode.ERR_OperateFail;
}
public static int StopGather(Unit unit, long gatherId, long peopleId)
{
People people = unit.GetComponent<PeopleComponent>().GetChild<People>(peopleId);
if (people == null)
{
return ErrorCode.ERR_PeopleNotFound;
}
Gather gather = unit.GetComponent<GatherComponent>().GetChild<Gather>(gatherId);
if (gather == null)
{
return ErrorCode.ERR_GatherNotFound;
}
var behaveType = people.GetBehaveType();
if ( (behaveType == ConstBehaveType.BEHAVE_PREPARE_GATHER && gather.PreparePeopleIdList.Remove(peopleId) )
||(behaveType == ConstBehaveType.BEHAVE_GATHER && gather.PeopleIdList.Remove(peopleId)) )
{
if (gather.IsOver())
{
gather.Dispose();
}
people.SetBehaveType(ConstBehaveType.BEHAVE_IDLE);
people.SetTargetId(0);
return ErrorCode.ERR_Success;
}
return ErrorCode.ERR_OperateFail;
}
// public static int StopGather(Unit unit, People people,Gather gather)
// {
//
//
// var behaveType = people.GetBehaveType();
// if ( (behaveType == ConstBehaveType.BEHAVE_PREPARE_GATHER && gather.PreparePeopleIdList.Remove(peopleId) )
// ||(behaveType == ConstBehaveType.BEHAVE_GATHER && gather.PeopleIdList.Remove(peopleId)) )
// {
// if (gather.IsOver())
// {
//
// gather.Dispose();
//
// }
// people.SetBehaveType(ConstBehaveType.BEHAVE_IDLE);
// people.SetTargetId(0);
// return ErrorCode.ERR_Success;
// }
// return ErrorCode.ERR_OperateFail;
// }
public static int CancelGather(Unit unit, long gatherId)
{

40
Unity/Codes/Hotfix/Demo/Operate/PeopleOperate.cs

@ -2,39 +2,53 @@
namespace ET
{
[FriendClass(typeof(People))]
[FriendClass(typeof (People))]
[FriendClass(typeof (Gather))]
public static class PeopleOperate
{
public static int StopBehave(Unit unit, People people)
{
if (people == null)
{
return ErrorCode.ERR_PeopleNotFound;
}
var peopleBehave = people.GetBehaveType();
var targetId = people.GetTargetId();
switch (peopleBehave)
{
case ConstBehaveType.BEHAVE_GATHER:
case ConstBehaveType.BEHAVE_PREPARE_GATHER:
GatherOperate.StopGather(unit, targetId, people.Id);
var gather = unit.GetComponent<GatherComponent>().GetChild<Gather>(targetId);
if (gather == null)
{
return ErrorCode.ERR_GatherNotFound;
}
gather.StartGather(people.Id);
break;
case ConstBehaveType.BEHAVE_CONSTRUCT:
case ConstBehaveType.BEHAVE_PREPARE_CONSTRUCT:
ConstructOperate.StopConstruct(unit, targetId, people.Id);
var construct = unit.GetComponent<GatherComponent>().GetChild<Construct>(targetId);
if (construct == null)
{
return ErrorCode.ERR_ConstructNotFound;
}
construct.StopConstruct(people.Id);
break;
case ConstBehaveType.BEHAVE_PREPARE_CABIN:
case ConstBehaveType.BEHAVE_CABIN:
var canbin = unit.GetGrandChild<Cabin>(targetId);
if (canbin == null)
{
return ErrorCode.ERR_CabinNotFound;
}
canbin.PeopleLeave();
break;
}
people.SetBehaveType(ConstBehaveType.BEHAVE_IDLE);
people.SetTargetId(0);
people.BehaveIdle();
return ErrorCode.ERR_Success;
}
public static int ChangeBehave(Unit unit, People people,int behaveType,long targetId=0 )
public static int ChangeBehave(Unit unit, People people, int behaveType, long targetId = 0)
{
var result = StopBehave(unit, people);
if (result != ErrorCode.ERR_Success)
{

6
Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs

@ -78,6 +78,12 @@ namespace ET
return self.BehaveType;
}
public static void BehaveIdle(this People self)
{
self.TargetId = 0;
self.SetBehaveType(ConstBehaveType.BEHAVE_IDLE);
}
public static void SetBehaveType(this People self, int val)
{
self.BehaveType = val;

2
Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs

@ -110,7 +110,7 @@ namespace ET
unitComponent.Add(unit);
unit.AddComponent<ObjectWait>();
unit.InitFarmlandDic();
unit.InitGrandChildren();
Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit});
return unit;

2
Unity/Codes/Hotfix/Demo/Unit/UnitHelper.cs

@ -73,7 +73,7 @@ namespace ET
List<NightEvent> nightEvents = null;
if (unit.EventSeed > 0)
{
SeasonConfig lastSeasonConfig = UnitOperate.GetSeasonConfigByDay(unit.Day-1, unit.Season);
SeasonConfig lastSeasonConfig = UnitOperate.GetSeasonConfigByDay(unit.Day-1,unit.Season);
int nightTime = UnitOperate.CheckMoonNightTime(unit.Day-1, lastSeasonConfig.DayTime[1]);
nightEvents = UnitOperate.NightEvent(unit, nightTime, unit.SeasonConfig.DayTime[0]);

19
Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs

@ -148,7 +148,7 @@ namespace ET
self.UpdateValleyTime = TimeHelper.ServerUnix();
self.SeasonConfig = SeasonConfigCategory.Instance.Get(self.Season);
self.InitPeopleNumberic();
self.InitFarmlandDic();
self.InitGrandChildren();
}
public static void updateSeason(this Unit self)
@ -272,19 +272,18 @@ namespace ET
}
}
public static void InitFarmlandDic(this Unit self)
public static void InitGrandChildren(this Unit self)
{
//
var bc = self.GetComponent<BuildingComponent>();
if (bc == null)
if (bc != null)
{
return;
}
foreach (var v in self.GetComponent<BuildingComponent>().Children.Values)
{
foreach (var c in v.Children.Values)
foreach (var v in self.GetComponent<BuildingComponent>().Children.Values)
{
self.AddGrandChild(c);
foreach (var c in v.Children.Values)
{
self.AddGrandChild(c);
}
}
}
}

7
Unity/Codes/HotfixView/Demo/FUI/Logic/Building/FUIFarmlandWindowComponentSystem.cs

@ -279,13 +279,10 @@ namespace ET
Log.Error($"Building [{self.Building.Id}] dosen't have a Farmland");
return;
}
List<long> farmlandList = new List<long>();
farmlandList.Add(farmland.Id);
List<int> cropList = new List<int>();
cropList.Add(self.CurSelectCrop.Id);
Unit unit = UnitHelper.GetMyUnitFromZoneScene(self.ZoneScene());
int result = await FarmlandHelper.FarmlandSeed(unit, farmlandList, cropList);
int result = await FarmlandHelper.FarmlandSeed(unit, farmland, self.CurSelectCrop.Id);
if (result != ErrorCode.ERR_Success)
{

2
Unity/Codes/Model/Demo/Building/Building.cs

@ -11,7 +11,7 @@ namespace ET
Upgrade = 3,
}
[ChildType(typeof(Farmland))]
[ChildType]
public class Building: Entity, IAwake, ISerializeToEntity
{
public int ConfigId;

13
Unity/Codes/Model/Demo/Cabin/Cabin.cs

@ -0,0 +1,13 @@
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
namespace ET
{
public class Cabin: Entity,IAwake,IUpdate, IDestroy,ISerializeToEntity
{
public long PeopleId;
public List<long> FarmlandIds = new List<long>();
public int ResidentState; //是不是有居民常驻 0表示没有,1表示有
}
}

5
Unity/Codes/Model/Demo/Common/GameUtil.cs

@ -7,5 +7,10 @@
{
return (int)time;
}
public static bool IsErrorSuc(int err)
{
return err == ErrorCode.ERR_Success;
}
}
}

2
Unity/Codes/Model/Demo/ConstValue.cs

@ -35,6 +35,8 @@ namespace ET
public const int BEHAVE_PLANT = 6; //正在种植
public const int BEHAVE_PREPARE_HARVEST = 7;//去收割
public const int BEHAVE_HARVEST = 8;//正在收割
public const int BEHAVE_PREPARE_CABIN = 9; //去小屋
public const int BEHAVE_CABIN = 10; //驻扎小屋
}

6
Unity/Codes/Model/Demo/Farmland/Farmland.cs

@ -10,7 +10,11 @@ namespace ET
public int ExProduct; //额外产量
public int FarmlandState; //农田状态
public int PlanCropCfgId; //计划种植的东西
public long PeopleId; //农民id
public long PeopleId; //农民id
public long CabinId; //小屋id
[BsonIgnore]
public CropConfig Config =>CropConfigCategory.Instance.Get(this.CropCfgId);

2
Unity/Codes/Model/Generate/ConfigEnum.cs

@ -909,6 +909,8 @@ namespace ET
MAKINGMEDICINE = 5,
// 粮仓
GRANARY = 6,
// 田间小屋
FARM_CABIN = 7,
}
public enum StructureSpecificPointEnum
{

155
Unity/Codes/Model/Generate/Message/OuterMessage.cs

@ -146,6 +146,9 @@ namespace ET
[ProtoMember(7)]
public int IsUpgrade { get; set; }
[ProtoMember(8)]
public CabinProto Cabin { get; set; }
}
[Message(OuterOpcode.PeopleProto)]
@ -2591,10 +2594,10 @@ namespace ET
public int RpcId { get; set; }
[ProtoMember(1)]
public List<long> FarmlandIds = new List<long>();
public long FarmlandId { get; set; }
[ProtoMember(2)]
public List<int> CropCfgIds = new List<int>();
public int CropCfgId { get; set; }
}
@ -2611,12 +2614,6 @@ namespace ET
[ProtoMember(92)]
public string Message { get; set; }
[ProtoMember(1)]
public List<long> FarmlandIds = new List<long>();
[ProtoMember(2)]
public List<int> CropCfgIds = new List<int>();
}
[ResponseType(nameof(M2C_ChangeBehave))]
@ -2795,4 +2792,146 @@ namespace ET
}
[Message(OuterOpcode.CabinProto)]
[ProtoContract]
public partial class CabinProto: Object
{
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public long PeopleId { get; set; }
[ProtoMember(3)]
public List<long> FarmlandIds = new List<long>();
[ProtoMember(4)]
public int ResidentState { get; set; }
}
[ResponseType(nameof(M2C_GoCabin))]
[Message(OuterOpcode.C2M_GoCabin)]
[ProtoContract]
public partial class C2M_GoCabin: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long PeopleId { get; set; }
[ProtoMember(2)]
public long CabinId { get; set; }
}
[Message(OuterOpcode.M2C_GoCabin)]
[ProtoContract]
public partial class M2C_GoCabin: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
[ResponseType(nameof(M2C_ArriveCabin))]
[Message(OuterOpcode.C2M_ArriveCabin)]
[ProtoContract]
public partial class C2M_ArriveCabin: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long PeopleId { get; set; }
[ProtoMember(2)]
public long CabinId { get; set; }
}
[Message(OuterOpcode.M2C_ArriveCabin)]
[ProtoContract]
public partial class M2C_ArriveCabin: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
[ResponseType(nameof(M2C_CabinAddFarmland))]
[Message(OuterOpcode.C2M_CabinAddFarmland)]
[ProtoContract]
public partial class C2M_CabinAddFarmland: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long FarmlandId { get; set; }
[ProtoMember(2)]
public long CabinId { get; set; }
}
[Message(OuterOpcode.M2C_CabinAddFarmland)]
[ProtoContract]
public partial class M2C_CabinAddFarmland: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
[ResponseType(nameof(M2C_CabinSeed))]
[Message(OuterOpcode.C2M_CabinSeed)]
[ProtoContract]
public partial class C2M_CabinSeed: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public long FarmlandId { get; set; }
[ProtoMember(2)]
public int CropCfgId { get; set; }
}
[Message(OuterOpcode.M2C_CabinSeed)]
[ProtoContract]
public partial class M2C_CabinSeed: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
}

9
Unity/Codes/Model/Generate/Message/OuterOpcode.cs

@ -166,5 +166,14 @@ namespace ET
public const ushort M2C_FarmlandRipe = 10163;
public const ushort M2C_NtfFarmlandRipe = 10164;
public const ushort M2C_NtfFarmlandRipeProgress = 10165;
public const ushort CabinProto = 10166;
public const ushort C2M_GoCabin = 10167;
public const ushort M2C_GoCabin = 10168;
public const ushort C2M_ArriveCabin = 10169;
public const ushort M2C_ArriveCabin = 10170;
public const ushort C2M_CabinAddFarmland = 10171;
public const ushort M2C_CabinAddFarmland = 10172;
public const ushort C2M_CabinSeed = 10173;
public const ushort M2C_CabinSeed = 10174;
}
}

3
Unity/Codes/Model/Module/Message/ErrorCode.cs

@ -96,5 +96,8 @@ namespace ET
public const int ERR_SeedNotEnough = 210205;// 农场没有找到
public const int ERR_FarmlandNotRipe = 210206;//没有成熟
public const int ERR_FarmlandNotSeed = 210207;//没有播种
public const int ERR_CabinNotFound = 210208;//没有找到小屋
public const int ERR_ArriveCabinFail = 210209;//到达小屋失败
public const int ERR_CabinNotPeople = 210210;//小屋没有常驻人
}
}
Loading…
Cancel
Save