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.
 
 
 
 
 
 

167 lines
5.6 KiB

using System;
using System.Collections.Generic;
namespace ET
{
public static class FarmlandHelper
{
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,Farmland farmland)
{
try
{
C2M_GoFarmlandPlant msg = new C2M_GoFarmlandPlant() { PeopleId = people.Id,FarmlandId = farmland.Id};
M2C_GoFarmlandPlant resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_GoFarmlandPlant;
if (resp.Error == ErrorCode.ERR_Success)
{
FarmlandOperate.GoPlant(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> StartFarmlandPlant(Unit unit, People people, Farmland farmland)
{
return await PeopleHelper.ChangeBehave(unit, people, ConstBehaveType.BEHAVE_PLANT,farmland.Id);
}
public static async ETTask<int> FinishFarmlandPlant(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.FinishPlant(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> GoFarmlandHarvest(Unit unit,People people,Farmland farmland)
{
try
{
C2M_GoFarmlandHarvest msg = new C2M_GoFarmlandHarvest() { PeopleId = people.Id,FarmlandId = farmland.Id};
M2C_GoFarmlandHarvest resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_GoFarmlandHarvest;
if (resp.Error == ErrorCode.ERR_Success)
{
FarmlandOperate.GoHarvest(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> StartFarmlandHarvest(Unit unit, People people, Farmland farmland)
{
return await PeopleHelper.ChangeBehave(unit, people, ConstBehaveType.BEHAVE_HARVEST,farmland.Id);
}
public static async ETTask<int> FarmlandHarvest(Unit unit, Farmland farmland,People people)
{
try
{
C2M_FarmlandHarvest msg = new C2M_FarmlandHarvest() { FarmlandId = farmland.Id, PeopleId = people.Id};
M2C_FarmlandHarvest resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_FarmlandHarvest;
if (resp.Error == ErrorCode.ERR_Success)
{
FarmlandOperate.FinishHarvest(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);
}
public static async ETTask<int> FarmlandRipe(Unit unit,long farmlandId)
{
try
{
C2M_FarmlandRipe msg = new C2M_FarmlandRipe() { FarmlandId = farmlandId };
M2C_FarmlandRipe resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_FarmlandRipe;
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
}
}