|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
{
|
|
|
|
public static class GatherHelper
|
|
|
|
{
|
|
|
|
public static async ETTask<int> GatherResource(Unit unit, long resPointId, int resConfigId, List<long> peopleIdList)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
C2M_GatherResource msg = new C2M_GatherResource(){ResPointId = resPointId, ResConfigId = resConfigId, PeopleIdList = peopleIdList};
|
|
|
|
M2C_GatherResource resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_GatherResource;
|
|
|
|
if (resp.Error != ErrorCode.ERR_Success)
|
|
|
|
{
|
|
|
|
Log.Error(resp.Error.ToString());
|
|
|
|
return resp.Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
GatherOperate.GatherResource(unit, resPointId,resConfigId, peopleIdList,resp.GatherId);
|
|
|
|
|
|
|
|
|
|
|
|
// GatherComponent gatherComponent = unit.GetOrAddComponent<GatherComponent>();
|
|
|
|
// Gather gather = gatherComponent.AddChildWithId<Gather>(resp.GatherId);
|
|
|
|
// gather.ResourceId = resourceId;
|
|
|
|
// gather.ReadyPeopleIdList = peopleIdList;
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e);
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
return ErrorCode.ERR_Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async ETTask<int> StartGather(Unit unit, long gatherId, long peopleId)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
C2M_StartGatherResource msg = new C2M_StartGatherResource() { GatherId = gatherId, PeopleId = peopleId };
|
|
|
|
M2C_StartGatherResource resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_StartGatherResource;
|
|
|
|
if (resp.Error != ErrorCode.ERR_Success)
|
|
|
|
{
|
|
|
|
Log.Error(resp.Error.ToString());
|
|
|
|
return resp.Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
GatherOperate.StartGather(unit, gatherId, peopleId);
|
|
|
|
|
|
|
|
// gather.ReadyPeopleIdList.Remove(peopleId);
|
|
|
|
// gather.PeopleIdList.Add(peopleId);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e);
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
return ErrorCode.ERR_Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async ETTask<int> StopGather(Unit unit, long gatherId, long peopleId)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
C2M_StopGather msg = new C2M_StopGather() { GatherId = gatherId, PeopleId = peopleId };
|
|
|
|
M2C_StopGather resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_StopGather;
|
|
|
|
if (resp.Error != ErrorCode.ERR_Success)
|
|
|
|
{
|
|
|
|
Log.Error(resp.Error.ToString());
|
|
|
|
return resp.Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GatherOperate.StopGather(unit, gatherId, peopleId);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e);
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
return ErrorCode.ERR_Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|