Consolidated jump and shoot animations for monsters into MonsterData.
This commit is contained in:
parent
0105910720
commit
f92e0f7213
@ -1,12 +1,6 @@
|
||||
#pragma once
|
||||
#include "Bullet.h"
|
||||
|
||||
struct GenericBullet:public Bullet{
|
||||
GenericBullet(vf2d pos,vf2d vel,float radius,int damage,Pixel col=WHITE);
|
||||
GenericBullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,Pixel col=WHITE);
|
||||
void Update(float fElapsedTime)override;
|
||||
};
|
||||
|
||||
struct EnergyBolt:public Bullet{
|
||||
float lastParticleSpawn=0;
|
||||
EnergyBolt(vf2d pos,vf2d vel,float radius,int damage,Pixel col=WHITE);
|
||||
|
@ -12,33 +12,6 @@ INCLUDE_DAMAGENUMBER_LIST
|
||||
INCLUDE_game
|
||||
INCLUDE_BULLET_LIST
|
||||
|
||||
MonsterData::MonsterData(){}
|
||||
MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg):
|
||||
type(type),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg){
|
||||
}
|
||||
int MonsterData::GetHealth(){
|
||||
return hp;
|
||||
}
|
||||
int MonsterData::GetAttack(){
|
||||
return atk;
|
||||
}
|
||||
float MonsterData::GetMoveSpdMult(){
|
||||
return moveSpd;
|
||||
}
|
||||
float MonsterData::GetSizeMult(){
|
||||
return size;
|
||||
}
|
||||
int MonsterData::GetCollisionDmg(){
|
||||
return collisionDmg;
|
||||
}
|
||||
MonsterName MonsterData::GetType(){
|
||||
return type;
|
||||
}
|
||||
MonsterStrategy MonsterData::GetAIStrategy(){
|
||||
return strategy;
|
||||
}
|
||||
|
||||
Monster::Monster(){}
|
||||
Monster::Monster(vf2d pos,MonsterData data):
|
||||
pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),strategy(data.GetAIStrategy()),type(data.GetType()){
|
||||
bool firstAnimation=true;
|
||||
@ -81,36 +54,10 @@ void Monster::UpdateAnimation(AnimationState state){
|
||||
animation.ChangeState(internal_animState,state);
|
||||
}
|
||||
void Monster::PerformJumpAnimation(){
|
||||
switch(type){
|
||||
case SLIME_GREEN:{
|
||||
animation.ChangeState(internal_animState,AnimationState::GREEN_SLIME_JUMP);
|
||||
}break;
|
||||
case SLIME_BLUE:{
|
||||
animation.ChangeState(internal_animState,AnimationState::BLUE_SLIME_JUMP);
|
||||
}break;
|
||||
case SLIME_RED:{
|
||||
animation.ChangeState(internal_animState,AnimationState::RED_SLIME_JUMP);
|
||||
}break;
|
||||
case SLIME_YELLOW:{
|
||||
animation.ChangeState(internal_animState,AnimationState::YELLOW_SLIME_JUMP);
|
||||
}break;
|
||||
}
|
||||
animation.ChangeState(internal_animState,MONSTER_DATA[type].GetJumpAnimation());
|
||||
}
|
||||
void Monster::PerformShootAnimation(){
|
||||
switch(type){
|
||||
case SLIME_GREEN:{
|
||||
animation.ChangeState(internal_animState,AnimationState::GREEN_SLIME_SPIT);
|
||||
}break;
|
||||
case SLIME_BLUE:{
|
||||
animation.ChangeState(internal_animState,AnimationState::BLUE_SLIME_SPIT);
|
||||
}break;
|
||||
case SLIME_RED:{
|
||||
animation.ChangeState(internal_animState,AnimationState::RED_SLIME_SPIT);
|
||||
}break;
|
||||
case SLIME_YELLOW:{
|
||||
animation.ChangeState(internal_animState,AnimationState::YELLOW_SLIME_SPIT);
|
||||
}break;
|
||||
}
|
||||
animation.ChangeState(internal_animState,MONSTER_DATA[type].GetShootAnimation());
|
||||
}
|
||||
bool Monster::SetX(float x){
|
||||
vf2d newPos={x,pos.y};
|
||||
@ -207,7 +154,9 @@ bool Monster::Update(float fElapsedTime){
|
||||
queueShotTimer-=fElapsedTime;
|
||||
if(queueShotTimer<0){
|
||||
queueShotTimer=0;
|
||||
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos+vf2d{0,-4},geom2d::line(pos+vf2d{0,-4},game->GetPlayer().GetPos()).vector().norm()*24*3.f,2,GetAttack(),{75/2,162/2,225/2})));
|
||||
{
|
||||
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos + vf2d{ 0,-4 }, geom2d::line(pos + vf2d{ 0,-4 }, game->GetPlayer().GetPos()).vector().norm() * 24 * 3.f, 2, GetAttack(), { 75 / 2,162 / 2,225 / 2 })));
|
||||
}
|
||||
}
|
||||
}
|
||||
geom2d::line line(pos,game->GetPlayer().GetPos());
|
||||
|
@ -32,10 +32,13 @@ struct MonsterData{
|
||||
MonsterStrategy strategy;
|
||||
MonsterName type;
|
||||
int collisionDmg;
|
||||
AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S;
|
||||
AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S;
|
||||
public:
|
||||
MonsterData();
|
||||
//When specifying animations, the first one will become the default animation. The last becomes the death 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 collisionDmg=0);
|
||||
MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS,int collisionDmg=0
|
||||
,AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S,AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S);
|
||||
int GetHealth();
|
||||
int GetAttack();
|
||||
float GetMoveSpdMult();
|
||||
@ -43,6 +46,8 @@ struct MonsterData{
|
||||
MonsterName GetType();
|
||||
MonsterStrategy GetAIStrategy();
|
||||
int GetCollisionDmg();
|
||||
AnimationState GetJumpAnimation();
|
||||
AnimationState GetShootAnimation();
|
||||
std::vector<AnimationState>GetAnimations(){
|
||||
return animations;
|
||||
}
|
||||
@ -73,8 +78,9 @@ struct Monster{
|
||||
AnimationState GetDeathAnimationName();
|
||||
bool hasHitPlayer=false;
|
||||
bool canMove=true; //Set to false when stuck due to collisions.
|
||||
protected:
|
||||
public:
|
||||
Monster();
|
||||
Monster()=delete;
|
||||
Monster(vf2d pos,MonsterData data);
|
||||
vf2d&GetPos();
|
||||
int GetHealth();
|
||||
|
@ -2,9 +2,46 @@
|
||||
#include "Monster.h"
|
||||
#include "Animation.h"
|
||||
|
||||
|
||||
std::map<MonsterName,MonsterData>MONSTER_DATA={
|
||||
{SLIME_GREEN,MonsterData(MonsterName::SLIME_GREEN,10,5,{{AnimationState::GREEN_SLIME_IDLE,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_ROLL,AnimationState::GREEN_SLIME_DIE,AnimationState::GREEN_SLIME_SPIT}},1.1f,0.8f,MonsterStrategy::RUN_TOWARDS,5)},
|
||||
{SLIME_BLUE,MonsterData(MonsterName::SLIME_BLUE,30,10,{{AnimationState::BLUE_SLIME_IDLE,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_ROLL,AnimationState::BLUE_SLIME_DIE,AnimationState::BLUE_SLIME_SPIT}},0.8f,1.0f,MonsterStrategy::SHOOT_AFAR)},
|
||||
{SLIME_RED,MonsterData(MonsterName::SLIME_RED,25,10,{{AnimationState::RED_SLIME_IDLE,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_ROLL,AnimationState::RED_SLIME_DIE,AnimationState::RED_SLIME_SPIT}},0.95f,1.2f,MonsterStrategy::RUN_TOWARDS,10)},
|
||||
{SLIME_YELLOW,MonsterData(MonsterName::SLIME_YELLOW,175,10,{{AnimationState::YELLOW_SLIME_IDLE,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_ROLL,AnimationState::YELLOW_SLIME_DIE,AnimationState::YELLOW_SLIME_SPIT}},0.4f,1.6f,MonsterStrategy::RUN_TOWARDS,15)},
|
||||
{SLIME_GREEN,MonsterData(MonsterName::SLIME_GREEN,10,5,{{AnimationState::GREEN_SLIME_IDLE,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_ROLL,AnimationState::GREEN_SLIME_DIE,AnimationState::GREEN_SLIME_SPIT}},1.1f,0.8f,MonsterStrategy::RUN_TOWARDS,5,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_SPIT)},
|
||||
{SLIME_BLUE,MonsterData(MonsterName::SLIME_BLUE,30,10,{{AnimationState::BLUE_SLIME_IDLE,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_ROLL,AnimationState::BLUE_SLIME_DIE,AnimationState::BLUE_SLIME_SPIT}},0.8f,1.0f,MonsterStrategy::SHOOT_AFAR,0,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_SPIT)},
|
||||
{SLIME_RED,MonsterData(MonsterName::SLIME_RED,25,10,{{AnimationState::RED_SLIME_IDLE,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_ROLL,AnimationState::RED_SLIME_DIE,AnimationState::RED_SLIME_SPIT}},0.95f,1.2f,MonsterStrategy::RUN_TOWARDS,10,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_SPIT)},
|
||||
{SLIME_YELLOW,MonsterData(MonsterName::SLIME_YELLOW,175,10,{{AnimationState::YELLOW_SLIME_IDLE,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_ROLL,AnimationState::YELLOW_SLIME_DIE,AnimationState::YELLOW_SLIME_SPIT}},0.4f,1.6f,MonsterStrategy::RUN_TOWARDS,15,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_SPIT)},
|
||||
};
|
||||
|
||||
|
||||
MonsterData::MonsterData(){}
|
||||
MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg
|
||||
,AnimationState jumpAnimation,AnimationState shootAnimation):
|
||||
type(type),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg)
|
||||
,jumpAnimation(jumpAnimation),shootAnimation(shootAnimation){
|
||||
}
|
||||
int MonsterData::GetHealth(){
|
||||
return hp;
|
||||
}
|
||||
int MonsterData::GetAttack(){
|
||||
return atk;
|
||||
}
|
||||
float MonsterData::GetMoveSpdMult(){
|
||||
return moveSpd;
|
||||
}
|
||||
float MonsterData::GetSizeMult(){
|
||||
return size;
|
||||
}
|
||||
int MonsterData::GetCollisionDmg(){
|
||||
return collisionDmg;
|
||||
}
|
||||
MonsterName MonsterData::GetType(){
|
||||
return type;
|
||||
}
|
||||
MonsterStrategy MonsterData::GetAIStrategy(){
|
||||
return strategy;
|
||||
}
|
||||
|
||||
AnimationState MonsterData::GetJumpAnimation(){
|
||||
return jumpAnimation;
|
||||
}
|
||||
AnimationState MonsterData::GetShootAnimation(){
|
||||
return shootAnimation;
|
||||
}
|
@ -414,7 +414,7 @@ void Player::Update(float fElapsedTime){
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSONICSWORD_S);
|
||||
}break;
|
||||
}
|
||||
PLAYER_BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(pos,bulletVel,30,GetAttack()*8,AnimationState::SONICSLASH,true,2.25,true)));
|
||||
PLAYER_BULLET_LIST.push_back(std::make_unique<Bullet>(pos,bulletVel,30,GetAttack()*8,AnimationState::SONICSLASH,true,2.25,true));
|
||||
game->SetupWorldShake(0.5);
|
||||
}break;
|
||||
case THIEF:{
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 347
|
||||
#define VERSION_BUILD 352
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
7
Crawler/monSlimeA.cpp
Normal file
7
Crawler/monSlimeA.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "MonsterType.h"
|
||||
|
||||
monSlimeA::monSlimeA(vf2d pos,MonsterData data)
|
||||
:Monster(pos,data){
|
||||
jumpAnimation=AnimationState::GREEN_SLIME_JUMP;
|
||||
shootAnimation=AnimationState::GREEN_SLIME_SPIT;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user