home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
cleanFloorChar.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
5KB
|
191 lines
-- cleaning floor character state machine
beginStateMachine()
onEnter(function(msg)
local hooverRack = getStateObjectFromID(msg.sender);
storeStateObject("hooverRack", hooverRack);
if (hooverRack) then
-- hooverRack does exist
if exitIfWrongPosition(getParent(), hooverRack, retrieveData("actionPointName")) then return end;
if (getParent().isOneActionPointLocked(hooverRack)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
freeHands(getParent());
exitStateMachine();
else
getParent().lockActionPoints(hooverRack);
end
else
-- guitarRack does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
freeHands(getParent());
exitStateMachine();
end
end )
onExit(function(msg)
end )
onReturn(function(msg)
print("cleaning floor character onReturn");
setState("clean");
end )
state("takeHoover")
onEnter(function(msg)
local hooverRack = retrieveStateObject("hooverRack");
local hoover = hooverRack.createGameObject("hoover");
this.getStateMachineContext(1).storeStateObject("hoover", hoover);
getParent().attachRightObjectHolder(hooverRack, "hoover");
local cleanFloor = getParent().startActivity("cleanFloor", hooverRack);
hoover.loopSound("hooverLoop");
setState("findDirt");
end )
state("findDirt")
onEnter(function(msg)
print("findDirt onEnter");
local actionPoint = getParent().getNextCleaningPoint(DIRT_DISTANCE);
if (actionPoint) then
if (walkToPointImmediate(actionPoint)) then
getParent().handSO.setPose("hooverHoldPose");
enterStateMachine("subwalk.walk");
return
end
end
-- no accessible dirt found
print("no accessible dirt found");
setState("stopClean");
end )
state("clean")
onEnter(function(msg)
print("clean onEnter ------------->");
if (testCancel()) then
print("clean onEnter testCancel() true");
setState("stopClean");
else
local hooverRack = retrieveStateObject("hooverRack");
local cleanFloor = getParent().createActivity("cleanFloor", hooverRack);
local length, scale = getActivityLength(cleanFloor);
print(">>>>>>>>>>> length, scale: " .. length .. "," .. scale);
--local length = cleanFloor.getLength(); -- 1666<length<15000
--length = ((length-1666)/(15000-1666)); -- 0<length<1
--local radius = 1.5 - (length * 1.25); -- 0.25<radius<1.5
scale = ((scale - 1.0) * HOOVER_RADIUS_BONUS) + 1.0;
print(">>>>>>>>>>> scale2:" .. scale);
local radius = hooverRack.range;
radius = radius * scale;
print(">>>>>>>>>>> clean radius: " .. radius);
getParent().clearDirt(DIRT_DISTANCE, radius);
getParent().handSO.stopAnimation(0.0);
startAnimation("cleanFloor", false, 1.0, 0.0);
end
end )
onMsg("stopHandPose", function(msg)
getParent().handSO.stopPose();
end )
onExit(function(msg)
-- local hooverRack = retrieveStateObject("hooverRack");
-- getParent().stopActivity("cleanFloor", hooverRack);
print("clean onExit <-------------");
end )
onMsg("end", function(msg)
if testCancel() then
setState("stopClean");
else
if (getParent().getCondition(NEED_TIREDNESS) < 0.1) then
getParent().setEmoticon(EMOTICON_SLEEPY, EMOTICON_DELAY);
setState("stopClean");
else
setState("findDirt");
end
end
end )
state("stopClean")
onEnter(function(msg)
print("stopClean onEnter");
local hoover = this.getStateMachineContext(1).retrieveStateObject("hoover", this.getStateObjectServer());
hoover.stopSound("hooverLoop");
freeHands(getParent());
-- local hooverRack = retrieveStateObject("hooverRack");
-- if (hooverRack) then
-- getParent().unlockActionPoints(hooverRack);
-- getParent().stopAllActivities(hooverRack);
-- removeStateObject("hooverRack");
-- end
unlockAll("hooverRack");
--hoover.playSound("hooverStop");
this.getStateMachineContext(1).removeStateObject("hoover");
exitAndGoAway();
getParent().stopAllActivities();
end )
endStateMachine()