You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public static class PlantHelper
|
||
|
{
|
||
|
public static async ETTask<int> FarmlandPlant(Unit unit, long farmlandId, int cropId)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
C2M_FarmlandPlant msg = new C2M_FarmlandPlant() { FarmlandId = farmlandId, CropCfgId = cropId };
|
||
|
M2C_FarmlandPlant resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_FarmlandPlant;
|
||
|
if (resp.Error == ErrorCode.ERR_Success)
|
||
|
{
|
||
|
FarmlandOperate.Plant(unit, farmlandId, cropId);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Log.Error(resp.Error.ToString());
|
||
|
}
|
||
|
|
||
|
return resp.Error;
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Log.Error(e.ToString());
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static async ETTask<int> FarmlandHarvest(Unit unit, long farmlandId)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
C2M_FarmlandHarvest msg = new C2M_FarmlandHarvest() { FarmlandId = farmlandId };
|
||
|
M2C_FarmlandPlant resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_FarmlandPlant;
|
||
|
if (resp.Error == ErrorCode.ERR_Success)
|
||
|
{
|
||
|
FarmlandOperate.Harvest(unit, farmlandId);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Log.Error(resp.Error.ToString());
|
||
|
}
|
||
|
|
||
|
return resp.Error;
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Log.Error(e.ToString());
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|