Super Knight : Enter the Dungeon
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class HPBarBoss : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Slider hpBar;
|
|
|
|
|
public Image icon;
|
|
|
|
|
|
|
|
|
|
Character boss;
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
EventManager.Instance.Add("BossAppear", BossAppear);
|
|
|
|
|
}
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
EventManager.Instance.Remove("BossAppear", BossAppear);
|
|
|
|
|
}
|
|
|
|
|
public void BossAppear(object value)
|
|
|
|
|
{
|
|
|
|
|
boss = (Character)value;
|
|
|
|
|
|
|
|
|
|
if (boss == null)
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
boss.OnHit += OnHit;
|
|
|
|
|
boss.OnDie += OnDie;
|
|
|
|
|
|
|
|
|
|
hpBar.value = boss.HP / (float)boss.HP_Max;
|
|
|
|
|
|
|
|
|
|
icon.sprite = SpriteManager.Instance.SpriteGet("AtlasIngame", $"bossIcon{boss.NAME}");
|
|
|
|
|
|
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
if (boss != null)
|
|
|
|
|
{
|
|
|
|
|
boss.OnHit -= OnHit;
|
|
|
|
|
boss.OnDie -= OnDie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boss = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnHit(Character attacker, Vector3 dir, float knockBackAddRate, bool MOTION_FORCE, System.Action OnEnd)
|
|
|
|
|
{
|
|
|
|
|
hpBar.value = boss.HP / (float)boss.HP_Max;
|
|
|
|
|
}
|
|
|
|
|
void OnDie(Character attacker, Vector3 dir)
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|