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.
 
 
 
 
 
 

108 lines
3.5 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> GoFarmlandPlant(Unit unit,People people,long farmlandId)
{
return await PeopleHelper.ChangeBehave(unit, people, farmlandId, ConstBehaveType.BEHAVE_PREPARE_PLANT);
}
public static async ETTask<int> StartFarmlandPlant(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> FinishFarmlandPlant(Unit unit,People people)
{
return await PeopleHelper.ChangeBehave(unit, people, 0, ConstBehaveType.BEHAVE_IDLE);
}
public static async ETTask<int> GoFarmlandHarvest(Unit unit,People people)
{
return await PeopleHelper.ChangeBehave(unit, people, 0, ConstBehaveType.BEHAVE_PREPARE_HARVEST);
}
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> FinishFarmlandHarvest(Unit unit,People people)
{
return await PeopleHelper.ChangeBehave(unit, people, 0, ConstBehaveType.BEHAVE_IDLE);
}
}
}