#pragma once
#include "global.h"
#include "MyView.h"
class Entity;
//血条受伤动画
struct BossHpBarDamageUnit
{
	int c;//颜色
	float from;//从血量
	float to;//掉至多少血
	int alpha;//伤害
};

class UiBossHpBar
{
public:
	void Init(MyDX11Renderer* pRenderer, MyView* pView);
	void Draw();
	void Step();
	void BossReady(std::weak_ptr<Entity> boss, int lineSize);
	void Reset();
	bool InBossFight();
private:
	void DrawBar(int c, float hpPercent, bool last = false);
	void DrawDmgBar(float percentSrc, float percentDst, Uint8 alpha);
	void DrawNumLine(int numLine);
	void DrawDamageAni();//绘制掉血动画
	void DrawAll(int hp);
	float H2P(float v) const;
	int H2L(float v) const;
	void HpCalcPercent(BossHpBarDamageUnit* b, float* out_percentSrc, float* out_percentDst);
	void SetDamageAni(int hpFrom, int hpTo);//设置一次伤害动画
	bool HpInSameLine(int hpSrc, int hpDst);//确认血量是否在同一行
	MyDX11Renderer* pRenderer = nullptr;
	MyView* pView = nullptr;
	//Boss血条
	MyTextureAndSRV* texture_bossHpBar = nullptr;
	MyTextureAndSRV* texture_bossdmgbar = nullptr;
	std::weak_ptr<Entity> boss;//指定的boss单位
	int lineSize = 0;//每行多少血
	//减血动画
	std::list<BossHpBarDamageUnit> bossHpbar_damageList;
	int dmgSpeed = 4;//伤害动画速度
	//检测掉血
	int last_hp = 0;
};

