Added a trigger that resets the player when his z value is below 15.
This commit is contained in:
parent
e14a2305a0
commit
12f76ddd5a
@ -11776,18 +11776,19 @@
|
|||||||
<idBlue>105</idBlue>
|
<idBlue>105</idBlue>
|
||||||
<typeID>20</typeID>
|
<typeID>20</typeID>
|
||||||
<trigger>
|
<trigger>
|
||||||
<name>-</name>
|
<name>resetPlayer</name>
|
||||||
|
<undo>false</undo>
|
||||||
<xPosition>0</xPosition>
|
<xPosition>0</xPosition>
|
||||||
<yPosition>0</yPosition>
|
<yPosition>-100000</yPosition>
|
||||||
<zPosition>0</zPosition>
|
<zPosition>0</zPosition>
|
||||||
<targetIdGreen>-</targetIdGreen>
|
<targetIdGreen>-</targetIdGreen>
|
||||||
<targetIdBlue>-</targetIdBlue>
|
<targetIdBlue>-</targetIdBlue>
|
||||||
<distance>1.0</distance>
|
<distance>100015</distance>
|
||||||
<isBiggerThan>false</isBiggerThan>
|
<isBiggerThan>false</isBiggerThan>
|
||||||
<objectNum>0</objectNum>
|
<objectNum>0</objectNum>
|
||||||
<luaScript>-</luaScript>
|
<luaScript>resetPlayer.lua</luaScript>
|
||||||
<toChangeIdGreen>0</toChangeIdGreen>
|
<toChangeIdGreen>0</toChangeIdGreen>
|
||||||
<toChangeIdBlue>0</toChangeIdBlue>
|
<toChangeIdBlue>105</toChangeIdBlue>
|
||||||
<toChangeObjNum>0</toChangeObjNum>
|
<toChangeObjNum>0</toChangeObjNum>
|
||||||
</trigger>
|
</trigger>
|
||||||
</composition>
|
</composition>
|
||||||
|
17
data/levels/scripts/resetPlayer.lua
Normal file
17
data/levels/scripts/resetPlayer.lua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
local global = require( "global" )
|
||||||
|
if(global.triggeredResetPlayer == nil) then
|
||||||
|
global.triggeredResetPlayer = false
|
||||||
|
end
|
||||||
|
function trigger(objectToChange)
|
||||||
|
if(global.triggeredResetPlayer == false) then
|
||||||
|
if(not level) then
|
||||||
|
print("No level found in Lua!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
level:resetPlayer()
|
||||||
|
|
||||||
|
--global.triggeredResetPlayer = true
|
||||||
|
print("reset player")
|
||||||
|
end
|
||||||
|
end
|
8
level.cc
8
level.cc
@ -38,6 +38,7 @@ void Level::load() {
|
|||||||
.addFunction("deleteObject", &Level::deleteObject)
|
.addFunction("deleteObject", &Level::deleteObject)
|
||||||
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
|
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
|
||||||
.addFunction("moveObject", &Level::moveObject)
|
.addFunction("moveObject", &Level::moveObject)
|
||||||
|
.addFunction("resetPlayer", &Level::resetPlayer)
|
||||||
.endClass();
|
.endClass();
|
||||||
//Push the level to Lua as a global variable
|
//Push the level to Lua as a global variable
|
||||||
luabridge::push(luaState, this);
|
luabridge::push(luaState, this);
|
||||||
@ -180,7 +181,12 @@ void Level::deleteObject(int objectIndex){
|
|||||||
void Level::resetPlayer(){
|
void Level::resetPlayer(){
|
||||||
Loader loader = Loader();
|
Loader loader = Loader();
|
||||||
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
|
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
|
||||||
//TODO cameraCenter.setPosition(newPosition);
|
physics.forceMove(newPosition, playerIndex);
|
||||||
|
physics.forceMoveCamera(newPosition + glm::vec3(1,0,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Level::setPlayerIndex(int index){
|
||||||
|
playerIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::setStrength(float strength) {
|
void Level::setStrength(float strength) {
|
||||||
|
2
level.hh
2
level.hh
@ -56,6 +56,7 @@ class Level {
|
|||||||
lua_State* getLuaState();
|
lua_State* getLuaState();
|
||||||
Terrain* getTerrain();
|
Terrain* getTerrain();
|
||||||
void resetPlayer();
|
void resetPlayer();
|
||||||
|
void setPlayerIndex(int index);
|
||||||
private:
|
private:
|
||||||
lua_State* luaState=nullptr;
|
lua_State* luaState=nullptr;
|
||||||
std::vector<Object*> objects;
|
std::vector<Object*> objects;
|
||||||
@ -66,6 +67,7 @@ class Level {
|
|||||||
glm::vec4 fogColour;
|
glm::vec4 fogColour;
|
||||||
Light directionalLight;
|
Light directionalLight;
|
||||||
Object* cameraCenter;
|
Object* cameraCenter;
|
||||||
|
int playerIndex;
|
||||||
Object* skydome;
|
Object* skydome;
|
||||||
Physics physics;
|
Physics physics;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
|
@ -259,6 +259,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
|
|
||||||
if(compositionType == 20){
|
if(compositionType == 20){
|
||||||
level->setCameraCenter(object);
|
level->setCameraCenter(object);
|
||||||
|
level->setPlayerIndex(objectIdentifier[1]);
|
||||||
}
|
}
|
||||||
}//objectData found
|
}//objectData found
|
||||||
}//finding the objectData
|
}//finding the objectData
|
||||||
|
Loading…
Reference in New Issue
Block a user