|
|
@ -20,7 +20,7 @@ safemap<int,std::string>STRATEGY_ID_DATA; |
|
|
|
std::map<int,Renderable*>MonsterData::imgs; |
|
|
|
std::map<int,Renderable*>MonsterData::imgs; |
|
|
|
|
|
|
|
|
|
|
|
Monster::Monster(vf2d pos,MonsterData data,bool upperLevel): |
|
|
|
Monster::Monster(vf2d pos,MonsterData data,bool upperLevel): |
|
|
|
pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),strategy(data.GetAIStrategy()),id(data.GetID()),upperLevel(upperLevel){ |
|
|
|
pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),id(data.GetID()),upperLevel(upperLevel){ |
|
|
|
bool firstAnimation=true; |
|
|
|
bool firstAnimation=true; |
|
|
|
for(std::string&anim:data.GetAnimations()){ |
|
|
|
for(std::string&anim:data.GetAnimations()){ |
|
|
|
animation.AddState(anim,ANIMATION_DATA[anim]); |
|
|
|
animation.AddState(anim,ANIMATION_DATA[anim]); |
|
|
@ -110,6 +110,13 @@ bool Monster::SetY(float y){ |
|
|
|
bool Monster::Update(float fElapsedTime){ |
|
|
|
bool Monster::Update(float fElapsedTime){ |
|
|
|
lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime); |
|
|
|
lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime); |
|
|
|
iframe_timer=std::max(0.f,iframe_timer-fElapsedTime); |
|
|
|
iframe_timer=std::max(0.f,iframe_timer-fElapsedTime); |
|
|
|
|
|
|
|
if(size!=targetSize){ |
|
|
|
|
|
|
|
if(size>targetSize){ |
|
|
|
|
|
|
|
size=std::max(targetSize,size-Crawler::SIZE_CHANGE_SPEED*fElapsedTime); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
size=std::min(targetSize,size+Crawler::SIZE_CHANGE_SPEED*fElapsedTime); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if(IsAlive()){ |
|
|
|
if(IsAlive()){ |
|
|
|
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){ |
|
|
|
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){ |
|
|
|
Buff&b=*it; |
|
|
|
Buff&b=*it; |
|
|
@ -273,6 +280,7 @@ vf2d MonsterSpawner::GetRange(){ |
|
|
|
vf2d MonsterSpawner::GetPos(){ |
|
|
|
vf2d MonsterSpawner::GetPos(){ |
|
|
|
return pos; |
|
|
|
return pos; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MonsterSpawner::SetTriggered(bool trigger,bool spawnMonsters){ |
|
|
|
void MonsterSpawner::SetTriggered(bool trigger,bool spawnMonsters){ |
|
|
|
triggered=trigger; |
|
|
|
triggered=trigger; |
|
|
|
if(spawnMonsters){ |
|
|
|
if(spawnMonsters){ |
|
|
@ -365,4 +373,12 @@ float Monster::GetZ(){ |
|
|
|
|
|
|
|
|
|
|
|
std::string Monster::GetStrategy(){ |
|
|
|
std::string Monster::GetStrategy(){ |
|
|
|
return STRATEGY_ID_DATA[strategy]; |
|
|
|
return STRATEGY_ID_DATA[strategy]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Monster::SetSize(float newSize,bool immediate){ |
|
|
|
|
|
|
|
if(immediate){ |
|
|
|
|
|
|
|
size=targetSize=newSize; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
targetSize=newSize; |
|
|
|
|
|
|
|
}
|
|
|
|
} |
|
|
|
} |