2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using ET;
|
|
|
|
|
using Cal.DataTable;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
[ActorMessageHandler]
|
|
|
|
|
public class C2M_UseMainUISkillHandler : AMActorLocationRpcHandler<Unit, C2M_UseMainUISkill, M2C_UseMainUISkill>
|
|
|
|
|
{
|
|
|
|
|
protected override async ETTask Run(Unit unit, C2M_UseMainUISkill request, M2C_UseMainUISkill 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.IsAutoSkill)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "自动战斗中...";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!userSetting.canUse)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "公共CD冷却中!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(unit.teamState != TeamState.Fight)
|
|
|
|
|
{
|
|
|
|
|
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(($" request.SlotId = {request.SlotId} is out of arr when spell skill 【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】"));
|
|
|
|
|
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 skillId = mainUISlot.RealId;
|
|
|
|
|
if (skillId == 0)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "点击了空格子,请拖入技能或者物品!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
long now = TimeHelper.ClientNow();
|
|
|
|
|
if (mainUISlot.MainUIType == MainUIType.SkillSlot)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
SkillAI ai = unit.GetComponent<SkillAI>();
|
|
|
|
|
string ret = ai.PlaySkill(skillId, now);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (ret != null)
|
|
|
|
|
response.Message = ret;
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
SkillMgrComponent skillMgr = unit.GetComponent<SkillMgrComponent>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
SkillLogic skillLogic = skillMgr.GetSkill(skillId);
|
|
|
|
|
userSetting.StartCD( MainUIType.SkillSlot,skillId,skillLogic.skillConfig.CD);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
reply();
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|