zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Server/Hotfix/Game/System/UI/FamilyBossSystem.cs

55 lines
1.8 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Collections.Generic;
namespace ET
{
public class FamilyBossDestroySystem : DestroySystem<FamilyBoss>
{
public override void Destroy(FamilyBoss self)
{
self.Destroy();
}
}
public static class FamilyBossSystem
{
public static int GetBossHp(this FamilyBoss self, int bossId)
{
2021-04-11 19:50:39 +08:00
if (!self.bossHpDic.TryGetValue(bossId, out int hp))
2021-04-08 20:09:59 +08:00
{
Log.Error($"bossHpDic has not the key = {bossId}");
hp = 0;
}
return hp;
}
public static void SetBossHp(this FamilyBoss self, int bossId, int hp)
{
if (hp <= 0)
{
hp = 0;
if (self.lockedMaxId == bossId) self.lockedMaxId++;
}
self.bossHpDic[bossId] = hp;
FamilyBossComponent.instance.Save(self).Coroutine();
}
public static LinkedList<BossDamageMap> GetRankList(this FamilyBoss self, int bossId)
{
2021-04-11 19:50:39 +08:00
self.rankDic.TryGetValue(bossId, out LinkedList<BossDamageMap> list);
2021-04-08 20:09:59 +08:00
return list;
}
public static void InsertDamageInfo(this FamilyBoss self, int bossId, BossDamageMap bossDamageMap)
{
2021-04-11 19:50:39 +08:00
LinkedList<BossDamageMap> list = self.GetRankList(bossId);
2021-04-08 20:09:59 +08:00
LinkedListHelper.InsertToLinkedListAndSort(list, bossDamageMap, (p1, p2) => p1.TotalDamage > p2.TotalDamage);
FamilyBossComponent.instance.Save(self).Coroutine();
}
public static void Destroy(this FamilyBoss self)
{
self.bossHpDic.Clear();
2021-04-11 19:50:39 +08:00
foreach (KeyValuePair<int, LinkedList<BossDamageMap>> item in self.rankDic)
2021-04-08 20:09:59 +08:00
{
item.Value.Clear();
}
}
}
}