Upper level and lower level spawning now distinguished in map editor.
This commit is contained in:
+1
-1
@@ -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")}});
|
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;
|
std::set<vi2d>foregroundTilesAdded,upperForegroundTilesAdded;
|
||||||
for(int x=0;x<WORLD_SIZE.x;x++){
|
for(int x=0;x<WORLD_SIZE.x;x++){
|
||||||
|
|||||||
@@ -220,6 +220,19 @@
|
|||||||
"tile"
|
"tile"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"color": "#ffff74fd",
|
||||||
|
"drawFill": true,
|
||||||
|
"id": 16,
|
||||||
|
"members": [
|
||||||
|
],
|
||||||
|
"name": "UpperSpawnGroup",
|
||||||
|
"type": "class",
|
||||||
|
"useAs": [
|
||||||
|
"property",
|
||||||
|
"object"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"color": "#ffa40aa4",
|
"color": "#ffa40aa4",
|
||||||
"drawFill": true,
|
"drawFill": true,
|
||||||
|
|||||||
+9
-5
@@ -12,8 +12,8 @@ INCLUDE_DAMAGENUMBER_LIST
|
|||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
INCLUDE_BULLET_LIST
|
INCLUDE_BULLET_LIST
|
||||||
|
|
||||||
Monster::Monster(vf2d pos,MonsterData data):
|
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()){
|
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;
|
bool firstAnimation=true;
|
||||||
for(AnimationState&anim:data.GetAnimations()){
|
for(AnimationState&anim:data.GetAnimations()){
|
||||||
animation.AddState(anim,ANIMATION_DATA[anim]);
|
animation.AddState(anim,ANIMATION_DATA[anim]);
|
||||||
@@ -349,8 +349,8 @@ vf2d&Monster::GetTargetPos(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
MonsterSpawner::MonsterSpawner(){}
|
MonsterSpawner::MonsterSpawner(){}
|
||||||
MonsterSpawner::MonsterSpawner(vf2d pos,vf2d range,std::vector<std::pair<MonsterName,vf2d>>monsters):
|
MonsterSpawner::MonsterSpawner(vf2d pos,vf2d range,std::vector<std::pair<MonsterName,vf2d>>monsters,bool upperLevel):
|
||||||
pos(pos),range(range),monsters(monsters){
|
pos(pos),range(range),monsters(monsters),upperLevel(upperLevel){
|
||||||
}
|
}
|
||||||
bool MonsterSpawner::SpawnTriggered(){
|
bool MonsterSpawner::SpawnTriggered(){
|
||||||
return triggered;
|
return triggered;
|
||||||
@@ -365,11 +365,15 @@ void MonsterSpawner::SetTriggered(bool trigger,bool spawnMonsters){
|
|||||||
triggered=trigger;
|
triggered=trigger;
|
||||||
if(spawnMonsters){
|
if(spawnMonsters){
|
||||||
for(std::pair<MonsterName,vf2d>&monsterInfo:monsters){
|
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(){
|
bool Monster::OnUpperLevel(){
|
||||||
return upperLevel;
|
return upperLevel;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -86,7 +86,7 @@ struct Monster{
|
|||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
Monster()=delete;
|
Monster()=delete;
|
||||||
Monster(vf2d pos,MonsterData data);
|
Monster(vf2d pos,MonsterData data,bool upperLevel=false);
|
||||||
vf2d&GetPos();
|
vf2d&GetPos();
|
||||||
int GetHealth();
|
int GetHealth();
|
||||||
int GetAttack();
|
int GetAttack();
|
||||||
@@ -127,13 +127,15 @@ struct MonsterSpawner{
|
|||||||
vf2d range;
|
vf2d range;
|
||||||
std::vector<std::pair<MonsterName,vf2d>>monsters;
|
std::vector<std::pair<MonsterName,vf2d>>monsters;
|
||||||
bool triggered=false;
|
bool triggered=false;
|
||||||
|
bool upperLevel=false;
|
||||||
public:
|
public:
|
||||||
MonsterSpawner();
|
MonsterSpawner();
|
||||||
//For the monster list, the second pair item is the position relative to the spawner to spawn the monster.
|
//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();
|
bool SpawnTriggered();
|
||||||
vf2d GetRange();
|
vf2d GetRange();
|
||||||
vf2d GetPos();
|
vf2d GetPos();
|
||||||
|
bool DoesUpperLevelSpawning();
|
||||||
void SetTriggered(bool trigger,bool spawnMonsters=true);
|
void SetTriggered(bool trigger,bool spawnMonsters=true);
|
||||||
friend std::ostream&operator<<(std::ostream&os,MonsterSpawner&rhs);
|
friend std::ostream&operator<<(std::ostream&os,MonsterSpawner&rhs);
|
||||||
};
|
};
|
||||||
+1
-1
@@ -392,7 +392,7 @@ Key Player::GetFacingDirection(){
|
|||||||
|
|
||||||
void Player::Moved(){
|
void Player::Moved(){
|
||||||
for(MonsterSpawner&spawner:SPAWNER_LIST){
|
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);
|
spawner.SetTriggered(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ struct LayerTag{
|
|||||||
struct SpawnerTag{
|
struct SpawnerTag{
|
||||||
XMLTag ObjectData;
|
XMLTag ObjectData;
|
||||||
std::vector<XMLTag>monsters;
|
std::vector<XMLTag>monsters;
|
||||||
|
bool upperLevel=false;
|
||||||
std::string str();
|
std::string str();
|
||||||
friend std::ostream& operator << (std::ostream& os, SpawnerTag& rhs);
|
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};
|
LayerTag l = {newTag};
|
||||||
parsedMapInfo.LayerData.push_back(l);
|
parsedMapInfo.LayerData.push_back(l);
|
||||||
}else
|
}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") {
|
if (newTag.tag=="object"&&newTag.data["type"]=="SpawnGroup") {
|
||||||
parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag};
|
parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag};
|
||||||
} else
|
} else
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 586
|
#define VERSION_BUILD 593
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #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
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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>
|
</data>
|
||||||
</layer>
|
</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">
|
<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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@@ -1081,11 +1081,11 @@
|
|||||||
<ellipse/>
|
<ellipse/>
|
||||||
</object>
|
</object>
|
||||||
<object id="28" name="Spawn Group 16" type="SpawnGroup" x="1294.67" y="1210.67" width="465.333" height="226.667"/>
|
<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="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="SpawnGroup" x="2878" y="1313.33" width="183.333" height="341.667">
|
<object id="31" name="Spawn Group 18" type="UpperSpawnGroup" x="2878" y="1313.33" width="183.333" height="341.667">
|
||||||
<ellipse/>
|
<ellipse/>
|
||||||
</object>
|
</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">
|
<object id="33" name="Green Slime" type="Monster" x="946.667" y="3197.33">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="Type" type="int" propertytype="MonsterName" value="1"/>
|
<property name="Type" type="int" propertytype="MonsterName" value="1"/>
|
||||||
@@ -1733,7 +1733,7 @@
|
|||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</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="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="41" type="UpperZone" x="1944" y="1140" width="552" height="696"/>
|
||||||
<object id="42" type="LowerBridgeCollision" x="3048" y="1416" width="24" height="144"/>
|
<object id="42" type="LowerBridgeCollision" x="3048" y="1416" width="24" height="144"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user