23 changed files with 395 additions and 196 deletions
@ -0,0 +1,25 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
namespace ET |
||||||
|
{ |
||||||
|
|
||||||
|
public class C2M_FarmlandHarvestHandler: AMActorLocationRpcHandler<Unit, C2M_FarmlandHarvest, M2C_FarmlandHarvest> |
||||||
|
{ |
||||||
|
protected override async ETTask Run(Unit unit, C2M_FarmlandHarvest request, M2C_FarmlandHarvest response, Action reply) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
response.Error = FarmlandOperate.Harvest(unit, request.FarmlandId); |
||||||
|
reply(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
response.Message = e.ToString(); |
||||||
|
response.Error = ErrorCode.ERR_OperateFail; |
||||||
|
reply(); |
||||||
|
} |
||||||
|
|
||||||
|
await ETTask.CompletedTask; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
namespace ET |
||||||
|
{ |
||||||
|
|
||||||
|
public class C2M_FarmlandPlantHandler: AMActorLocationRpcHandler<Unit, C2M_FarmlandPlant, M2C_FarmlandPlant> |
||||||
|
{ |
||||||
|
protected override async ETTask Run(Unit unit, C2M_FarmlandPlant request, M2C_FarmlandPlant response, Action reply) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
response.Error=FarmlandOperate.Plant(unit, request.FarmlandId); |
||||||
|
reply(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
response.Message = e.ToString(); |
||||||
|
response.Error = ErrorCode.ERR_OperateFail; |
||||||
|
reply(); |
||||||
|
} |
||||||
|
|
||||||
|
await ETTask.CompletedTask; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
namespace ET |
||||||
|
{ |
||||||
|
public class C2M_FarmlandSeedHandler: AMActorLocationRpcHandler<Unit, C2M_FarmlandSeed, M2C_FarmlandSeed> |
||||||
|
{ |
||||||
|
protected override async ETTask Run(Unit unit, C2M_FarmlandSeed request, M2C_FarmlandSeed response, Action reply) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
(response.FarmlandIds, response.CropCfgIds) = FarmlandOperate.FarmlandSeed(unit, request.FarmlandIds, request.CropCfgIds); |
||||||
|
response.Error = ErrorCode.ERR_Success; |
||||||
|
reply(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
response.Message = e.ToString(); |
||||||
|
response.Error = ErrorCode.ERR_OperateFail; |
||||||
|
reply(); |
||||||
|
} |
||||||
|
|
||||||
|
await ETTask.CompletedTask; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,28 +0,0 @@ |
|||||||
using System; |
|
||||||
|
|
||||||
namespace ET.Gm.Handler |
|
||||||
{ |
|
||||||
public class M2C_GMAddItemHandler:AMActorLocationRpcHandler<Unit, C2M_GMAddItem, M2C_GMAddItem> |
|
||||||
{ |
|
||||||
protected override async ETTask Run(Unit unit, C2M_GMAddItem request, M2C_GMAddItem response, Action reply) |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
var storeNc = unit.GetComponent<StoreComponent>(); |
|
||||||
for (int i = 0; i < request.Ks.Count; i++) |
|
||||||
{ |
|
||||||
storeNc.Add(request.Ks[i], request.Vs[i]); |
|
||||||
} |
|
||||||
response.Error = ErrorCode.ERR_Success; |
|
||||||
reply(); |
|
||||||
} |
|
||||||
catch (Exception e) |
|
||||||
{ |
|
||||||
response.Message = e.ToString(); |
|
||||||
reply(); |
|
||||||
} |
|
||||||
|
|
||||||
await ETTask.CompletedTask; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,38 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
|
|
||||||
namespace ET |
|
||||||
{ |
|
||||||
public static class GmHelper |
|
||||||
{ |
|
||||||
public static async ETTask<int> AddItem(Unit unit, List<int> Ks, List<int> Vs) |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
M2C_GMAddItem resp = |
|
||||||
await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(new C2M_GMAddItem() { Ks = Ks, Vs = Vs }) as |
|
||||||
M2C_GMAddItem; |
|
||||||
if (resp.Error != ErrorCode.ERR_Success) |
|
||||||
{ |
|
||||||
Log.Error(resp.Error.ToString()); |
|
||||||
return resp.Error; |
|
||||||
} |
|
||||||
|
|
||||||
var storeNc = unit.GetComponent<StoreComponent>(); |
|
||||||
for (int i = 0; i < Ks.Count; i++) |
|
||||||
{ |
|
||||||
storeNc.Add(Ks[i], Vs[i]); |
|
||||||
} |
|
||||||
} |
|
||||||
catch (Exception e) |
|
||||||
{ |
|
||||||
Console.WriteLine(e); |
|
||||||
throw; |
|
||||||
} |
|
||||||
|
|
||||||
await ETTask.CompletedTask; |
|
||||||
return ErrorCode.ERR_Success; |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue