55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
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)
|
|
{
|
|
if (!self.bossHpDic.TryGetValue(bossId, out int hp))
|
|
{
|
|
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)
|
|
{
|
|
self.rankDic.TryGetValue(bossId, out LinkedList<BossDamageMap> list);
|
|
return list;
|
|
}
|
|
public static void InsertDamageInfo(this FamilyBoss self, int bossId, BossDamageMap bossDamageMap)
|
|
{
|
|
LinkedList<BossDamageMap> list = self.GetRankList(bossId);
|
|
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();
|
|
foreach (KeyValuePair<int, LinkedList<BossDamageMap>> item in self.rankDic)
|
|
{
|
|
item.Value.Clear();
|
|
}
|
|
}
|
|
}
|
|
}
|