Added hp and attack actions, and labels
This commit is contained in:
1 parent
393ebcd831
commit
44cc0fba67
8 files changed
+166
-9
No files matched your search
@@ -14,6 +14,8 @@
|
||||
|
||||
namespace ZL {
|
||||
|
||||
class TextRenderer;
|
||||
|
||||
enum class AnimationState {
|
||||
STAND = 0,
|
||||
WALK = 1,
|
||||
@@ -66,6 +68,21 @@ public:
|
||||
// particles against that camera before its VBO is uploaded.
|
||||
void prepareHitSparksForDraw(const Eigen::Matrix4f& cameraViewMatrix);
|
||||
|
||||
// Draws the NPC name floating above this character in 2D screen space.
|
||||
// No-op for the player, for dead characters, or if npcName is empty.
|
||||
// The text is green for peaceful (canAttack == false) NPCs, red otherwise.
|
||||
void drawName(TextRenderer& textRenderer,
|
||||
const Eigen::Matrix4f& cameraViewMatrix,
|
||||
const Eigen::Matrix4f& projectionMatrix);
|
||||
|
||||
// Draws a horizontal health bar above this character in 2D screen space.
|
||||
// Visible only for the player and hostile NPCs (canAttack == true), and
|
||||
// only while hp > 0. The left portion is green (hp / initialHp) and the
|
||||
// remainder is red.
|
||||
void drawHealthBar(Renderer& renderer,
|
||||
const Eigen::Matrix4f& cameraViewMatrix,
|
||||
const Eigen::Matrix4f& projectionMatrix);
|
||||
|
||||
// Public: read by Game for camera tracking and ray-cast origin
|
||||
Eigen::Vector3f position = Eigen::Vector3f(0.f, 0.f, 0.f);
|
||||
float facingAngle = 0.0f;
|
||||
@@ -83,6 +100,9 @@ public:
|
||||
std::string npcName;
|
||||
bool giftReceived = false;
|
||||
float hp = 100.f;
|
||||
// Captured lazily from `hp` on the first update() tick if left at zero;
|
||||
// set explicitly if you need a different reference for the health bar.
|
||||
float initialHp = 0.f;
|
||||
|
||||
|
||||
int battle_state = 0;
|
||||
@@ -112,6 +132,7 @@ private:
|
||||
|
||||
std::map<AnimationState, BoneAnimationDataNew> animations;
|
||||
VertexRenderStruct modelMutable;
|
||||
VertexRenderStruct healthBarMesh;
|
||||
std::unordered_map<std::string, std::shared_ptr<Texture>> meshTextures;
|
||||
|
||||
Eigen::Vector3f walkTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
|
||||
|
||||
Reference in new issue
Block a user