Added 'Safepoints' to the resetPlayer script.

This commit is contained in:
Steffen Fündgens 2015-03-04 18:10:49 +01:00
parent bb30aee8d3
commit 79faa2edea
8 changed files with 27 additions and 33 deletions

View File

@ -15,7 +15,7 @@ function trigger(objectToChange)
local strength = 100 local strength = 100
local xPos = 17.5 local xPos = 17.5
local yPos = 33 local yPos = 33.0
local zPos = 81.5 local zPos = 81.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos) level:moveObject(objectToChange, strength, xPos, yPos, zPos)
@ -35,7 +35,7 @@ function triggerUndo(objectToChange)
local strength = 100 local strength = 100
local xPos = 17.5 local xPos = 17.5
local yPos = 25 local yPos = 25.0
local zPos = 81.5 local zPos = 81.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos) level:moveObject(objectToChange, strength, xPos, yPos, zPos)

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor1 = true global.triggeredOpenSecondDoor1 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then global.triggeredOpenSecondDoor1Undo = false
local strength = 100
local xPos = -81.5
local yPos = 33
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
global.triggeredOpenSecondDoor1Undo = false
end
end end
print("openSecondDoor1") print("openSecondDoor1")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor2 = true global.triggeredOpenSecondDoor2 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then global.triggeredOpenSecondDoor2Undo = false
local strength = 100
local xPos = -81.5
local yPos = 33
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
global.triggeredOpenSecondDoor2Undo = false
end
end end
print("openSecondDoor2") print("openSecondDoor2")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor3 = true global.triggeredOpenSecondDoor3 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then global.triggeredOpenSecondDoor3Undo = false
local strength = 100
local xPos = -81.5
local yPos = 33
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
global.triggeredOpenSecondDoor3Undo = false
end
end end
print("openSecondDoor3") print("openSecondDoor3")

View File

@ -28,6 +28,7 @@ function trigger(objectToChange)
local yPos = 33 local yPos = 33
local zPos = 4.5 local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos) level:moveObject(objectToChange, strength, xPos, yPos, zPos)
global.openedSecondDoor = true
else else
global.triggeredOpenSecondDoor4Undo = false global.triggeredOpenSecondDoor4Undo = false
end end

View File

@ -8,8 +8,19 @@ function trigger(objectToChange)
print("No level found in Lua!") print("No level found in Lua!")
return return
end end
if(global.triggeredOpenFirstDoor == true) then
level:resetPlayer() if(global.openedSecondDoor == true) then
if(global.triggeredOpenThirdDoor == true) then
level:movePlayer(-169.5,22.5,58.5)
else
level:movePlayer(-78.5,22.5,4.5)
end
else
level:movePlayer(17.5,22.5,87.0)
end
else
level:resetPlayer()
end
--global.triggeredResetPlayer = true --global.triggeredResetPlayer = true
print("reset player") print("reset player")

View File

@ -39,6 +39,7 @@ void Level::load() {
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize) .addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
.addFunction("moveObject", &Level::moveObject) .addFunction("moveObject", &Level::moveObject)
.addFunction("resetPlayer", &Level::resetPlayer) .addFunction("resetPlayer", &Level::resetPlayer)
.addFunction("movePlayer", &Level::movePlayer)
.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);
@ -188,8 +189,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);
physics.forceMove(newPosition, playerIndex); physics.forcePlayer(newPosition);
physics.forceMoveCamera(newPosition + glm::vec3(1,0,0)); }
void Level::movePlayer(float xPosition, float yPosition, float zPosition){
glm::vec3 newPosition = glm::vec3(xPosition, yPosition, zPosition);
physics.forcePlayer(newPosition);
} }
void Level::setPlayerIndex(int index){ void Level::setPlayerIndex(int index){

View File

@ -57,6 +57,7 @@ class Level {
lua_State* getLuaState(); lua_State* getLuaState();
Terrain* getTerrain(); Terrain* getTerrain();
void resetPlayer(); void resetPlayer();
void movePlayer(float xPosition, float yPosition, float zPosition);
void setPlayerIndex(int index); void setPlayerIndex(int index);
private: private:
lua_State* luaState=nullptr; lua_State* luaState=nullptr;