CTT/Server/Hotfix/Game/Event/Battle/DamageEventEvent.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using ET.EventType;
using System;
using System.Collections.Generic;
namespace ET
{
public class DamageEventEvent : AEvent<DamageEvent>
{
public override async ETTask Run(DamageEvent args)
{
try
{
2021-04-11 19:50:39 +08:00
Unit attacker = args.attacker;
2021-05-01 11:27:41 +08:00
CopyBattle battleBase = BattleMgrCompnent.Instance.GetBattle(attacker);
2021-04-08 20:09:59 +08:00
if (battleBase == null)
{
Log.Error($"battleBase is null");
return;
}
2021-05-01 11:27:41 +08:00
if (battleBase.battleType == BattleType.FamilyBoss)
2021-04-08 20:09:59 +08:00
{
2021-05-01 11:27:41 +08:00
ChangeDamageData(battleBase,attacker, args.damage);
2021-04-08 20:09:59 +08:00
}
}
catch (Exception e)
{
Log.Error(e);
}
await ETTask.CompletedTask;
2021-05-01 11:27:41 +08:00
}
public static void ChangeDamageData( CopyBattle battleBase, Unit unit, int damage)
{
BossDamageMap map = battleBase.bossDamageMap;
map.TotalDamage += damage;
for (int i = map.DamageList.Count - 1; i >= 0; i--)
{
BossDamagePerMemberMap info = map.DamageList[i];
if (info.Id == unit.Id)
{
info.Damage += damage;
return;
}
}
2021-04-08 20:09:59 +08:00
}
}
}