com.theoworlds.builder.Character

com.theoworlds.builder.Character

Character class -- character/avatar main class

Version

1.0

Author

© TheoWorlds.com, 2007--2009.

Summary
com.theoworlds.builder.CharacterCharacter class -- character/avatar main class
Variables
_stackablestacks on top of other tiles, taking elevation in consideration overwriting the parent class value (MapObject._stackable)
_walkableflag(Boolean) that tells if characters(Character) can walk on top of this object overwriting the parent class value (MapObject._walkable)
_netIDid(String) for network characters (in multi--user envirorment).
_chatColorpredefined chat message color borders.
_phasesMCMovieClip that contains all the characters animation phases
_an_framesnumber(Number) of animation phases per step of animation
_usesLeftRightStepsflag(Boolean) -- the step animation is made of left and right step parts
IGNORES_TERRAIN_ELEVATIONSflag(Boolean) -- ignores floor tiles elevations
SMOOTH_ELEVATIONflag(Boolean) -- elevates gradually from tile to tile, instead of “jumping” on top of the elevated tile
_speedanimation speed(Number).
_moveToDirectionremembers the direction(Number) the character should move to WHEN IT CAN (it can’t change direction in the middle of the stepping animation).
_isMovingflag (Boolean)
_isDoingAnActionflag (Boolean)
_isICharactermain character (“I”)
_displayNamecharacter’s name (String)
_directionthe direction(Number) the character is turned to
_cActionToDothe action the character has to do (whenever possible.
_cActionEndFramethe number of phases/frames of the current action animation; 1 by default
_cCurrentTileElevationthe elevation(Number) of the current tile (Tile) -- elevation is the character own elevation -- can be different
_cFutureTileElevationthe elevation(Number) of the current tile (Tile) -- elevation is the character own elevation -- can be different
_phasecharacter animation phase (Number)
_brainthe reference to the CharacterLogin object
_autoPilotflag(Boolean) -- if the character is in autoPilot mode, he decides himself were to move, for example random monster movements
_anIntused to store animation interval function (setInterval:Function) id
_layersXMLNode[node:XMLNode] stores the XML nodes(XMLNode) -- this way we can store all the possible parametters, and we can also extend the functionality easily
_layersto access the parametters just use -- _layers[XMLNode.attributes.name]
_visibleLayersvisible layers (clothes and accessories)
LAYERS_PROTOCOL_GROUP
LAYERS_PROTOCOL_LAYER
LAYERS_PROTOCOL_NAME
LAYERS_PROTOCOL_REQUIRED
_pShiftXthe shift by X(Number) for each walking/moving animation frame
_pShiftYthe shift by Y(Number) for each walking/moving animation frame
_dShiftXthe diagonal X(Number) shift for each walking/moving animation frame
_dShiftYthe diagonal Y(Number) shift for each walking/moving animation frame
_tileDiagonaldistance(Number) between diagonal tiles (Tile)
nameTxtthe text field for displaying the character name
debugTxtdebugging text field (TextField)
_libSpeedthe speed(Number) of the character from the Library stored locally for better performance TODO -- add the possibility to accelerate the characters at will.
_selectableflag(Boolean)is the character selectable or not
_hitTestBitmapthe bitmap used for hit test (detect the clicks on the character).
_hitTestBitmapFirstPointthe parametter used for BitmapData.hitTest(firstPoint:Point, firstAlphaThreshold:Number, secondObject:Object) stored for optimizing the hit test
Functions and Properties
Character
initinitialization
onLoadInitLibrarySymbolcalled when the character is loaded -- overwrites the parent method
onLoadCompleteLibrarySymbolcharacters are more complex then other map objects (floor tiles, furniture) and need to finish the initialization after the locading
activateactivating the character -- dress and make it move
placeplacing the character on the map
doActionmakes the character perform an action (ex: dance)
actionAnstep animation actionFrameLabel -- first frame of the action nonStop -- loop
setCurrentActionsets the current action.
isMovableActionmovable -- the action used to movements
isNonStopActionnonStopAction -- “looping” action
isSnapToActionsnapToAction -- switches to this action instantly (like sitting on a chair after wakling, without walking on the chair
getActionFrameNumber
isUsesLeftRightStepsused for movable actions to distinguish movements that use left and right steps (walking) from the ones that don’t (sliding, floating...)
stopActionstops the character action
standstand still
freezeunlike the stopMoving, that makes the character to come to a stop naturally (finishing the step, for example), this method forces the character to freeze right away.
turnmakes the character turn to a given direction
moveToTilemakes the character move to the indicated tile
moveToDirmakes the character start to move in a specific direction // TODO -- implement the same for network characters
moveDirProcessingmoves the character to a given direction this function is used to emulate the keyboard control.
stopMovingstops the character movement
stepAnused for step animation
changeIntervalmethod is used for dead reconing only now.
scrollMapcalls the map scroll function, if needed
isStepEndedchecks if the step animation ended
testLayers
initLayersparcing the XML from the Library RECOMMENDED! 
takeAllLayersOnshows all layers of clothes
takeAllLayersOffhides all layers of clothes
takeGroupClothesOffhides the layers of a given group (if it is declared in the XML)
putGroupClothesOnshows the layers of a given group (if it is declared in the XML)
takeClothesOffhides layers of clothes the (String) parametter is passed with the names of the layers, separated by commas: takeLayersOff(“top1”, “bottom24”);
putClothesOnshows layers of clothes the (String) parametter is passed with the names of the layers, separated by commas: takeLayersOn(“top1”, “bottom24”);
getGroupClothesListget the list of the layer groups
getDressedClothes[XMLNode]
getGroupNodethis function makes it easier to get through the XML.
getLayersFromNode
updateClothesPhasesynchronize clothes animation with character animation
dressRandomClothesdresses a character in random clothes paces all the clothes groups -- same as with CHARACTER_CLOTHES_TYPES
getHeight character height(Number) (the size of the non--transparent area of the bitmap -- not the movieclip)
getCrown the height(Number) of the character from the registration point till its top (the bimap) Example -- a character sits on the floor -- it means his height above the floor is lower than if he would stand up
attachBrainconnects a CharacterLogic object to a character
detachBraindisconnects the CharacterLogic object from a character
clearcleans the assets
getSettingsreturns character settings
onClickSpriteMCthis event is called only when _selectable (Character._selectable) == true; it triggers a method in the World that takes action
onRollOverSpriteMCthis event is called only when selectable(Character._selectable) == true; it calls hitTestMode to find out if the area clicked is not transparent (empty)
onRollOutSpriteMCcalled when selectable(Character._selectable) == true; turns off hitTestMode
hitTestModedetects if the click is made on actual non--transparent part of the furniture
setHighlightcalled when selectable(Character._selectable) == true; highlights on un/highlights a furniture
selectablechecks if the furniture is selectable (Character._selectable)
selectablemakes the Character object selectable or not
speed speed of character animation.
speedused by CharacterLogic(CharacterLogic) when doing deadReconing the character changes the speed when it can TODO optional
getLibSpeed Library (Library) speed of the character (the base speed he should use when no compensation is applied on top of it)
isDoingAnActionBoolean.
getDirection the direction(Number) the character is turned to Character._direction
isMoving Character._isMoving
getDestinationTile coordinates ( Point(col, row) ) of the tile that the character moves to
isICharacterBoolean -- is the character controllable (mouse, keyboard) -- the main character
isICharacter
currentActionName the name of the current action String
netID the network ID (String)
chatColorthe color for chat messages
displayNamethe character name for chat
DIDNT_ACHIEVED_DESTINATION_TILE

Variables

_stackable

private var _stackable: Boolean

stacks on top of other tiles, taking elevation in consideration overwriting the parent class value (MapObject._stackable)

_walkable

private var _walkable: Boolean

flag(Boolean) that tells if characters(Character) can walk on top of this object overwriting the parent class value (MapObject._walkable)

_netID

private var _netID: String

id(String) for network characters (in multi--user envirorment).  String is used for compatibility between different socket servers (SFS uses Number)

_chatColor

private var _chatColor: Number

predefined chat message color borders. it helps differentiating the messages

_phasesMC

private var _phasesMC: MovieClip

MovieClip that contains all the characters animation phases

_an_frames

private var _an_frames: Number

number(Number) of animation phases per step of animation

_usesLeftRightSteps

private var _usesLeftRightSteps: Boolean

flag(Boolean) -- the step animation is made of left and right step parts

IGNORES_TERRAIN_ELEVATIONS

private var IGNORES_TERRAIN_ELEVATIONS: Boolean

flag(Boolean) -- ignores floor tiles elevations

SMOOTH_ELEVATION

private var SMOOTH_ELEVATION: Boolean

flag(Boolean) -- elevates gradually from tile to tile, instead of “jumping” on top of the elevated tile

_speed

private var _speed: Number

animation speed(Number). it is actually the time between phases, so bigger values mean slowe animation speed

_moveToDirection

private var _moveToDirection: Number

remembers the direction(Number) the character should move to WHEN IT CAN (it can’t change direction in the middle of the stepping animation). the character checks at the end of each step this direction.

_isMoving

private var _isMoving: Boolean

flag (Boolean)

_isDoingAnAction

private var _isDoingAnAction: Boolean

flag (Boolean)

_isICharacter

private var _isICharacter: Boolean

main character (“I”)

_displayName

private var _displayName: String

character’s name (String)

_direction

private var _direction: Number

the direction(Number) the character is turned to

_cActionToDo

private var _cActionToDo: Object

the action the character has to do (whenever possible.  For example when he/she is done with the step animation that can not be interrupted). undefined -- nothing to do (walking and standing in not an action) {action:String, params:Object}

_cActionEndFrame

private var _cActionEndFrame: Number

the number of phases/frames of the current action animation; 1 by default

_cCurrentTileElevation

private var _cCurrentTileElevation: Number

the elevation(Number) of the current tile (Tile) -- elevation is the character own elevation -- can be different

_cFutureTileElevation

private var _cFutureTileElevation: Number

the elevation(Number) of the current tile (Tile) -- elevation is the character own elevation -- can be different

_phase

private var _phase: Number

character animation phase (Number)

_brain

private var _brain: CharacterLogic

the reference to the CharacterLogin object

_autoPilot

private var _autoPilot: Boolean

flag(Boolean) -- if the character is in autoPilot mode, he decides himself were to move, for example random monster movements

_anInt

private var _anInt: Number

used to store animation interval function (setInterval:Function) id

_layersXMLNode

private var _layersXMLNode: XMLNode

[node:XMLNode] stores the XML nodes(XMLNode) -- this way we can store all the possible parametters, and we can also extend the functionality easily

_layers

private var _layers: Object

to access the parametters just use -- _layers[XMLNode.attributes.name]

_visibleLayers

private var _visibleLayers: Object

visible layers (clothes and accessories)

to access the parametters just use -- _visibleLayers[XMLNode.attributes.name]

LAYERS_PROTOCOL_GROUP

private static var LAYERS_PROTOCOL_GROUP: String

LAYERS_PROTOCOL_LAYER

private static var LAYERS_PROTOCOL_LAYER: String

LAYERS_PROTOCOL_NAME

private static var LAYERS_PROTOCOL_NAME: String

LAYERS_PROTOCOL_REQUIRED

private static var LAYERS_PROTOCOL_REQUIRED: String

_pShiftX

private var _pShiftX: Number

the shift by X(Number) for each walking/moving animation frame

_pShiftY

private var _pShiftY: Number

the shift by Y(Number) for each walking/moving animation frame

_dShiftX

private var _dShiftX: Number

the diagonal X(Number) shift for each walking/moving animation frame

_dShiftY

private var _dShiftY: Number

the diagonal Y(Number) shift for each walking/moving animation frame

_tileDiagonal

private var _tileDiagonal: Number

distance(Number) between diagonal tiles (Tile)

nameTxt

private var nameTxt: TextField

the text field for displaying the character name

OPT -- it is easier to create the Text Field during the runtime, or, if it’s created in the TimeLine -- give it the parametter TextField.variablе.  This way it’s easier and we don’t have to deal with key frames

debugTxt

private var debugTxt: TextField

debugging text field (TextField)

_libSpeed

private var _libSpeed: Number

the speed(Number) of the character from the Library stored locally for better performance TODO -- add the possibility to accelerate the characters at will.  Right now just the dead reconing changes its speed

_selectable

private var _selectable: Boolean

flag(Boolean)is the character selectable or not

_hitTestBitmap

private var _hitTestBitmap: BitmapData

the bitmap used for hit test (detect the clicks on the character).  Since we use bitmaps, the standart MovieClip.hitTest will react to the clicks on the transparent areas as well Is created just on Character._spriteMC#onRollOver() deleted on Character._spriteMC.#nRollOut()

_hitTestBitmapFirstPoint

private var _hitTestBitmapFirstPoint: Point

the parametter used for BitmapData.hitTest(firstPoint:Point, firstAlphaThreshold:Number, secondObject:Object) stored for optimizing the hit test

Functions and Properties

Character

public function Character(target: MovieClip,
spriteMCName: String,
spriteMCZOrder: Number,
tileX: Number,
tileY: Number,
cs: CharacterSettings,
withoutValidation: Boolean)

Parameters

targetMovieClip to wich the character object is attached to
spriteMCNamethe name of the Character._spriteMC (if it’s created)
spriteMCZOrderz--order of the Character._spriteMC (if it’s created)
tileXposition on the map -- column(Number) (also storred in CharacterSettings)
tileYposition on the map -- row(Number)...
cs(CharacterSettings)

init

private function init(cs: CharacterSettings):Void

initialization

Parameters

cs(CharacterSettings)

onLoadInitLibrarySymbol

private function onLoadInitLibrarySymbol(cs: CharacterSettings):Void

called when the character is loaded -- overwrites the parent method

Parameters

cs(CharacterSettings)

onLoadCompleteLibrarySymbol

private function onLoadCompleteLibrarySymbol(cs: CharacterSettings):Void

characters are more complex then other map objects (floor tiles, furniture) and need to finish the initialization after the locading

Parameters

cs(CharacterSettings)

activate

private function activate(cs: CharacterSettings):Void

activating the character -- dress and make it move

Parameters

cs(CharacterSettings)

place

public function place(tileX: Number,
tileY: Number,
dir: Number,
phase: Number,
elevation: Number,
action: String,
actionParams: Object):Void

placing the character on the map

Parameters

tileX-- position on the map -- column(Number) (also storred in CharacterSettings)
tileY-- position on the map -- row(Number)...
dir-- the direction(Number) the character should turn to
phase-- the movement animation phase (frame)(Number)
elevation-- elevation(Number) above the zero level
action-- the action name(String), if any
actionParams-- action parametters.  This would be used just when we want to modify a standart action since the action parametters are already stored in _actions This is NOT being used at this point

doAction

public function doAction(action: String,
params: Object):Void

makes the character perform an action (ex: dance)

Parameters

action-- the name of the action(String)
params-- attributes -- the action parametters(Object). his would be used just when we want to modify a standart action since the action parametters are already stored in _actions This is NOT being used at this point

actionAn

private function actionAn(action: String,
params: Object):Void

step animation actionFrameLabel -- first frame of the action nonStop -- loop

Parameters

action-- name of the action(String)
params-- action parametters(Object) (not used right now)

setCurrentAction

private function setCurrentAction(action: String):Void

sets the current action. has to be called once when the character current action changes

Parameters

action-- the action name (String)

isMovableAction

private function isMovableAction(action: String):Boolean

movable -- the action used to movements

Parameters

action-- the action name(String)

Returns

flag -- (Boolean).  Default value is false. 

isNonStopAction

private function isNonStopAction(action: String):Boolean

nonStopAction -- “looping” action

Parameters

action-- the action name (String)

Returns

Boolean.  Default value is false. 

isSnapToAction

private function isSnapToAction(action: String):Boolean

snapToAction -- switches to this action instantly (like sitting on a chair after wakling, without walking on the chair

Parameters

action-- the action name (String)

Returns

Boolean Default value is false. 

getActionFrameNumber

private function getActionFrameNumber(action: String):Number

Parameters

action-- the action name (String)

Returns

the number of frames for a given action (or moving animation).  By default == 1

isUsesLeftRightSteps

private function isUsesLeftRightSteps(action: String):Boolean

used for movable actions to distinguish movements that use left and right steps (walking) from the ones that don’t (sliding, floating...).

Parameters

action-- the action name (String)

Returns

Boolean.  Default value is false

stopAction

public function stopAction():Void

stops the character action

stand

public function stand():Void

stand still

freeze

public function freeze():Void

unlike the stopMoving, that makes the character to come to a stop naturally (finishing the step, for example), this method forces the character to freeze right away.  Usually the Character.place is called right after that.

turn

public function turn(dir: Number,
phase: Number):Void

makes the character turn to a given direction

Parameters

dir-- the direction(Number) the character should turn to
phase-- phase(Number) of animation

moveToTile

public function moveToTile(tileX: Number,
tileY: Number,
latency: Number):Void

makes the character move to the indicated tile

Parameters

tileX-- position on the map -- column (also storred in CharacterSettings)
tileY-- position on the map -- row...
latency(Number) -- lag, if it’s too big, the character accelerates

moveToDir

public function moveToDir(dir: Number,
nonStop: Boolean):Void

makes the character start to move in a specific direction // TODO -- implement the same for network characters

Parameters

dir-- the direction(Number) the character should turn to
nonStop-- flag(Boolean) that tell the character to stop after this step or move on

moveDirProcessing

public function moveDirProcessing(dir: Number,
nonStop: Boolean):Void

moves the character to a given direction this function is used to emulate the keyboard control.  CharacterLogic takes care of it -- it calls this method to make a character move, stop and keep moving // TMP public for CharacterLogic

Parameters

dir-- the direction(Number) the character should turn to
nonStop-- if this flag is true -- keeps moving in that directions untill stopped. if not -- makes just one step. 

stopMoving

private function stopMoving():Void

stops the character movement

stepAn

private function stepAn(nonStop: Boolean):Void

used for step animation

Parameters

nonStop-- flag(Boolean) that tell the character to stop after this step or move on

changeInterval

private function changeInterval(speed: Number):Void

method is used for dead reconing only now.  TODO more functional

Parameters

speed-- the speed(Number) of the character

scrollMap

private function scrollMap(mapShiftX: Number,
mapShiftY: Number):Void

calls the map scroll function, if needed

Parameters

mapShiftX(Number)
mapShiftY(Number)

isStepEnded

private function isStepEnded(phase: Number): Boolean

checks if the step animation ended

Parameters

phase(Number) of animation

Returns

(Bolean)

testLayers

private function testLayers():Void

initLayers

private function initLayers():Void

parcing the XML from the Library RECOMMENDED!  -- include in XML just the layers that will have its transparency changed (clothes or accessories -- can be hidden) and keep the rest as part of the body -- this makes the coding easier

takeAllLayersOn

public function takeAllLayersOn():Void

shows all layers of clothes

takeAllLayersOff

public function takeAllLayersOff():Void

hides all layers of clothes

takeGroupClothesOff

public function takeGroupClothesOff():Void

hides the layers of a given group (if it is declared in the XML)

if sub--groups are used, the string value can be passed as grop.subgroup (dot--syntax)

multiple groups can be passed, separated by commas, like takeClothesOffByGroup(“clothes.tops”, “clothes.bottoms”, “hair”);

if you have a tree of groups (“clothes.tops, “clothes.bottoms” ), you can call takeClothesOffByGroup(“clothes”), and it will hide all the sub--groups

putGroupClothesOn

public function putGroupClothesOn():Void

shows the layers of a given group (if it is declared in the XML)

when using sub--groups, a dot--syntax is used: grop.subgroup

takeClothesOff

public function takeClothesOff():Void

hides layers of clothes the (String) parametter is passed with the names of the layers, separated by commas: takeLayersOff(“top1”, “bottom24”);

putClothesOn

public function putClothesOn():Void

shows layers of clothes the (String) parametter is passed with the names of the layers, separated by commas: takeLayersOn(“top1”, “bottom24”);

getGroupClothesList

public function getGroupClothesList(chain: String,
deep: Boolean):Object

get the list of the layer groups

Parameters

chain-- string is a dot--syntax -- “clothes.tops”
deep-- same as in XMLNode.cloneNode(deep) -- a flag that tells it to include the sub--groups or not.  By default deep = true

Returns

Object of this type: {layerName1:XMLNode, layerName2:XMLNode, layerName3:XMLNode...} 

getDressedClothes

public function getDressedClothes():Object

Returns

[XMLNode]

getGroupNode

public function getGroupNode(chain: String,
source: XMLNode):XMLNode

this function makes it easier to get through the XML.  It’s used in TheoChat, that’s why it’s public

Parameters

chain-- string is a dot--syntax -- “clothes.tops”
source(XMLNode)

getLayersFromNode

private function getLayersFromNode(node: XMLNode,
deep: Boolean):Object

Parameters

nodeXMLNode
deepBoolean -- if set to true, the children of the specified XML object will be recursively returned

Returns

Object{layerName_1, [layerName_n]}

updateClothesPhase

private function updateClothesPhase():Void

synchronize clothes animation with character animation

dressRandomClothes

public function dressRandomClothes(requiredOn: Boolean):Void

dresses a character in random clothes paces all the clothes groups -- same as with CHARACTER_CLOTHES_TYPES

Parameters

requiredOn(Boolean) -- if there is a CHARACTER_CLOTHES_TYPES_REQUIRED in the group -- one layer is left visible

getHeight

public function getHeight(): Number

Returns

character height(Number) (the size of the non--transparent area of the bitmap -- not the movieclip)

getCrown

public function getCrown():Number

Returns

the height(Number) of the character from the registration point till its top (the bimap) Example -- a character sits on the floor -- it means his height above the floor is lower than if he would stand up

attachBrain

public function attachBrain(brainType: String,
autoStart: Boolean,
initObj: Object):Void

connects a CharacterLogic object to a character

Parameters

brainType(String)
autoStart(Boolean)
initObj

detachBrain

private function detachBrain():Void

disconnects the CharacterLogic object from a character

clear

public function clear():Void

cleans the assets

getSettings

public function getSettings(type: Number):CharacterSettings

returns character settings

Parameters

type(Number) -- used for optimization, so it doesn’t return redundant properties (unused at this moment)

Returns

CharacterSettings

onClickSpriteMC

private function onClickSpriteMC():Void

this event is called only when _selectable (Character._selectable) == true; it triggers a method in the World that takes action

onRollOverSpriteMC

private function onRollOverSpriteMC():Void

this event is called only when selectable(Character._selectable) == true; it calls hitTestMode to find out if the area clicked is not transparent (empty)

onRollOutSpriteMC

private function onRollOutSpriteMC():Void

called when selectable(Character._selectable) == true; turns off hitTestMode

hitTestMode

private function hitTestMode():Void

detects if the click is made on actual non--transparent part of the furniture

setHighlight

private function setHighlight(b: Boolean):Void

called when selectable(Character._selectable) == true; highlights on un/highlights a furniture

Parameters

paramBoolean

selectable

public function get selectable():Boolean

checks if the furniture is selectable (Character._selectable)

Returns

Boolean

selectable

public function set selectable(b: Boolean):Void

makes the Character object selectable or not

Parameters

paramBoolean

speed

public function get speed():Number

Returns

speed of character animation.  TODO -- return current speed of character animation

speed

public function set speed(speed: Number):Void

used by CharacterLogic(CharacterLogic) when doing deadReconing the character changes the speed when it can TODO optional

getLibSpeed

public function getLibSpeed():Number

Returns

Library (Library) speed of the character (the base speed he should use when no compensation is applied on top of it)

isDoingAnAction

public function isDoingAnAction(): Boolean

Returns

Boolean.  Is doing character any action. 

getDirection

public function getDirection():Number

Returns

the direction(Number) the character is turned to Character._direction

isMoving

public function get isMoving(): Boolean

Returns

Character._isMoving

getDestinationTile

public function getDestinationTile():Point

Returns

coordinates ( Point(col, row) ) of the tile that the character moves to

isICharacter

public function get isICharacter(): Boolean

Returns

Boolean -- is the character controllable (mouse, keyboard) -- the main character

isICharacter

public function set isICharacter(b: Boolean):Void

currentActionName

public function get currentActionName():String

Returns

the name of the current action String

netID

public function get netID ():String

Returns

the network ID (String)

chatColor

public function get chatColor():Number

Returns

the color for chat messages

displayName

public function get displayName():String

Returns

the character name for chat

DIDNT_ACHIEVED_DESTINATION_TILE

public static function get DIDNT_ACHIEVED_DESTINATION_TILE():String
base class for all map objects classes on the map : Tile, Furniture, Character
private var _stackable: Boolean
stacks on top of other tiles, taking elevation in consideration overwriting the parent class value (MapObject._stackable)
private var _stackable: Boolean
stacks on top of other tiles, taking elevation in consideration
private var _walkable: Boolean
flag(Boolean) that tells if characters(Character) can walk on top of this object overwriting the parent class value (MapObject._walkable)
public function Character(target: MovieClip,
spriteMCName: String,
spriteMCZOrder: Number,
tileX: Number,
tileY: Number,
cs: CharacterSettings,
withoutValidation: Boolean)
private var _walkable: Boolean
flag(:Boolean) that tells if characters(Character) can walk on top of this object
private var _netID: String
id(String) for network characters (in multi--user envirorment).
private var _chatColor: Number
predefined chat message color borders.
private var _phasesMC: MovieClip
MovieClip that contains all the characters animation phases
private var _an_frames: Number
number(Number) of animation phases per step of animation
private var _usesLeftRightSteps: Boolean
flag(Boolean) -- the step animation is made of left and right step parts
private var IGNORES_TERRAIN_ELEVATIONS: Boolean
flag(Boolean) -- ignores floor tiles elevations
private var SMOOTH_ELEVATION: Boolean
flag(Boolean) -- elevates gradually from tile to tile, instead of “jumping” on top of the elevated tile
private var _speed: Number
animation speed(Number).
private var _moveToDirection: Number
remembers the direction(Number) the character should move to WHEN IT CAN (it can’t change direction in the middle of the stepping animation).
private var _isMoving: Boolean
flag (Boolean)
private var _isDoingAnAction: Boolean
flag (Boolean)
private var _isICharacter: Boolean
main character (“I”)
private var _displayName: String
character’s name (String)
private var _direction: Number
the direction(Number) the character is turned to
private var _cActionToDo: Object
the action the character has to do (whenever possible.
private var _cActionEndFrame: Number
the number of phases/frames of the current action animation; 1 by default
private var _cCurrentTileElevation: Number
the elevation(Number) of the current tile (Tile) -- elevation is the character own elevation -- can be different
Tile class -- floor tile main class
private var _cFutureTileElevation: Number
the elevation(Number) of the current tile (Tile) -- elevation is the character own elevation -- can be different
private var _phase: Number
character animation phase (Number)
private var _brain: CharacterLogic
the reference to the CharacterLogin object
private var _autoPilot: Boolean
flag(Boolean) -- if the character is in autoPilot mode, he decides himself were to move, for example random monster movements
private var _anInt: Number
used to store animation interval function (setInterval:Function) id
private var _layersXMLNode: XMLNode
[node:XMLNode] stores the XML nodes(XMLNode) -- this way we can store all the possible parametters, and we can also extend the functionality easily
private var _layers: Object
to access the parametters just use -- _layers[XMLNode.attributes.name]
private var _visibleLayers: Object
visible layers (clothes and accessories)
private static var LAYERS_PROTOCOL_GROUP: String
private static var LAYERS_PROTOCOL_LAYER: String
private static var LAYERS_PROTOCOL_NAME: String
private static var LAYERS_PROTOCOL_REQUIRED: String
private var _pShiftX: Number
the shift by X(Number) for each walking/moving animation frame
private var _pShiftY: Number
the shift by Y(Number) for each walking/moving animation frame
private var _dShiftX: Number
the diagonal X(Number) shift for each walking/moving animation frame
private var _dShiftY: Number
the diagonal Y(Number) shift for each walking/moving animation frame
private var _tileDiagonal: Number
distance(Number) between diagonal tiles (Tile)
private var nameTxt: TextField
the text field for displaying the character name
private var debugTxt: TextField
debugging text field (TextField)
private var _libSpeed: Number
the speed(Number) of the character from the Library stored locally for better performance TODO -- add the possibility to accelerate the characters at will.
LibraryItem class i- stores and manages a collection of LibraryItem objects organized in sub-libraries - those are map objects like Floor tiles, Furniture and Characters that can be placed on maps
private var _selectable: Boolean
flag(Boolean)is the character selectable or not
private var _hitTestBitmap: BitmapData
the bitmap used for hit test (detect the clicks on the character).
private var _hitTestBitmapFirstPoint: Point
the parametter used for BitmapData.hitTest(firstPoint:Point, firstAlphaThreshold:Number, secondObject:Object) stored for optimizing the hit test
private function init(cs: CharacterSettings):Void
initialization
private function onLoadInitLibrarySymbol(cs: CharacterSettings):Void
called when the character is loaded -- overwrites the parent method
private function onLoadCompleteLibrarySymbol(cs: CharacterSettings):Void
characters are more complex then other map objects (floor tiles, furniture) and need to finish the initialization after the locading
private function activate(cs: CharacterSettings):Void
activating the character -- dress and make it move
public function place(tileX: Number,
tileY: Number,
dir: Number,
phase: Number,
elevation: Number,
action: String,
actionParams: Object):Void
placing the character on the map
public function doAction(action: String,
params: Object):Void
makes the character perform an action (ex: dance)
private function actionAn(action: String,
params: Object):Void
step animation actionFrameLabel -- first frame of the action nonStop -- loop
private function setCurrentAction(action: String):Void
sets the current action.
private function isMovableAction(action: String):Boolean
movable -- the action used to movements
private function isNonStopAction(action: String):Boolean
nonStopAction -- “looping” action
private function isSnapToAction(action: String):Boolean
snapToAction -- switches to this action instantly (like sitting on a chair after wakling, without walking on the chair
private function getActionFrameNumber(action: String):Number
private function isUsesLeftRightSteps(action: String):Boolean
used for movable actions to distinguish movements that use left and right steps (walking) from the ones that don’t (sliding, floating...)
public function stopAction():Void
stops the character action
public function stand():Void
stand still
public function freeze():Void
unlike the stopMoving, that makes the character to come to a stop naturally (finishing the step, for example), this method forces the character to freeze right away.
public function turn(dir: Number,
phase: Number):Void
makes the character turn to a given direction
public function moveToTile(tileX: Number,
tileY: Number,
latency: Number):Void
makes the character move to the indicated tile
public function moveToDir(dir: Number,
nonStop: Boolean):Void
makes the character start to move in a specific direction // TODO -- implement the same for network characters
public function moveDirProcessing(dir: Number,
nonStop: Boolean):Void
moves the character to a given direction this function is used to emulate the keyboard control.
private function stopMoving():Void
stops the character movement
private function stepAn(nonStop: Boolean):Void
used for step animation
private function changeInterval(speed: Number):Void
method is used for dead reconing only now.
private function scrollMap(mapShiftX: Number,
mapShiftY: Number):Void
calls the map scroll function, if needed
private function isStepEnded(phase: Number): Boolean
checks if the step animation ended
private function testLayers():Void
private function initLayers():Void
parcing the XML from the Library RECOMMENDED! 
public function takeAllLayersOn():Void
shows all layers of clothes
public function takeAllLayersOff():Void
hides all layers of clothes
public function takeGroupClothesOff():Void
hides the layers of a given group (if it is declared in the XML)
public function putGroupClothesOn():Void
shows the layers of a given group (if it is declared in the XML)
public function takeClothesOff():Void
hides layers of clothes the (String) parametter is passed with the names of the layers, separated by commas: takeLayersOff(“top1”, “bottom24”);
public function putClothesOn():Void
shows layers of clothes the (String) parametter is passed with the names of the layers, separated by commas: takeLayersOn(“top1”, “bottom24”);
public function getGroupClothesList(chain: String,
deep: Boolean):Object
get the list of the layer groups
public function getDressedClothes():Object
[XMLNode]
public function getGroupNode(chain: String,
source: XMLNode):XMLNode
this function makes it easier to get through the XML.
private function getLayersFromNode(node: XMLNode,
deep: Boolean):Object
private function updateClothesPhase():Void
synchronize clothes animation with character animation
public function dressRandomClothes(requiredOn: Boolean):Void
dresses a character in random clothes paces all the clothes groups -- same as with CHARACTER_CLOTHES_TYPES
public function getHeight(): Number
character height(Number) (the size of the non--transparent area of the bitmap -- not the movieclip)
public function getCrown():Number
the height(Number) of the character from the registration point till its top (the bimap) Example -- a character sits on the floor -- it means his height above the floor is lower than if he would stand up
public function attachBrain(brainType: String,
autoStart: Boolean,
initObj: Object):Void
connects a CharacterLogic object to a character
private function detachBrain():Void
disconnects the CharacterLogic object from a character
public function clear():Void
cleans the assets
public function getSettings(type: Number):CharacterSettings
returns character settings
private function onClickSpriteMC():Void
this event is called only when _selectable (Character._selectable) == true; it triggers a method in the World that takes action
World class -- main class that builds an isometric tile--based map
private function onRollOverSpriteMC():Void
this event is called only when selectable(Character._selectable) == true; it calls hitTestMode to find out if the area clicked is not transparent (empty)
private function onRollOutSpriteMC():Void
called when selectable(Character._selectable) == true; turns off hitTestMode
private function hitTestMode():Void
detects if the click is made on actual non--transparent part of the furniture
private function setHighlight(b: Boolean):Void
called when selectable(Character._selectable) == true; highlights on un/highlights a furniture
public function get selectable():Boolean
checks if the furniture is selectable (Character._selectable)
public function get speed():Number
speed of character animation.
CharacterLogic class - stores the character logic.
public function getLibSpeed():Number
Library (Library) speed of the character (the base speed he should use when no compensation is applied on top of it)
public function isDoingAnAction(): Boolean
Boolean.
public function getDirection():Number
the direction(Number) the character is turned to Character._direction
public function get isMoving(): Boolean
Character._isMoving
public function getDestinationTile():Point
coordinates ( Point(col, row) ) of the tile that the character moves to
public function get isICharacter(): Boolean
Boolean -- is the character controllable (mouse, keyboard) -- the main character
public function get currentActionName():String
the name of the current action String
public function get netID ():String
the network ID (String)
public function get chatColor():Number
the color for chat messages
public function get displayName():String
the character name for chat
public static function get DIDNT_ACHIEVED_DESTINATION_TILE():String
CharacterSettings class stores the settings of a Character object
Close