|
|
|
#pragma once
|
|
|
|
#include "olcPixelGameEngine.h"
|
|
|
|
#include "Animation.h"
|
|
|
|
#include "olcUTIL_Animate2D.h"
|
|
|
|
|
|
|
|
enum MonsterStrategy{
|
|
|
|
RUN_TOWARDS,
|
|
|
|
SHOOT_AFAR
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MonsterName{
|
|
|
|
SLIME_GREEN,
|
|
|
|
SLIME_BLUE,
|
|
|
|
SLIME_RED,
|
|
|
|
SLIME_YELLOW,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MonsterData{
|
|
|
|
private:
|
|
|
|
int hp;
|
|
|
|
int atk;
|
|
|
|
float moveSpd;//1.0=100%
|
|
|
|
float size;
|
|
|
|
std::vector<AnimationState> animations;
|
|
|
|
MonsterStrategy strategy;
|
|
|
|
MonsterName type;
|
|
|
|
public:
|
|
|
|
MonsterData();
|
|
|
|
//When specifying animations, the first one will become the default animation.
|
|
|
|
MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS);
|
|
|
|
int GetHealth();
|
|
|
|
int GetAttack();
|
|
|
|
float GetMoveSpdMult();
|
|
|
|
float GetSizeMult();
|
|
|
|
MonsterName GetType();
|
|
|
|
MonsterStrategy GetAIStrategy();
|
|
|
|
std::vector<AnimationState>GetAnimations(){
|
|
|
|
return animations;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Monster{
|
|
|
|
private:
|
|
|
|
vf2d pos;
|
|
|
|
int hp,maxhp;
|
|
|
|
int atk;
|
|
|
|
float moveSpd;
|
|
|
|
float size;
|
|
|
|
MonsterStrategy strategy;
|
|
|
|
Animate2D::Animation<AnimationState>animation;
|
|
|
|
Animate2D::AnimationState internal_animState;
|
|
|
|
float randomFrameOffset=0.f;
|
|
|
|
float deathTimer=0.f;
|
|
|
|
MonsterName type;
|
|
|
|
AnimationState GetDeathAnimationName();
|
|
|
|
public:
|
|
|
|
Monster();
|
|
|
|
Monster(vf2d pos,MonsterData data);
|
|
|
|
vf2d&GetPos();
|
|
|
|
int GetHealth();
|
|
|
|
int GetAttack();
|
|
|
|
float GetMoveSpdMult();
|
|
|
|
float GetSizeMult();
|
|
|
|
Animate2D::Frame GetFrame();
|
|
|
|
void UpdateAnimation(AnimationState state);
|
|
|
|
bool Update(float fElapsedTime);
|
|
|
|
void Hurt(int damage);
|
|
|
|
bool IsAlive();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MonsterSpawner{
|
|
|
|
private:
|
|
|
|
vf2d pos;
|
|
|
|
int range;
|
|
|
|
std::vector<std::pair<MonsterName,vf2d>>monsters;
|
|
|
|
bool triggered=false;
|
|
|
|
public:
|
|
|
|
MonsterSpawner();
|
|
|
|
//For the monster list, the second pair item is the position relative to the spawner to spawn the monster.
|
|
|
|
MonsterSpawner(vf2d pos,int range,std::vector<std::pair<MonsterName,vf2d>>MONSTER_LIST);
|
|
|
|
bool SpawnTriggered();
|
|
|
|
int GetRange();
|
|
|
|
vf2d GetPos();
|
|
|
|
void SetTriggered(bool trigger,bool spawnMonsters=true);
|
|
|
|
};
|