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.
96 lines
3.0 KiB
96 lines
3.0 KiB
using System; |
|
using System.Collections.Generic; |
|
|
|
namespace ET |
|
{ |
|
public static class PlantHelper |
|
{ |
|
public static async ETTask<int> FarmlandSeed(Unit unit, List<long> farmlandIds, List<int> cropCfgIds) |
|
{ |
|
try |
|
{ |
|
C2M_FarmlandSeed msg = new C2M_FarmlandSeed() { FarmlandIds = farmlandIds, CropCfgIds = cropCfgIds }; |
|
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); |
|
} |
|
else |
|
{ |
|
Log.Error(resp.Error.ToString()); |
|
} |
|
|
|
return resp.Error; |
|
} |
|
catch (Exception e) |
|
{ |
|
Log.Error(e.ToString()); |
|
throw; |
|
} |
|
} |
|
|
|
public static async ETTask<int> FarmlandPlant(Unit unit, Farmland farmland,People people) |
|
{ |
|
try |
|
{ |
|
C2M_FarmlandPlant msg = new C2M_FarmlandPlant() { FarmlandId = farmland.Id,PeopleId = people.Id}; |
|
M2C_FarmlandPlant resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_FarmlandPlant; |
|
if (resp.Error == ErrorCode.ERR_Success) |
|
{ |
|
FarmlandOperate.Plant(unit, farmland,people); |
|
} |
|
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, Farmland farmland,People people) |
|
{ |
|
try |
|
{ |
|
C2M_FarmlandHarvest msg = new C2M_FarmlandHarvest() { FarmlandId = farmland.Id }; |
|
M2C_FarmlandPlant resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_FarmlandPlant; |
|
if (resp.Error == ErrorCode.ERR_Success) |
|
{ |
|
FarmlandOperate.Harvest(unit, farmland,people); |
|
} |
|
else |
|
{ |
|
Log.Error(resp.Error.ToString()); |
|
} |
|
|
|
return resp.Error; |
|
} |
|
catch (Exception e) |
|
{ |
|
Log.Error(e.ToString()); |
|
throw; |
|
} |
|
} |
|
|
|
public static async ETTask<int> FarmlandPlantFinish(Unit unit,People people) |
|
{ |
|
return await PeopleHelper.ChangeBehave(unit, people, 0, ConstBehaveType.BEHAVE_IDLE); |
|
} |
|
|
|
public static async ETTask<int> FarmlandHarvestFinish(Unit unit,People people) |
|
{ |
|
return await PeopleHelper.ChangeBehave(unit, people, 0, ConstBehaveType.BEHAVE_IDLE); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
} |