home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
sofaGuitarChar.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
4KB
|
161 lines
-- sofa character state machine
beginStateMachine()
onEnter(function(msg)
local sofa = retrieveStateObject("sofa");
-- removeStateObject("seat");
-- storeStateObject("sofa", sofa);
if (not sofa) then
-- sofa does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
local actionPointName = retrieveData("actionPointName");
if exitIfWrongPosition(getParent(), sofa, actionPointName) then return end;
end
--freeHands(getParent());
end )
onExit(function(msg)
local sofa = retrieveStateObject("sofa");
if (sofa) then
getParent().unlockActionPoints(sofa);
getParent().stopAllActivities(sofa);
removeStateObject("sofa");
end;
-- local guitarRack = retrieveStateObject("guitarRack");
-- if (guitarRack) then
-- getParent().unlockActionPoints(guitarRack);
-- getParent().stopAllActivities(guitarRack);
-- removeStateObject("guitarRack");
-- end;
--
-- --local guitar = retrieveStateObject("guitar");
-- removeStateObject("guitar");
end )
-- sit down on sofa
state("sitDown")
onEnter(function(msg)
local sofa = retrieveStateObject("sofa");
local actionPointName = retrieveData("actionPointName");
if (getParent().isActionPointLocked(sofa, actionPointName)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
freeHands(getParent());
exitStateMachine();
else
getParent().lockActionPoint(sofa, actionPointName);
getParent().handSO.stopAnimation(0.0);
startAnimation("playGuitarSitdown", false, 1.0, 0.0);
sofa.playSound("Sofa setzen");
end
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end )
onMsg("end", function(msg)
if testCancel() then
setState("standUp");
else
setState("playSitting");
end
end )
onMsg("testCancel", function(msg)
if testCancel() then
setState("standUp");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
state("playSitting")
onEnter(function(msg)
local guitarRack = retrieveStateObject("guitarRack");
local play = getParent().startActivity("playGuitar", guitarRack);
local length, scale = getActivityLength(play);
storeData("scale", scale);
startAnimation("playGuitarLoop");
sendDelayedMsgThis("stopPlaying", length);
--this.actionComplete();
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
getParent().loopSound("guitar");
end )
onExit(function(msg)
getParent().stopSound("guitar");
end )
onMsg("testCancel", function(msg)
if testCancel() or (not this.getParent().getCurrentActivityGain()) then
sendMsgThis("stopPlaying");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("end", function(msg)
if testCancel() or (not this.getParent().getCurrentActivityGain()) then
sendMsgThis("stopPlaying");
else
startAnimation("playGuitarLoop");
end
end )
onMsg("stopPlaying", function(msg)
local guitarRack = retrieveStateObject("guitarRack");
getParent().stopAllActivities(guitarRack);
setState("standUp");
end )
onMsg("queue", function(msg)
sendMsgThis("stopPlaying");
end )
-- stand up from sofa
state("standUp")
onEnter(function(msg)
startAnimation("standupArmchair");
getParent().detachLeftObjectHolder();
local guitar = retrieveStateObject("guitar");
if (guitar) then guitar.deleteGameObject(); end
local guitarRack = retrieveStateObject("guitarRack");
if (guitarRack) then guitarRack.setChildEnable("guitar", true) end
end )
onMsg("end", function(msg)
flipPoseDirection();
exitStateMachine();
end )
endStateMachine()