Browse Source

增加C2M_ChangeBehaveHandler

master
wserver/wangdisen 3 years ago
parent
commit
65d29a7529
  1. 36
      Server/Hotfix/Demo/People/Handler/C2M_ChangeBehaveHandler.cs
  2. 4
      Unity/Codes/Hotfix/Demo/Operate/FarmlandOperate.cs

36
Server/Hotfix/Demo/People/Handler/C2M_ChangeBehaveHandler.cs

@ -0,0 +1,36 @@
using System;
namespace ET
{
public class C2M_ChangeBehaveHandler: AMActorLocationRpcHandler<Unit, C2M_ChangeBehave, M2C_ChangeBehave>
{
protected async override ETTask Run(Unit unit, C2M_ChangeBehave request, M2C_ChangeBehave response, Action reply)
{
try
{
People people = unit.GetComponent<PeopleComponent>().GetChild<People>(request.PeopleId);
if (people != null)
{
PeopleOperate.ChangeBehave(unit, people, request.BehaveType, request.TargetId);
response.Error = ErrorCode.ERR_Success;
}
else
{
response.Error = ErrorCode.ERR_PeopleMoveFail;
}
reply();
}
catch (Exception e)
{
response.Message = e.ToString();
response.Error = ErrorCode.ERR_PeopleMoveFail;
reply();
}
await ETTask.CompletedTask;
}
}
}

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

@ -83,8 +83,8 @@ namespace ET
var sc = unit.GetComponent<StoreComponent>();
if (sc.Remove(cropCfg.SeedNeed, cropCfg.SeedNum))
{
farmland.Seed(cropCfg.SeedNeed);
sucCropList.Add(cropCfg.SeedNeed);
farmland.Seed(cropCfg.Id);
sucCropList.Add(cropCfg.Id);
sucFarmlandList.Add(farmlandIds[i]);
}
}

Loading…
Cancel
Save