|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
namespace ET |
|
|
|
|
{ |
|
|
|
|
[FriendClass(typeof(Unit))] |
|
|
|
|
[FriendClass(typeof (Unit))] |
|
|
|
|
public static class CheatHelper |
|
|
|
|
{ |
|
|
|
|
public static async ETTask<int> AddItem(Unit unit, int id, int type, uint num) |
|
|
|
@ -22,18 +23,18 @@ namespace ET
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
storeComponent.Remove(id, (int)Math.Abs(num)); |
|
|
|
|
storeComponent.Remove(id, (int) Math.Abs(num)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (type == 2) |
|
|
|
|
{ |
|
|
|
|
if (id == NumericType.Water) |
|
|
|
|
{ |
|
|
|
|
unit.Water += num; |
|
|
|
|
unit.Water += num; |
|
|
|
|
} |
|
|
|
|
else if (id == NumericType.Food) |
|
|
|
|
{ |
|
|
|
|
unit.Food += num; |
|
|
|
|
unit.Food += num; |
|
|
|
|
} |
|
|
|
|
else if (id == NumericType.SilverTael) |
|
|
|
|
{ |
|
|
|
@ -109,5 +110,27 @@ namespace ET
|
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static async ETTask<int> AddItemList(Unit unit, List<int> configIds, List<int> nums) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
C2M_CheatItemList msg = new C2M_CheatItemList() { ConfigIds = configIds, Nums = nums }; |
|
|
|
|
M2C_CheatItemList resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_CheatItemList; |
|
|
|
|
if (resp.Error == ErrorCode.ERR_Success) |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < configIds.Count; i++) |
|
|
|
|
{ |
|
|
|
|
unit.GetComponent<StoreComponent>().Add(configIds[i], nums[i]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return resp.Error; |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
|
Log.Error(e.ToString()); |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |