Upper level and lower level spawning now distinguished in map editor.
This commit is contained in:
parent
0349e5d16e
commit
228a3caa0e
@ -1062,7 +1062,7 @@ void Crawler::LoadLevel(MapName map){
|
||||
monster_list.push_back({MonsterName(monsterTypeID),{monster.GetInteger("x")-spawnData.ObjectData.GetFloat("x"),monster.GetInteger("y")-spawnData.ObjectData.GetFloat("y")}});
|
||||
}
|
||||
}
|
||||
SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list});
|
||||
SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list,spawnData.upperLevel});
|
||||
}
|
||||
std::set<vi2d>foregroundTilesAdded,upperForegroundTilesAdded;
|
||||
for(int x=0;x<WORLD_SIZE.x;x++){
|
||||
|
@ -220,6 +220,19 @@
|
||||
"tile"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "#ffff74fd",
|
||||
"drawFill": true,
|
||||
"id": 16,
|
||||
"members": [
|
||||
],
|
||||
"name": "UpperSpawnGroup",
|
||||
"type": "class",
|
||||
"useAs": [
|
||||
"property",
|
||||
"object"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "#ffa40aa4",
|
||||
"drawFill": true,
|
||||
|
@ -12,8 +12,8 @@ INCLUDE_DAMAGENUMBER_LIST
|
||||
INCLUDE_game
|
||||
INCLUDE_BULLET_LIST
|
||||
|
||||
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()){
|
||||
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()),type(data.GetType()),upperLevel(upperLevel){
|
||||
bool firstAnimation=true;
|
||||
for(AnimationState&anim:data.GetAnimations()){
|
||||
animation.AddState(anim,ANIMATION_DATA[anim]);
|
||||
@ -349,8 +349,8 @@ vf2d&Monster::GetTargetPos(){
|
||||
}
|
||||
|
||||
MonsterSpawner::MonsterSpawner(){}
|
||||
MonsterSpawner::MonsterSpawner(vf2d pos,vf2d range,std::vector<std::pair<MonsterName,vf2d>>monsters):
|
||||
pos(pos),range(range),monsters(monsters){
|
||||
MonsterSpawner::MonsterSpawner(vf2d pos,vf2d range,std::vector<std::pair<MonsterName,vf2d>>monsters,bool upperLevel):
|
||||
pos(pos),range(range),monsters(monsters),upperLevel(upperLevel){
|
||||
}
|
||||
bool MonsterSpawner::SpawnTriggered(){
|
||||
return triggered;
|
||||
@ -365,11 +365,15 @@ void MonsterSpawner::SetTriggered(bool trigger,bool spawnMonsters){
|
||||
triggered=trigger;
|
||||
if(spawnMonsters){
|
||||
for(std::pair<MonsterName,vf2d>&monsterInfo:monsters){
|
||||
MONSTER_LIST.push_back(Monster(pos+monsterInfo.second,MONSTER_DATA[monsterInfo.first]));
|
||||
MONSTER_LIST.push_back(Monster(pos+monsterInfo.second,MONSTER_DATA[monsterInfo.first],DoesUpperLevelSpawning()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MonsterSpawner::DoesUpperLevelSpawning(){
|
||||
return upperLevel;
|
||||
}
|
||||
|
||||
bool Monster::OnUpperLevel(){
|
||||
return upperLevel;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ struct Monster{
|
||||
protected:
|
||||
public:
|
||||
Monster()=delete;
|
||||
Monster(vf2d pos,MonsterData data);
|
||||
Monster(vf2d pos,MonsterData data,bool upperLevel=false);
|
||||
vf2d&GetPos();
|
||||
int GetHealth();
|
||||
int GetAttack();
|
||||
@ -127,13 +127,15 @@ struct MonsterSpawner{
|
||||
vf2d range;
|
||||
std::vector<std::pair<MonsterName,vf2d>>monsters;
|
||||
bool triggered=false;
|
||||
bool upperLevel=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,vf2d range,std::vector<std::pair<MonsterName,vf2d>>MONSTER_LIST);
|
||||
MonsterSpawner(vf2d pos,vf2d range,std::vector<std::pair<MonsterName,vf2d>>MONSTER_LIST,bool upperLevel=false);
|
||||
bool SpawnTriggered();
|
||||
vf2d GetRange();
|
||||
vf2d GetPos();
|
||||
bool DoesUpperLevelSpawning();
|
||||
void SetTriggered(bool trigger,bool spawnMonsters=true);
|
||||
friend std::ostream&operator<<(std::ostream&os,MonsterSpawner&rhs);
|
||||
};
|
@ -392,7 +392,7 @@ Key Player::GetFacingDirection(){
|
||||
|
||||
void Player::Moved(){
|
||||
for(MonsterSpawner&spawner:SPAWNER_LIST){
|
||||
if(!spawner.SpawnTriggered()&&geom2d::contains(geom2d::rect<float>{spawner.GetPos(),spawner.GetRange()},pos)){
|
||||
if(!spawner.SpawnTriggered()&&spawner.DoesUpperLevelSpawning()==OnUpperLevel()&&geom2d::contains(geom2d::rect<float>{spawner.GetPos(),spawner.GetRange()},pos)){
|
||||
spawner.SetTriggered(true);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ struct LayerTag{
|
||||
struct SpawnerTag{
|
||||
XMLTag ObjectData;
|
||||
std::vector<XMLTag>monsters;
|
||||
bool upperLevel=false;
|
||||
std::string str();
|
||||
friend std::ostream& operator << (std::ostream& os, SpawnerTag& rhs);
|
||||
};
|
||||
@ -217,6 +218,10 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
|
||||
LayerTag l = {newTag};
|
||||
parsedMapInfo.LayerData.push_back(l);
|
||||
}else
|
||||
if (newTag.tag=="object"&&newTag.data["type"]=="UpperSpawnGroup") {
|
||||
parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag};
|
||||
parsedMapInfo.SpawnerData[newTag.GetInteger("id")].upperLevel=true;
|
||||
} else
|
||||
if (newTag.tag=="object"&&newTag.data["type"]=="SpawnGroup") {
|
||||
parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag};
|
||||
} else
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 586
|
||||
#define VERSION_BUILD 593
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -830,7 +830,7 @@
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="6" name="Bridge Layer" class="Bridge" width="192" height="203" visible="0">
|
||||
<layer id="6" name="Bridge Layer" class="Bridge" width="192" height="203">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
@ -1081,11 +1081,11 @@
|
||||
<ellipse/>
|
||||
</object>
|
||||
<object id="28" name="Spawn Group 16" type="SpawnGroup" x="1294.67" y="1210.67" width="465.333" height="226.667"/>
|
||||
<object id="30" name="Spawn Group 17" type="SpawnGroup" x="2209.33" y="1297.33" width="173.333" height="304"/>
|
||||
<object id="31" name="Spawn Group 18" type="SpawnGroup" x="2878" y="1313.33" width="183.333" height="341.667">
|
||||
<object id="30" name="Spawn Group 17" type="UpperSpawnGroup" x="2209.33" y="1297.33" width="173.333" height="304"/>
|
||||
<object id="31" name="Spawn Group 18" type="UpperSpawnGroup" x="2878" y="1313.33" width="183.333" height="341.667">
|
||||
<ellipse/>
|
||||
</object>
|
||||
<object id="32" name="Spawn Group 19" type="SpawnGroup" x="3857.33" y="1294.67" width="320" height="376"/>
|
||||
<object id="32" name="Spawn Group 19" type="UpperSpawnGroup" x="3857.33" y="1294.67" width="320" height="376"/>
|
||||
<object id="33" name="Green Slime" type="Monster" x="946.667" y="3197.33">
|
||||
<properties>
|
||||
<property name="Type" type="int" propertytype="MonsterName" value="1"/>
|
||||
@ -1733,7 +1733,7 @@
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="7" name="Transition Layerxzs">
|
||||
<objectgroup id="7" name="Transition Layerxzs" visible="0">
|
||||
<object id="40" type="LowerZone" x="1572" y="1140" width="372" height="684"/>
|
||||
<object id="41" type="UpperZone" x="1944" y="1140" width="552" height="696"/>
|
||||
<object id="42" type="LowerBridgeCollision" x="3048" y="1416" width="24" height="144"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user