Added 'Safepoints' to the resetPlayer script.

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

View File

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

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor1 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then
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
global.triggeredOpenSecondDoor1Undo = false
end
print("openSecondDoor1")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor2 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then
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
global.triggeredOpenSecondDoor2Undo = false
end
print("openSecondDoor2")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor3 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then
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
global.triggeredOpenSecondDoor3Undo = false
end
print("openSecondDoor3")

View File

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

View File

@ -8,8 +8,19 @@ function trigger(objectToChange)
print("No level found in Lua!")
return
end
level:resetPlayer()
if(global.triggeredOpenFirstDoor == true) then
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
print("reset player")

View File

@ -39,6 +39,7 @@ void Level::load() {
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
.addFunction("moveObject", &Level::moveObject)
.addFunction("resetPlayer", &Level::resetPlayer)
.addFunction("movePlayer", &Level::movePlayer)
.endClass();
//Push the level to Lua as a global variable
luabridge::push(luaState, this);
@ -188,8 +189,12 @@ void Level::deleteObject(int objectIndex){
void Level::resetPlayer(){
Loader loader = Loader();
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
physics.forceMove(newPosition, playerIndex);
physics.forceMoveCamera(newPosition + glm::vec3(1,0,0));
physics.forcePlayer(newPosition);
}
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){

View File

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