home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
hifiChar.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
3KB
|
113 lines
-- boxing character state machine
beginStateMachine()
onEnter(function(msg)
local hifi = getStateObjectFromID(msg.sender);
storeStateObject("hifi", hifi);
if (hifi) then
-- hifi does exist
if exitIfWrongPosition(getParent(), hifi, retrieveData("actionPointName")) then return end;
--local actionPoint = getParent().getClosestFreeActionPoint(getParent(), hifi, {"dance1", "dance2"});
local actionPointName = retrieveData("actionPointName");
local actionPoint = getParent().getFreeActionPoint(hifi, actionPointName);
if (not actionPoint) then
-- action points is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoint(hifi, actionPoint.getName());
end
else
-- sink does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
print("exit hifi");
-- local hifi = retrieveStateObject("hifi");
-- getParent().stopAllActivities(hifi);
-- getParent().unlockActionPoints(hifi);
-- removeStateObject("hifi");
unlockAll("hifi");
getParent().stopAllActivities();
end )
-- dance
state("dance")
onEnter(function(msg)
startAnimation("danceElaine", false, retrieveData("scale", 1.0));
local hifi = retrieveStateObject("hifi");
local dance = getParent().startActivity("dance", hifi);
local length, scale = getActivityLength(dance);
storeData("scale", scale);
sendMsg("addListener", hifi);
sendDelayedMsgThis("stopDancing", length);
local numListeners = hifi.retrieveData("numListeners", 0);
--print("start dance with ", numListeners);
if (numListeners > 1) then
getParent().startActivity("flirtDancing", hifi);
end
end )
onExit(function(msg)
local hifi = retrieveStateObject("hifi");
sendMsg("removeListener", hifi);
end )
onMsg("stopDancing", function(msg)
exitStateMachine();
end )
onMsg("end", function(msg)
local s = getParent().getGameObjectServer();
if testCancel() or (s.addListener(0) == 0) then
--exitStateMachine();
sendMsgThis("stopDancing");
else
startAnimation("danceElaine", false, retrieveData("scale", 1.0));
local hifi = retrieveStateObject("hifi");
local numListeners = hifi.retrieveData("numListeners");
if (numListeners == nil) then numListeners = 0 end
--print("keep dance with ", numListeners);
if (numListeners > 1) then
if (not getParent().hasActivity("flirtDancing", hifi)) then
--print("start flirtDancing");
getParent().startActivity("flirtDancing", hifi);
end
else
if (getParent().hasActivity("flirtDancing", hifi)) then
--print("end flirtDancing");
getParent().stopActivity("flirtDancing", hifi);
end
end
end
end )
endStateMachine()