16 changed files with 279 additions and 13 deletions
@ -0,0 +1,38 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ET |
||||||
|
{ |
||||||
|
[FriendClass(typeof(Farmland))] |
||||||
|
public class C2M_FarmlandRipeHandler: AMActorLocationRpcHandler<Unit, C2M_FarmlandRipe, M2C_FarmlandRipe> |
||||||
|
{ |
||||||
|
protected override async ETTask Run(Unit unit, C2M_FarmlandRipe request, M2C_FarmlandRipe response, Action reply) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
Farmland farmland = unit.GetGrandChild<Farmland>(request.FarmlandId); |
||||||
|
if (farmland != null) |
||||||
|
{ |
||||||
|
farmland.FarmlandState = FarmlandState.FARMLAND_STATE_RIPE; |
||||||
|
response.Error = ErrorCode.ERR_Success; |
||||||
|
FarmlandHelper.NotifyFarmlandRipe(unit,new List<long>{farmland.Id}); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
response.Error = ErrorCode.ERR_FarmlandNotFound; |
||||||
|
} |
||||||
|
|
||||||
|
reply(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
response.Message = e.ToString(); |
||||||
|
response.Error = ErrorCode.ERR_OperateFail; |
||||||
|
reply(); |
||||||
|
throw; |
||||||
|
} |
||||||
|
|
||||||
|
await ETTask.CompletedTask; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ET |
||||||
|
{ |
||||||
|
public static class FarmlandHelper |
||||||
|
{ |
||||||
|
public static void M2C_NtfFarmlandRipeProgress(Unit unit, List<long> farmlandIds, List<int> progresses) |
||||||
|
{ |
||||||
|
if (farmlandIds.Count == 0) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
MessageHelper.SendToClient(unit,new M2C_NtfFarmlandRipeProgress(){ FarmlandIds = farmlandIds,Progresses = progresses}); |
||||||
|
} |
||||||
|
public static void NotifyFarmlandRipe(Unit unit, List<long> farmlandIds) |
||||||
|
{ |
||||||
|
if (farmlandIds.Count == 0) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
MessageHelper.SendToClient(unit,new M2C_NtfFarmlandRipe(){FarmlandIds =farmlandIds }); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
namespace ET.Handler |
||||||
|
{ |
||||||
|
[FriendClass(typeof(Farmland))] |
||||||
|
public class M2C_NtfFarmlandRipeHandler:AMHandler<M2C_NtfFarmlandRipe> |
||||||
|
{ |
||||||
|
protected override void Run(Session session, M2C_NtfFarmlandRipe message) |
||||||
|
{ |
||||||
|
foreach (var v in message.FarmlandIds) |
||||||
|
{ |
||||||
|
Farmland farmland=UnitComponent.unit.GetGrandChild<Farmland>(v); |
||||||
|
if ( farmland!= null) |
||||||
|
{ |
||||||
|
farmland.FarmlandState = FarmlandState.FARMLAND_STATE_RIPE; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
namespace ET.Handler |
||||||
|
{ |
||||||
|
|
||||||
|
[FriendClass(typeof(Farmland))] |
||||||
|
public class M2C_NtfFarmlandRipeProgressHandler:AMHandler<M2C_NtfFarmlandRipeProgress> |
||||||
|
{ |
||||||
|
protected override void Run(Session session, M2C_NtfFarmlandRipeProgress message) |
||||||
|
{ |
||||||
|
for (int i=0;i<message.FarmlandIds.Count;i++) |
||||||
|
{ |
||||||
|
Farmland farmland=UnitComponent.unit.GetGrandChild<Farmland>(message.FarmlandIds[i]); |
||||||
|
if ( farmland!= null) |
||||||
|
{ |
||||||
|
farmland.Duration = message.Progresses[i]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue