2021-04-08 20:09:59 +08:00
|
|
|
|
using Cal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public class AttackComponentAwakeSystem : AwakeSystem<AttackComponent>
|
|
|
|
|
{
|
|
|
|
|
public override void Awake(AttackComponent self)
|
|
|
|
|
{
|
|
|
|
|
self.multipleDamageX10000 = 1;
|
|
|
|
|
self.playAmount = 1;
|
|
|
|
|
self.isFirstAtk = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class AttackComponentDstroySystem : DestroySystem<AttackComponent>
|
|
|
|
|
{
|
|
|
|
|
public override void Destroy(AttackComponent self)
|
|
|
|
|
{
|
|
|
|
|
self.attacker = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static class AttackComponentSystem
|
|
|
|
|
{
|
2021-04-18 15:54:51 +08:00
|
|
|
|
public static void Clear(this AttackComponent self)
|
|
|
|
|
{
|
|
|
|
|
self.attacker = null;
|
|
|
|
|
self.attackData = default;
|
|
|
|
|
self.isFirstAtk = false;
|
|
|
|
|
}
|
2021-04-08 20:09:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 《选择目标》
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="self"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool StartSpellSkill(this AttackComponent self, SkillLogic skillLogic)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Unit unit = self.GetParent<Unit>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
self.isFirstAtk = true;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
TargetableUnitComponent targetCompoennt = self.Parent.GetComponent<TargetableUnitComponent>();
|
|
|
|
|
List<Unit> allList = targetCompoennt.GetAllTarget();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
|
2021-05-16 17:22:42 +08:00
|
|
|
|
var config = skillLogic.skillLogicConfig;
|
|
|
|
|
SkillTypes skillTypes = config.skillType;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
|
2021-05-16 17:22:42 +08:00
|
|
|
|
skillLogic.HandleEvent(SkillEventCondition.当技能施法前, new SkillSender
|
|
|
|
|
{
|
|
|
|
|
caster = unit,
|
|
|
|
|
skillLogic = skillLogic,
|
|
|
|
|
});
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return skillTypes switch
|
|
|
|
|
{
|
|
|
|
|
SkillTypes.普通 => SpellGeneralSkill(self, unit, skillLogic, allList),
|
|
|
|
|
SkillTypes.被动 => false,
|
|
|
|
|
SkillTypes.引导 => SpellChannelSkill(self, unit, skillLogic, allList),
|
|
|
|
|
SkillTypes.开关 => SpellToggleSkill(self, unit, skillLogic, allList),
|
|
|
|
|
_ => false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool SpellGeneralSkill(AttackComponent self, Unit unit, SkillLogic skillLogic, List<Unit> allList)
|
|
|
|
|
{
|
2021-05-16 17:22:42 +08:00
|
|
|
|
int playAmount = skillLogic.GetPlayAmount();
|
|
|
|
|
Log.Info($"{playAmount}");
|
|
|
|
|
for (int i = playAmount - 1; i >= 0; i--)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
SpellSkill(self, unit, skillLogic, allList).Coroutine();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
private static bool SpellChannelSkill(AttackComponent self, Unit unit, SkillLogic skillLogic, List<Unit> allList)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
SkillLogicConfig skillConfig = skillLogic.skillLogicConfig;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
int duration = skillConfig.duration;
|
|
|
|
|
int interval = skillConfig.interval;
|
|
|
|
|
SpellChannelSkillAsync(self, unit, skillLogic, duration, interval, allList).Coroutine();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async ETVoid SpellChannelSkillAsync(AttackComponent self, Unit unit, SkillLogic skillLogic, int duration, int interval, List<Unit> allList)
|
|
|
|
|
{
|
|
|
|
|
if (AppConfig.inst.showBattleSkillInfo)
|
|
|
|
|
Log.Info($"{unit}释放技能:【{skillLogic.skillLogicConfig.skillName}({skillLogic.skillConfigId})】");
|
|
|
|
|
//!广播释放技能
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit u in allList)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
M2C_PlaySkill m2C_PlayerSkill = new M2C_PlaySkill
|
|
|
|
|
{
|
|
|
|
|
SkillId = skillLogic.skillId,
|
|
|
|
|
UnitId = unit.Id,
|
|
|
|
|
};
|
|
|
|
|
MessageHelper.SendActor(u, m2C_PlayerSkill);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//!动画开始到产生特效的时间
|
|
|
|
|
int delayTime = 1000;
|
|
|
|
|
await TimerComponent.Instance.WaitAsync(delayTime);
|
|
|
|
|
skillLogic.HandleEvent(SkillEventCondition.当技能引导开始, new SkillSender
|
|
|
|
|
{
|
|
|
|
|
caster = unit,
|
|
|
|
|
skillLogic = skillLogic,
|
|
|
|
|
});
|
2021-04-11 19:50:39 +08:00
|
|
|
|
long start = TimeHelper.ClientNow();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
long now = start;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
await TimerComponent.Instance.WaitTillAsync(now + interval);
|
|
|
|
|
now = TimeHelper.ClientNow();
|
|
|
|
|
skillLogic.HandleEvent(SkillEventCondition.当技能引导时, new SkillSender
|
|
|
|
|
{
|
|
|
|
|
caster = unit,
|
|
|
|
|
skillLogic = skillLogic
|
|
|
|
|
});
|
|
|
|
|
} while (now + interval <= start + duration);
|
|
|
|
|
|
|
|
|
|
skillLogic.HandleEvent(SkillEventCondition.当技能引导完成, new SkillSender
|
|
|
|
|
{
|
|
|
|
|
caster = unit,
|
|
|
|
|
skillLogic = skillLogic,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool SpellToggleSkill(AttackComponent self, Unit unit, SkillLogic skillLogic, List<Unit> allList)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async ETVoid SpellSkill(AttackComponent self, Unit unit, SkillLogic skillLogic, List<Unit> allList)
|
|
|
|
|
{
|
|
|
|
|
if (AppConfig.inst.showBattleSkillInfo)
|
|
|
|
|
Log.Info($"{unit}释放技能:【{skillLogic.skillLogicConfig.skillName}({skillLogic.skillConfigId})】");
|
|
|
|
|
skillLogic.HandleEvent(SkillEventCondition.当技能施法开始, new SkillSender
|
|
|
|
|
{
|
|
|
|
|
caster = unit,
|
|
|
|
|
skillLogic = skillLogic
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//!广播释放技能
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit u in allList)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
M2C_PlaySkill m2C_PlayerSkill = new M2C_PlaySkill
|
|
|
|
|
{
|
|
|
|
|
SkillId = skillLogic.skillId,
|
|
|
|
|
UnitId = unit.Id,
|
|
|
|
|
};
|
|
|
|
|
MessageHelper.SendActor(u, m2C_PlayerSkill);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//!动画开始到产生特效的时间
|
|
|
|
|
int delayTime = 1000;
|
|
|
|
|
await TimerComponent.Instance.WaitAsync(delayTime);
|
|
|
|
|
self.EndSpellSkill(unit, skillLogic);
|
|
|
|
|
}
|
|
|
|
|
public static void EndSpellSkill(this AttackComponent self, Unit unit, SkillLogic skillLogic)
|
|
|
|
|
{
|
|
|
|
|
skillLogic.HandleEvent(SkillEventCondition.当技能施法时, new SkillSender
|
|
|
|
|
{
|
|
|
|
|
caster = unit,
|
|
|
|
|
skillLogic = skillLogic
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取子弹数据,里面包含伤害等
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static BallisticData GetAttackData(this AttackComponent self)
|
|
|
|
|
{
|
|
|
|
|
return self.attackData;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 执行伤害
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void AttackTarget(this AttackComponent self, Unit target, BallisticData data, ISkillSender skillSender, bool applyBallisticData = true)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Unit unit = self.GetParent<Unit>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (AppConfig.inst.showBattleDamageInfo)
|
|
|
|
|
Log.Debug($"{unit.Id}对{target.Id},伤害数据2:{data}");
|
|
|
|
|
if (data.value == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (applyBallisticData)
|
|
|
|
|
self.attackData = data;
|
|
|
|
|
|
|
|
|
|
if (!target || !target.IsAlive)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
// if(AppConfig.inst.isTest)
|
|
|
|
|
// Log.Warning($"目标{target.Id}已经死亡 ");
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
AttackComponent attackComponent = target.GetComponent<AttackComponent>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (attackComponent!=null)
|
|
|
|
|
attackComponent.attacker = unit;
|
|
|
|
|
target.GetComponent<UnitEnermy>().unit = unit;
|
|
|
|
|
target.GetComponent<BattleComponent>().Damage(data, skillSender);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 执行治疗
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void TreatTarget(this AttackComponent self, Unit target, BallisticData ballisticData, ISkillSender skillSender)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Unit unit = self.GetParent<Unit>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (AppConfig.inst.showBattleDamageInfo)
|
|
|
|
|
Log.Debug($"{self.GetParent<Unit>().Id}对{target.Id},治疗数据:{ballisticData}");
|
2021-04-11 19:50:39 +08:00
|
|
|
|
AttackComponent attackComponent = target.GetComponent<AttackComponent>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
attackComponent.attacker = unit;
|
|
|
|
|
target.GetComponent<BattleComponent>().Treat(ballisticData, skillSender);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|