|
|
|
@ -5,16 +5,16 @@ namespace ET
|
|
|
|
|
{ |
|
|
|
|
public static class ConstructHelper |
|
|
|
|
{ |
|
|
|
|
public static async ETTask<int> CreateConstruct(Unit unit, int configId, float x, float y,long buildingId=0) |
|
|
|
|
public static async ETTask<int> CreateConstruct(Unit unit, int configId, float x, float y, long buildingId = 0) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
C2M_CreateConstruct msg = new C2M_CreateConstruct(){ConfigId = configId, X = x,Y = y,BuildingId = buildingId}; |
|
|
|
|
M2C_CreateConstruct resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_CreateConstruct; |
|
|
|
|
C2M_CreateConstruct msg = new C2M_CreateConstruct() { ConfigId = configId, X = x, Y = y, BuildingId = buildingId }; |
|
|
|
|
M2C_CreateConstruct resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_CreateConstruct; |
|
|
|
|
if (resp.Error == ErrorCode.ERR_Success) |
|
|
|
|
{ |
|
|
|
|
var construct = unit.GetOrAddComponent<ConstructComponent>().CreateConstruct(unit,configId, x, y, resp.Id); |
|
|
|
|
Game.EventSystem.Publish(new EventType.AfterCreateConstruct(){Unit = unit, Construct = construct, IsNew = true}); |
|
|
|
|
var construct = unit.GetOrAddComponent<ConstructComponent>().CreateConstruct(unit, configId, x, y, resp.Id); |
|
|
|
|
Game.EventSystem.Publish(new EventType.AfterCreateConstruct() { Unit = unit, Construct = construct, IsNew = true }); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -28,7 +28,6 @@ namespace ET
|
|
|
|
|
Log.Error(e.ToString()); |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static async ETTask<int> CancelConstruct(Unit unit, long id) |
|
|
|
@ -51,17 +50,18 @@ namespace ET
|
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async ETTask<int> GoConstruct(Unit unit, long id, List<long> peopleIdList) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
M2C_GoConstruct resp = |
|
|
|
|
await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(new C2M_GoConstruct() { Id = id,PeopleIdList = peopleIdList}) as |
|
|
|
|
await unit.ZoneScene().GetComponent<SessionComponent>().Session |
|
|
|
|
.Call(new C2M_GoConstruct() { Id = id, PeopleIdList = peopleIdList }) as |
|
|
|
|
M2C_GoConstruct; |
|
|
|
|
if (resp.Error == ErrorCode.ERR_Success) |
|
|
|
|
{ |
|
|
|
|
ConstructOperate.GoConstruct(unit,id,peopleIdList); |
|
|
|
|
ConstructOperate.GoConstruct(unit, id, peopleIdList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return resp.Error; |
|
|
|
@ -78,12 +78,14 @@ namespace ET
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
M2C_StartConstruct resp = |
|
|
|
|
await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(new C2M_StartConstruct() { Id = id,peopleId = peopleId }) as |
|
|
|
|
await unit.ZoneScene().GetComponent<SessionComponent>().Session |
|
|
|
|
.Call(new C2M_StartConstruct() { Id = id, peopleId = peopleId }) as |
|
|
|
|
M2C_StartConstruct; |
|
|
|
|
if (resp.Error == ErrorCode.ERR_Success) |
|
|
|
|
{ |
|
|
|
|
ConstructOperate.StartConstruct(unit,id,peopleId); |
|
|
|
|
ConstructOperate.StartConstruct(unit, id, peopleId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return resp.Error; |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
@ -92,17 +94,18 @@ namespace ET
|
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async ETTask<int> StopConstruct(Unit unit, long id, long peopleId) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
M2C_StopConstruct resp = |
|
|
|
|
await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(new C2M_StopConstruct() { Id = id,peopleId = peopleId}) as |
|
|
|
|
await unit.ZoneScene().GetComponent<SessionComponent>().Session |
|
|
|
|
.Call(new C2M_StopConstruct() { Id = id, peopleId = peopleId }) as |
|
|
|
|
M2C_StopConstruct; |
|
|
|
|
if (resp.Error == ErrorCode.ERR_Success) |
|
|
|
|
{ |
|
|
|
|
ConstructOperate.StopConstruct(unit,id,peopleId); |
|
|
|
|
ConstructOperate.StopConstruct(unit, id, peopleId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return resp.Error; |
|
|
|
@ -113,6 +116,22 @@ namespace ET
|
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async ETTask<int> ConstructFinish(Unit unit, long id) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
M2C_ConstructFinish resp = |
|
|
|
|
await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(new C2M_ConstructFinish() { ConstructId = id }) as |
|
|
|
|
M2C_ConstructFinish; |
|
|
|
|
|
|
|
|
|
return resp.Error; |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
|
Log.Error(e.ToString()); |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |