85 lines
2.9 KiB
C#
85 lines
2.9 KiB
C#
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;
|
||
}
|
||
MainUISlot[] arr = userSetting.GetMainUISlots();
|
||
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;
|
||
}
|
||
MainUISlot mainUISlot = arr[request.SlotId];
|
||
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)
|
||
{
|
||
SkillAI ai = unit.GetComponent<SkillAI>();
|
||
string ret = ai.PlaySkill(skillId, now);
|
||
if (ret != null)
|
||
response.Message = ret;
|
||
else
|
||
{
|
||
SkillMgrComponent skillMgr = unit.GetComponent<SkillMgrComponent>();
|
||
SkillLogic skillLogic = skillMgr.GetSkill(skillId);
|
||
userSetting.StartCD( MainUIType.SkillSlot,skillId,skillLogic.skillConfig.CD);
|
||
}
|
||
}
|
||
reply();
|
||
await ETTask.CompletedTask;
|
||
}
|
||
}
|
||
} |