Added a trigger that resets the player when his z value is below 15.

This commit is contained in:
Steffen Fündgens 2015-03-04 15:52:28 +01:00
parent e14a2305a0
commit 12f76ddd5a
5 changed files with 33 additions and 6 deletions

View File

@ -11776,18 +11776,19 @@
<idBlue>105</idBlue>
<typeID>20</typeID>
<trigger>
<name>-</name>
<name>resetPlayer</name>
<undo>false</undo>
<xPosition>0</xPosition>
<yPosition>0</yPosition>
<yPosition>-100000</yPosition>
<zPosition>0</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>1.0</distance>
<distance>100015</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>-</luaScript>
<luaScript>resetPlayer.lua</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>0</toChangeIdBlue>
<toChangeIdBlue>105</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>

View 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

View File

@ -38,6 +38,7 @@ void Level::load() {
.addFunction("deleteObject", &Level::deleteObject)
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
.addFunction("moveObject", &Level::moveObject)
.addFunction("resetPlayer", &Level::resetPlayer)
.endClass();
//Push the level to Lua as a global variable
luabridge::push(luaState, this);
@ -180,7 +181,12 @@ void Level::deleteObject(int objectIndex){
void Level::resetPlayer(){
Loader loader = Loader();
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) {

View File

@ -56,6 +56,7 @@ class Level {
lua_State* getLuaState();
Terrain* getTerrain();
void resetPlayer();
void setPlayerIndex(int index);
private:
lua_State* luaState=nullptr;
std::vector<Object*> objects;
@ -66,6 +67,7 @@ class Level {
glm::vec4 fogColour;
Light directionalLight;
Object* cameraCenter;
int playerIndex;
Object* skydome;
Physics physics;
Camera camera;

View File

@ -259,6 +259,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
if(compositionType == 20){
level->setCameraCenter(object);
level->setPlayerIndex(objectIdentifier[1]);
}
}//objectData found
}//finding the objectData