2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
[ActorMessageHandler]
|
|
|
|
|
public class C2M_UseMainUIGoodsHandler : AMActorLocationRpcHandler<Unit, C2M_UseMainUIGoods, M2C_UseMainUIGoods>
|
|
|
|
|
{
|
|
|
|
|
protected override async ETTask Run(Unit unit, C2M_UseMainUIGoods request, M2C_UseMainUIGoods response, Action reply)
|
|
|
|
|
{
|
|
|
|
|
if (!unit.IsAlive)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "您已经死亡!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
UserSetting userSetting = unit.GetComponent<UserSetting>();
|
|
|
|
|
if (userSetting == null)
|
|
|
|
|
{
|
|
|
|
|
Log.Error("userSetting == null");
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!userSetting.canUse)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "公共冷却中!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
MainUISlot[] arr = userSetting.GetMainUISlots();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (request.SlotId < 0 || request.SlotId >= arr.Length)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(new Exception($"*************************************" +
|
|
|
|
|
$"[等级1]:" +
|
|
|
|
|
$" 格子index错误,作弊嫌疑!\n" +
|
|
|
|
|
$" 【玩家unitId = {unit.Id}】,\n" +
|
|
|
|
|
$"*************************************"));
|
|
|
|
|
response.Message = "请求信息错误,请注意您的行为!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
MainUISlot mainUISlot = arr[request.SlotId];
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (mainUISlot == null)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "点击了空格子,请拖入技能或者物品!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int itemId = mainUISlot.RealId;
|
|
|
|
|
if (itemId == 0)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "点击了空格子,请拖入技能或者物品!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-11 19:50:39 +08:00
|
|
|
|
string ret = (await ItemComponent.Instance.UseGoods(unit, itemId: itemId)).Item1;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (ret==null)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (MainUISlot __mainUISlot in userSetting.GetMainUISlots())
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (__mainUISlot?.RealId == itemId)
|
|
|
|
|
{
|
|
|
|
|
__mainUISlot.Count--;
|
|
|
|
|
if (__mainUISlot.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
__mainUISlot.RealId = 0;
|
|
|
|
|
__mainUISlot.MainUIType = MainUIType.NoneSlot;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BagHelper.GetBagInfo(unit, response.BagMapList);
|
|
|
|
|
MainUIHelper.GetMainUISlotInfo(userSetting, response.MainUISlotList);
|
|
|
|
|
userSetting.StartCD(MainUIType.ItemSlot, itemId, Bag.UseTimeInterval);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
response.Message = ret;
|
|
|
|
|
}
|
|
|
|
|
reply();
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|