com.theoworlds.builder.World |
World class -- main class that builds an isometric tile--based map
1.0
© TheoWorlds.com, 2007--2008.
| com. | World class -- main class that builds an isometric tile--based map |
| Variables | |
| addEventListener | |
| removeEventListener | |
| dispatchEvent | |
| _onEnterFrameBeaconForCursor | |
| _highestFloorTileElevation | |
| _mapName | the name of th map. |
| _worldLogic | link the class (WorldLogic) that processes the user UI events (mouse, keyboard) can be extended to add more functionality (generation ond processing on World actions) |
| _sizeX | world/map/room size X = columns(:Number) |
| _sizeY | world/map/room size Y = rows(:Number) |
| _scrollY | scrollable world/map/room area(:Number) (the sub--area of the big map that fits on the the screen) defined in rows/cols. |
| _scrollX | scrollable world/map/room area(:Number) (the sub--area of the big map that fits on the the screen) defined in rows/cols. |
| _scrollBuffer | the number(:Number) of pixels left till the edge of the map when the auto--scrolling starts. |
| _tileWidth | tile size (width(:Number) ). |
| _tileHeight | tile size (height(:Number) ). |
| halfTileWidth | |
| halfTileHeight | |
| _tileDiagonal | |
| _worldMC | the main movieclip(:MovieClip), inside which the World is created |
| _maskMC | mask movieclip(:MovieClip) (it’s existence and parametters are set in the World constructor) the movie that may contains the mask for the map, to hide parts of it (that are bigger than the visible area) |
| _containerMC | the top container MC(:MovieClip) that contains everything |
| _backgroundMC | map background(:MovieClip) |
| _floorMC | mc(:MovieClip) containing all the floor tiles |
| debugLayerMC | |
| _mouseMC | movieclip (:MovieClip)for the cursor (World._cursorMC) changing its depth we can use it for different purposes (for example now it points only on the floor, but is covered by characters and furniture) |
| _cursorMC | cursor movieclip(:MovieClip). |
| _contentMC | the main mc(:MovieClip) containing furniture(:Furniture) and characters(:Character) |
| _furnitureCursorMC | |
| _chatMC | contains the chat bubbles (:TextBubble) |
| _foregroundMC | map foreground (:MovieClip) |
| _furnitureStandingOrderList | the array that stores the ORDER in which the furniture is added to the map when its created (the Map Editor generates this order. |
| _aFloor | the array that contains the floor tiles _aFloor[n][m] = Tile (Tile) |
| _aFurniture | the array that contains the furniture _aFurniture[n][m] = Furniture (Furniture) |
| _aCharacters | the array that contains the characters _aCharacters[n][m] = Characters (Character) |
| _lastObjectID | tracks the objects IDs used for Worlds initialization, for generating the names of the movieclips |
| _charactersList | character list for a quick reference (instead of looping the whole aCharacters 3D array) OPT define List object with lookup and other functions |
| _charactersAreSelectable | a flag -- not used yet |
| _rollOveredCharacter | link to the Character. |
| _iCharacter | the reference to “I” (main) character |
| _worldOrigin | top left corner of the map (the ground level) |
| _tbController | class--controller of the text bubbles |
| MAX_ROW_ZORDER | a z--order value calculated on initialization for speed |
| _scrollWidth | the width of the scroll area. |
| _scrollHeight | the height of the scroll area. |
| _maxScrollX | maximum scroll value in X |
| _maxScrollY | maximum scroll value in Y |
| Functions | |
| World | |
| init | initializes the World object |
| maskMap | Mask map -- can be used hide the area of the map that is out of the scroll area |
| maskHitTest | true if the click was on the mask and false otherwise (or if the mask is not present) |
| initAllTiles | loops the aFloor array and adds all the tiles to the map |
| addTile | puts a floor tile on the map If ts:TileSettings contains links to the Library ( see the Library method for more details ), then a MovieClip (MovieClip) and loads the image into it |
| removeTile | removes a tile using its zorder since it’s unique and doesn’t change (tileID = _zorder) note that the Characters use characterID, because their zorder always changes (they move) |
| initAllFurniture | loops the aFurniture array and adds all the furniture objects to the map |
| addFurniture | adds furniture objects to the map |
| furnitureConfigurationAnalyser | |
| getRegistrationPoint | |
| onClickFurniture | furniture with _selectable == true calls this function directly and passes a link to itself as its parametter World uses it to detect ABOVE which exact tile is locate the clicked part of the furniture and passes this information to the WorldLogic (WorldLogic), where the actions to that event are decided |
| initAllCharacters | loops the aCharacters array and adds all the charracters objects to the map |
| addCharacter | adds a character to the map |
| Variables | |
| testCount | |
| Functions | |
| netCharacterCorrection | called fromTheoChat (optimize it?) |
| placeCharacter | instantly places an existing character on a tile (Tile) (and removes from a previous one) |
| moveNetCharacter | * used in TheoChat * tells the character to move to a tile * this method uses overloading * if tileX, tileY is send -- move to that tile * if direction is sent -- move to that direction * call moveCharacter(ID, tileX, tileY) * or moveCharacter(ID, null, null, direction) * @param netID (String) -- network ID of the character(Character) * @param tileX position on the map (column:Number) * @param tileY position on the map (row:Number) * @param dir reduntant? |
| moveCharacter | makes a character move |
| changeCharacterState | not used right now. |
| sendMoveToServer | |
| characterOnMoved | the character informs where he moved to (can be used for adjusting the text bubbles for example) |
| characterDidNotAchieveDestinationTile | the character informes what point he wasn’t able to reach The Worlds checks why and generates an event //TODO -- right now the cause for this situation is another character, but can be extended to include furniture |
| tilesAreNeighbors | checks if the two tiles are next to each other |
| stopCharacter | stops the character |
| doCharacterAction | executes actions like sit, dance... |
| isValidAction | not used anymore since the WorldLogic decides things like that. |
| onRollOverCharacter | called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable) |
| onRollOutCharacter | called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable) |
| onClickCharacter | called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable) |
| getRollOveredCharacter | called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true Character.selectable == true; |
| setBordersForTextBubbleController | usually those parametters coincide with the mask parametters, or the area defined in the GUI |
| netCharacterSay | text message received from another character |
| characterSay | shows a character text message |
| generateObjectName | generates names for tile, furniture, characters |
| removeCharacter | removes a character (Character) |
| removeCharacterByNetID | removes network characters (Character) |
| removeObject | removes an object |
| removeAllFurniture | Removes all the furniture (Furniture) |
| removeAllCharacters | Removes all the characters (Character) |
| scrollMap | scrolls the map |
| getAreaWidth | calculates the width of a floor area |
| getAreaHeight | calculates the height of a floor area |
| Properties | |
| mapScrollX | the ammount of scroll applied to the world/map in pixels |
| mapScrollY | the container position (Number) (movieclip containing the World objects -- floor(Tile), furniture(Furniture), characters(Character)) |
| Functions | |
| centerMap | centers the map around a given tile |
| isInLeftHorizontalScrollArea | finds out in the point is too close to the enge -- within “scroll buffer’ zone x, y -- absolute position on the map is inside the left scroll buffer zone |
| isInRightHorizontalScrollArea | finds out in the point is too close to the enge -- within “scroll buffer’ zone x, y -- absolute position on the map is inside the left scroll buffer zone |
| isInHorizontalScrollArea | finds out in the point is too close to the enge -- within “scroll buffer’ zone x, y -- absolute position on the map is inside the left scroll buffer zone |
| isInTopVerticalScrollArea | the same as in isInHorizontalScrollArea |
| isInBottomVerticalScrollArea | the same as in isInHorizontalScrollArea |
| isInVerticalScrollArea | the same as in isInHorizontalScrollArea |
| isInScrollArea | the same as in isInHorizontalScrollArea, but for all the directions |
| getTileCoordinates | find the tile x:y coorinates -- tile.location tileX, tileY are counted from 1, not from 0 |
| getTileElevation | calculates the tile elevation (the sum of the whole floor tiles stack elevation) |
| getRandomWalkableTile | // TODO used to place a character on a random tile -- has to be optimized |
| _getTileMapLocation | |
| getTileMapLocation | |
| __getTileMapLocation | find the tile row/column on the map -- tileX, tileY by a coordinate |
| getNearestWalkableTile | returns the nearest walkable tile |
| getNearestEmptyTile | return nearest walkable tile tile without any furniture on it |
| getNextTile | returns next tile coordinates to any direction. |
| isWalkableTile | check if the tile is walkable and returns the cause if its not the codes for non--walkable tiles are defined in Constants |
| getCharactersOnTile | a situation when two characters are on the same tile is possible. |
| isValidTile | checks if it’s a valid tile coordinate (within a map, etc). |
| showCursor | shows the mouse cursor depending on mouse events |
| getNextZOrder | calculates next available z--order for each object on a given tile tileX, tileY should be >0 and <=map width/height |
| getStackElZOrder | calculates the zorder of the element by it’s tile and position in the stack a -- the array (aCharacter, aFurniture or aFloor) |
| getObjectBaseZOrder | gets the base z--order |
| getObjectMaxZOrder | gets the maximum z--order |
| removeObjectFromStack | removes the map object (character/furniture/floor) from the tile stack array simple Array.splice() shifts the items above the splice element down, closing the “gap” from the removed object their z--order has to be updated to be in sync with the stack order |
| getObjectStackOrder | returns the the 3rd index of aCharacters array -- his number in the “stack” of characters on the same tile |
| getMapObjectByID | gets the movieclip of a map object |
| getObjectArray | returns aCharacters for CHARACTER_OBJECT and so on... |
| getContainerMC | returns the container movieclip for particular Map Object |
| clear | clears the World |
| Properties | |
| iCharacter | return the main (“I”) character |
| iCharacter | sets the main character OPT needs to be removed from here? |
| mouseX | getting local _xmouse coordinates |
| mouseY | getting local _ymouse |
| tileWidth | getting tile width |
| tileHeight | getting tile height |
| worldLogic | |
| worldLogic | link to the WorldLogic (WorldLogic) |
| charactersAreSelectable | sets the flag so the character can be selectable (not implemented yet) |
| charactersAreSelectable | returns the flag value (Boolean) |
| isMasked | returns the flag value (Boolean) |
| Functions | |
| getTileActionName | returns the NAME of the action, that is saved in the BASE tile (depends on the actions that are assigned to the furniture on that tile) this method is needed for a better performance -- a name is enough in most cases otherwise we would need to use the heavy method World.getTileAction |
| getTileAction | retuns the copy action (Object). |
| getCharactersList | |
| Properties | |
| EVENT_CHARACTER_MOVE | |
| EVENT_CHARACTER_STOP | |
| EVENT_CHARACTER_CHANGE_SETTINGS | |
| EVENT_CHARACTER_DESTINATION_CORRECTION | |
| EVENT_CHARACTER_ARRIVED_TELEPORT | |
| EVENT_CHARACTER_IS_CLICKED | |
| Functions | |
| onRollOverFurniture | |
| onRollOutFurniture | |
| traceMapArrays | |
| fillTilesArea | // TODO |
| getTileMC | NOT WORKING |
| drawDebugGrid | NOT WORKING |
private var _worldLogic: WorldLogic
link the class (WorldLogic) that processes the user UI events (mouse, keyboard) can be extended to add more functionality (generation ond processing on World actions)
private var _mouseMC: MovieClip
movieclip (:MovieClip)for the cursor (World._cursorMC) changing its depth we can use it for different purposes (for example now it points only on the floor, but is covered by characters and furniture)
private var _chatMC: MovieClip
contains the chat bubbles (:TextBubble)
private var _furnitureStandingOrderList: Array
the array that stores the ORDER in which the furniture is added to the map when its created (the Map Editor generates this order. if the map is created manually, then the furniture will have to be placed in the XML is the right order). This is necessary for displaying the objects correctly. For example, so the vase is on the table, and not vice versa -- the table has to be added first, and only after that the vase
private var _aFloor: Array
the array that contains the floor tiles _aFloor[n][m] = Tile (Tile)
private var _aFurniture: Array
the array that contains the furniture _aFurniture[n][m] = Furniture (Furniture)
private var _aCharacters: Array
the array that contains the characters _aCharacters[n][m] = Characters (Character)
public function World( target: MovieClip, sizeX: Number, sizeY: Number, tHeight: Number, tWidth: Number, mapBGImage: Object, mapFGImage: Object, aFloor: Array, aFurniture: Array, aCharacters: Array, origin: Point, scrollX: Number, scrollY: Number, scrollBuffer: Number, masking: Boolean, maskMinX: Number, maskMinY: Number, maskMaxX: Number, maskMaxY: Number )
| target | root MC for the World (MovieClip) |
| sizeX | number of columns |
| sizeY | number of rows |
| tileHeight | tile height |
| tileWidth | tileWidth |
| mapBGImage | object with background image params {url:String, _x:Number, _y:Number} |
| mapFGImage | object with foreground image params {url:String, _x:Number, _y:Number} |
| _aFloor | 3D array containing floor tile objects (Array) |
| _aFurniture | 3D array containing furniture objects (Array) |
| _aCharacters | 3D array containig characters objects (Array) |
| origin | World origin (Point) |
| scrollX | defines the scrollable area in columns |
| scrollY | defines the scrollable area in rows |
| scrollBuffer | |
| masking | flag -- is a mask used or not |
| maskX | defines the masked area of the world in columns |
| maskY | defines the masked area of the world in rows |
| maskMaxX | the maximum Х for the mask |
| maskMaxY | the maximum Y for the mask |
private function init( target: MovieClip, sizeX: Number, sizeY: Number, tileHeight: Number, tileWidth: Number, mapBGImage: Object, mapFGImage: Object, aFloor: Array, aFurniture: Array, aCharacters: Array, origin: Point, scrollX: Number, scrollY: Number, scrollBuffer: Number, masking: Boolean, maskMinX: Number, maskMinY: Number, maskMaxX: Number, maskMaxY: Number ):Void
initializes the World object
private function addTile( tileX: Number , tileY: Number , ts: TileSettings ):Tile
puts a floor tile on the map If ts:TileSettings contains links to the Library ( see the Library method for more details ), then a MovieClip (MovieClip) and loads the image into it
| tileX | Number position on the map (row) |
| tileY | Number posituin in the map (column) |
| ts | TileSettings |
public function addFurniture( tileX: Number, tileY: Number, fs: FurnitureSettings ): Furniture
adds furniture objects to the map
| tileX | |
| tileY | |
| fs | (FurnitureSettings) |
function furnitureConfigurationAnalyser( configuration: String, registrationTile: String, destTile: Point ):Array
| configuration | -- the string from ХML Library |
| registrationTile | = the string from XML Library |
| detTile | -- the tile on which to place the furniture |
Object {occupiedTiles:Array} -- the array that stores all the tiles the furniture covered
public function onClickFurniture( f: Furniture ):Void
furniture with _selectable == true calls this function directly and passes a link to itself as its parametter World uses it to detect ABOVE which exact tile is locate the clicked part of the furniture and passes this information to the WorldLogic (WorldLogic), where the actions to that event are decided
| f | (Furniture) |
public function addCharacter( tileX: Number, tileY: Number, cs: CharacterSettings ): Character
adds a character to the map
| tileX | |
| tileY | |
| cs | (CharacterSettings) |
Character (Character)
public function netCharacterCorrection( cs: CharacterSettings, cause: MapObjectSettings ):Void
called fromTheoChat (optimize it?) in case a conflict situation happened (due to net latency)
| cs | (CharacterSettings) -- character that can’t reach the destination |
| cause | (MapObject) -- the cause of the conflict // TODO -- right now the cause it another character (that got to the destination and occupied it before, most likely), but in the future it can be extended to include furniture (for cases when it changes or moves as well). |
public function placeCharacter( characterID: Number, tileX: Number, tileY: Number, dir: Number, phase: Number, action: String, actionParams: Object ):Void
instantly places an existing character on a tile (Tile) (and removes from a previous one)
| characterID | (Number) |
| tileX | position on the map (column:Number) |
| tileY | position on the map (row:Number) |
| dir | (Number) direction the character is facing |
| phase | (Number) the animation phase |
| action | the action the character(Character) is performing |
| actionParams | (Object) -- not used right now, but can be used to pass details about the action |
public function moveNetCharacter( netID: String, tileX: Number, tileY: Number, dir: Number, nonStop: Boolean, latency: Number ):Void
* used in TheoChat * tells the character to move to a tile * this method uses overloading * if tileX, tileY is send -- move to that tile * if direction is sent -- move to that direction * call moveCharacter(ID, tileX, tileY) * or moveCharacter(ID, null, null, direction) * @param netID (String) -- network ID of the character(Character) * @param tileX position on the map (column:Number) * @param tileY position on the map (row:Number) * @param dir reduntant? needs to be deleted? * @param nonStop redundant? needs to be deleted? * @param latency the total network lag time (adding the two characters personal lags -- the “I” one and the indicated one) -- used to accelerate the character to compensate for the lag
public function moveCharacter( characterID: Number, tileX: Number, tileY: Number, dir: Number, nonStop: Boolean, latency: Number ):Void
makes a character move
| characterID | (Number) |
| tileX | position on the map (column:Number) |
| tileY | position on the map (row:Number) |
| dir | (Number) direction the character is facing |
| nonStop | redundant? |
| latency | the total network lag time (adding the two characters personal lags -- the “I” one and the indicated one) -- used to accelerate the character to compensate for the lag |
public function changeCharacterState( cs: CharacterSettings ):Void
not used right now. can be used to update character settings like the clothes and pass them to the server
| cs | (CharacterSettings) |
public function characterOnMoved( characterID: Number, tileX: Number, tileY: Number ):Void
the character informs where he moved to (can be used for adjusting the text bubbles for example)
| characterID | (Number) |
| tileX | position on the map (column:Number) |
| tileY | position on the map (row:Number) |
public function characterDidNotAchieveDestinationTile( c: Character, destTile: Point ):Void
the character informes what point he wasn’t able to reach The Worlds checks why and generates an event //TODO -- right now the cause for this situation is another character, but can be extended to include furniture
| c | (Character) |
| destTile | (Point) Point(tileX, tileY) |
public function onRollOverCharacter( c: Character ):Void
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable)
| c | (Character) |
public function onRollOutCharacter( c: Character ):Void
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable)
| c | (Character) |
public function onClickCharacter( c: Character ):Void
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable)
| c | (Character) |
public function getRollOveredCharacter():Character
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true Character.selectable == true;
| c | (Character) |
public function netCharacterSay( netID: String, text: String, params: Object ):Void
text message received from another character
| netID | of character (Character),received from the server |
| text | (String) |
| params | (Object) -- not used yet |
public function characterSay( characterID: Number, text: String, params: Object ):Void
shows a character text message
| characterID | -- gets it when the World attaces a character (Character) |
| text | (String) |
| params | (Object) -- not used yet |
private function generateObjectName( oType: Number, ID: Number ):String
generates names for tile, furniture, characters
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
| ID | (Number) |
public function removeCharacter( characterID: Number ):Void
removes a character (Character)
| characterID | (Number) |
public function removeCharacterByNetID( netID: String ):Void
removes network characters (Character)
| netID | (String) |
private function removeObject( oType: Number, objectID: Number ):Void
removes an object
| oType | -- types (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
| objectID | (Number) |
public function removeAllFurniture():Void
Removes all the furniture (Furniture)
public function removeAllCharacters():Void
Removes all the characters (Character)
public function getTileElevation( tileX: Number, tileY: Number, includeFurniture: Boolean ): Number
calculates the tile elevation (the sum of the whole floor tiles stack elevation)
| tileX | -- position on the map (column:Number) |
| tileY | -- position on the map (row:Number) |
| includeFurniture | (Boolean), by default is false |
Number
public function __getTileMapLocation( x: Number, y: Number, elevationEnabled: Boolean, furnitureElevationEnabled: Boolean ):Point
find the tile row/column on the map -- tileX, tileY by a coordinate
| x | -- an integer (Number) that sets the x coordinate |
| y | -- an integer (Number) that sets the y coordinate |
| elevationEnabled | (Boolean) |
| furnitureElevationEnabled | (Boolean) |
Point(col, row)
public function getNextTile( tileX: Number, tileY: Number, dir: Number ): Point
returns next tile coordinates to any direction. tileX = point.x; tileY = point.y;
| tileX | -- position on the map (column:Number) |
| tileY | -- position on the map (row:Number) |
| dir | -- derection (Number) |
Point(col, row)
public function isWalkableTile( tileX: Number, tileY: Number, ignoreCharacter: Boolean ):Boolean
check if the tile is walkable and returns the cause if its not the codes for non--walkable tiles are defined in Constants
| tileX | -- position on the map (column:Number) |
| tileY | -- position on the map (row:Number) |
| ignoreCharacter | (Boolean) |
Boolean
public function getCharactersOnTile( tileX: Number, tileY: Number ):Array
a situation when two characters are on the same tile is possible. This method is used to get the array of the characters located on the same tile
| tileX | -- position on the map (column:Number) |
| tileY | -- position on the map (row:Number) |
array of characters (Character) (can be empty)
private function getNextZOrder( tileX: Number, tileY: Number, oType: Number ): Number
calculates next available z--order for each object on a given tile tileX, tileY should be >0 and <=map width/height
| tileX | -- position on the map (column:Number) |
| tileY | -- position on the map (row:Number) |
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
Number
private function getStackElZOrder( tileX: Number, tileY: Number, oType: Number, stackOrder: Number ): Number
calculates the zorder of the element by it’s tile and position in the stack a -- the array (aCharacter, aFurniture or aFloor)
| tileX | -- position on the map (column:Number) |
| tileY | -- position on the map (row:Number) |
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
| stackOrder | (Number) |
Number
private function getObjectBaseZOrder( objectType: Number ): Number
gets the base z--order
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
Number
private function getObjectMaxZOrder( objectType: Number ): Number
gets the maximum z--order
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
Number
private function removeObjectFromStack( tileX: Number, tileY: Number, objectType: Number, stackOrder: Number ):Number
removes the map object (character/furniture/floor) from the tile stack array simple Array.splice() shifts the items above the splice element down, closing the “gap” from the removed object their z--order has to be updated to be in sync with the stack order
| tileX | -- position on the map (column:Number) |
| tileY | -- position on the map (row:Number) |
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
| stackOrder | -- the link to the stack array inside -- aCharacter[x][y], aFurniture[x][y], or aFloor[x][y] |
Number
private function getObjectStackOrder( ID: Number, objectType: Number ): Number
returns the the 3rd index of aCharacters array -- his number in the “stack” of characters on the same tile
| ID | (Number) |
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
Number
private function getMapObjectByID( ID: Number, objectType: Number ): MapObject
gets the movieclip of a map object
| ID | (Number) |
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
public function getObjectArray( objectType: Number ): Array
returns aCharacters for CHARACTER_OBJECT and so on... public -- because it’s accessed from WorldLogic
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
Array
public function getContainerMC( objectType: Number ): MovieClip
returns the container movieclip for particular Map Object
| oType | -- the object type: (Constants.CHARACTER_OBJECT, Constants.FURNITURE_OBJECT, Constants.FLOOR_OBJECT) |
Number
public function set iCharacter( c: Character ):Void
sets the main character OPT needs to be removed from here?
| c | (Character) |
public function getTileActionName( x, y ):String
returns the NAME of the action, that is saved in the BASE tile (depends on the actions that are assigned to the furniture on that tile) this method is needed for a better performance -- a name is enough in most cases otherwise we would need to use the heavy method World.getTileAction
action name (String)
var addEventListener: Function
var removeEventListener: Function
var dispatchEvent: Function
private var _onEnterFrameBeaconForCursor: MovieClip
private var _highestFloorTileElevation: Number
the name of th map.
private var _mapName: String
link the class (WorldLogic) that processes the user UI events (mouse, keyboard) can be extended to add more functionality (generation ond processing on World actions)
private var _worldLogic: WorldLogic
world/map/room size X = columns(:Number)
private var _sizeX: Number
world/map/room size Y = rows(:Number)
private var _sizeY: Number
scrollable world/map/room area(:Number) (the sub--area of the big map that fits on the the screen) defined in rows/cols.
private var _scrollY: Number
scrollable world/map/room area(:Number) (the sub--area of the big map that fits on the the screen) defined in rows/cols.
private var _scrollX: Number
the number(:Number) of pixels left till the edge of the map when the auto--scrolling starts.
private var _scrollBuffer: Number
tile size (width(:Number) ).
private var _tileWidth: Number
tile size (height(:Number) ).
private var _tileHeight: Number
public var halfTileWidth: Number
public var halfTileHeight: Number
private var _tileDiagonal: Number
the main movieclip(:MovieClip), inside which the World is created
private var _worldMC: MovieClip
mask movieclip(:MovieClip) (it’s existence and parametters are set in the World constructor) the movie that may contains the mask for the map, to hide parts of it (that are bigger than the visible area)
private var _maskMC: MovieClip
the top container MC(:MovieClip) that contains everything
private var _containerMC: MovieClip
map background(:MovieClip)
private var _backgroundMC: MovieClip
mc(:MovieClip) containing all the floor tiles
private var _floorMC: MovieClip
public var debugLayerMC: MovieClip
movieclip (:MovieClip)for the cursor (World._cursorMC) changing its depth we can use it for different purposes (for example now it points only on the floor, but is covered by characters and furniture)
private var _mouseMC: MovieClip
cursor movieclip(:MovieClip).
private var _cursorMC: MovieClip
the main mc(:MovieClip) containing furniture(:Furniture) and characters(:Character)
private var _contentMC: MovieClip
private var _furnitureCursorMC: MovieClip
contains the chat bubbles (:TextBubble)
private var _chatMC: MovieClip
map foreground (:MovieClip)
private var _foregroundMC: MovieClip
the array that stores the ORDER in which the furniture is added to the map when its created (the Map Editor generates this order.
private var _furnitureStandingOrderList: Array
the array that contains the floor tiles _aFloor[n][m] = Tile (Tile)
private var _aFloor: Array
the array that contains the furniture _aFurniture[n][m] = Furniture (Furniture)
private var _aFurniture: Array
the array that contains the characters _aCharacters[n][m] = Characters (Character)
private var _aCharacters: Array
tracks the objects IDs used for Worlds initialization, for generating the names of the movieclips
private var _lastObjectID: Array
character list for a quick reference (instead of looping the whole aCharacters 3D array) OPT define List object with lookup and other functions
private var _charactersList: Array
a flag -- not used yet
private var _charactersAreSelectable: Boolean
link to the Character.
private var _rollOveredCharacter: Character
the reference to “I” (main) character
private var _iCharacter: Character
top left corner of the map (the ground level)
private var _worldOrigin: Point
class--controller of the text bubbles
private var _tbController: TextBubbleController
a z--order value calculated on initialization for speed
private var MAX_ROW_ZORDER: Number
the width of the scroll area.
private var _scrollWidth: Number
the height of the scroll area.
private var _scrollHeight: Number
maximum scroll value in X
private var _maxScrollX: Number
maximum scroll value in Y
private var _maxScrollY: Number
public function World( target: MovieClip, sizeX: Number, sizeY: Number, tHeight: Number, tWidth: Number, mapBGImage: Object, mapFGImage: Object, aFloor: Array, aFurniture: Array, aCharacters: Array, origin: Point, scrollX: Number, scrollY: Number, scrollBuffer: Number, masking: Boolean, maskMinX: Number, maskMinY: Number, maskMaxX: Number, maskMaxY: Number )
initializes the World object
private function init( target: MovieClip, sizeX: Number, sizeY: Number, tileHeight: Number, tileWidth: Number, mapBGImage: Object, mapFGImage: Object, aFloor: Array, aFurniture: Array, aCharacters: Array, origin: Point, scrollX: Number, scrollY: Number, scrollBuffer: Number, masking: Boolean, maskMinX: Number, maskMinY: Number, maskMaxX: Number, maskMaxY: Number ):Void
Mask map -- can be used hide the area of the map that is out of the scroll area
private function maskMap( minX: Number, minY: Number, maxX: Number, maxY: Number ):Void
true if the click was on the mask and false otherwise (or if the mask is not present)
public function maskHitTest():Boolean
loops the aFloor array and adds all the tiles to the map
private function initAllTiles( a: Array ):Void
puts a floor tile on the map If ts:TileSettings contains links to the Library ( see the Library method for more details ), then a MovieClip (MovieClip) and loads the image into it
private function addTile( tileX: Number , tileY: Number , ts: TileSettings ):Tile
removes a tile using its zorder since it’s unique and doesn’t change (tileID = _zorder) note that the Characters use characterID, because their zorder always changes (they move)
private function removeTile( tileID: Number ):Void
loops the aFurniture array and adds all the furniture objects to the map
private function initAllFurniture( a: Array ):Void
adds furniture objects to the map
public function addFurniture( tileX: Number, tileY: Number, fs: FurnitureSettings ): Furniture
function furnitureConfigurationAnalyser( configuration: String, registrationTile: String, destTile: Point ):Array
private function getRegistrationPoint( configuration: Array ):Point
furniture with _selectable == true calls this function directly and passes a link to itself as its parametter World uses it to detect ABOVE which exact tile is locate the clicked part of the furniture and passes this information to the WorldLogic (WorldLogic), where the actions to that event are decided
public function onClickFurniture( f: Furniture ):Void
loops the aCharacters array and adds all the charracters objects to the map
private function initAllCharacters( a: Array ):Void
adds a character to the map
public function addCharacter( tileX: Number, tileY: Number, cs: CharacterSettings ): Character
var testCount: Number
called fromTheoChat (optimize it?)
public function netCharacterCorrection( cs: CharacterSettings, cause: MapObjectSettings ):Void
instantly places an existing character on a tile (Tile) (and removes from a previous one)
public function placeCharacter( characterID: Number, tileX: Number, tileY: Number, dir: Number, phase: Number, action: String, actionParams: Object ):Void
* used in TheoChat * tells the character to move to a tile * this method uses overloading * if tileX, tileY is send -- move to that tile * if direction is sent -- move to that direction * call moveCharacter(ID, tileX, tileY) * or moveCharacter(ID, null, null, direction) * @param netID (String) -- network ID of the character(Character) * @param tileX position on the map (column:Number) * @param tileY position on the map (row:Number) * @param dir reduntant?
public function moveNetCharacter( netID: String, tileX: Number, tileY: Number, dir: Number, nonStop: Boolean, latency: Number ):Void
makes a character move
public function moveCharacter( characterID: Number, tileX: Number, tileY: Number, dir: Number, nonStop: Boolean, latency: Number ):Void
not used right now.
public function changeCharacterState( cs: CharacterSettings ):Void
public function sendMoveToServer( c: Character ):Void
the character informs where he moved to (can be used for adjusting the text bubbles for example)
public function characterOnMoved( characterID: Number, tileX: Number, tileY: Number ):Void
the character informes what point he wasn’t able to reach The Worlds checks why and generates an event //TODO -- right now the cause for this situation is another character, but can be extended to include furniture
public function characterDidNotAchieveDestinationTile( c: Character, destTile: Point ):Void
checks if the two tiles are next to each other
public function tilesAreNeighbors( t1: Point, t2: Point ):Boolean
stops the character
public function stopCharacter( c: Character ):Void
executes actions like sit, dance...
public function doCharacterAction( characterID: Number, action: String, params: Object ):Void
not used anymore since the WorldLogic decides things like that.
public function isValidAction( characterID: Number, action: Number, params: Object ):Boolean
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable)
public function onRollOverCharacter( c: Character ):Void
checks if the furniture is selectable (Character._selectable)
public function get selectable():Boolean
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable)
public function onRollOutCharacter( c: Character ):Void
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true (World._charactersAreSelectable) Character.selectable == true (Character.selectable)
public function onClickCharacter( c: Character ):Void
called by the Character, if (will be implemented in the next release) _charactersAreSelectable == true Character.selectable == true;
public function getRollOveredCharacter():Character
usually those parametters coincide with the mask parametters, or the area defined in the GUI
private function setBordersForTextBubbleController( x: Number, y: Number, width: Number, height: Number ):Void
text message received from another character
public function netCharacterSay( netID: String, text: String, params: Object ):Void
shows a character text message
public function characterSay( characterID: Number, text: String, params: Object ):Void
generates names for tile, furniture, characters
private function generateObjectName( oType: Number, ID: Number ):String
removes a character (Character)
public function removeCharacter( characterID: Number ):Void
removes network characters (Character)
public function removeCharacterByNetID( netID: String ):Void
removes an object
private function removeObject( oType: Number, objectID: Number ):Void
Removes all the furniture (Furniture)
public function removeAllFurniture():Void
Removes all the characters (Character)
public function removeAllCharacters():Void
scrolls the map
public function scrollMap( shiftX: Number, shiftY: Number, autoAdjust: Boolean ):Void
calculates the width of a floor area
public static function getAreaWidth( cols: Number ): Number
calculates the height of a floor area
public static function getAreaHeight( rows: Number ): Number
the ammount of scroll applied to the world/map in pixels
public function get mapScrollX():Number
the container position (Number) (movieclip containing the World objects -- floor(Tile), furniture(Furniture), characters(Character))
public function get mapScrollY():Number
centers the map around a given tile
public function centerMap( tileX : Number, tileY: Number ):Void
finds out in the point is too close to the enge -- within “scroll buffer’ zone x, y -- absolute position on the map is inside the left scroll buffer zone
public function isInLeftHorizontalScrollArea( x: Number ): Boolean
finds out in the point is too close to the enge -- within “scroll buffer’ zone x, y -- absolute position on the map is inside the left scroll buffer zone
public function isInRightHorizontalScrollArea( x: Number ): Boolean
finds out in the point is too close to the enge -- within “scroll buffer’ zone x, y -- absolute position on the map is inside the left scroll buffer zone
public function isInHorizontalScrollArea( x: Number ): Boolean
the same as in isInHorizontalScrollArea
public function isInTopVerticalScrollArea( y: Number ): Boolean
the same as in isInHorizontalScrollArea
public function isInBottomVerticalScrollArea( y: Number ): Boolean
the same as in isInHorizontalScrollArea
public function isInVerticalScrollArea( y: Number ): Boolean
the same as in isInHorizontalScrollArea, but for all the directions
public function isInScrollArea( x: Number, y: Number ): Boolean
find the tile x:y coorinates -- tile.location tileX, tileY are counted from 1, not from 0
public function getTileCoordinates( tileX: Number, tileY: Number ): Point
calculates the tile elevation (the sum of the whole floor tiles stack elevation)
public function getTileElevation( tileX: Number, tileY: Number, includeFurniture: Boolean ): Number
// TODO used to place a character on a random tile -- has to be optimized
public function getRandomWalkableTile( preferableDir: Number ):Point
public function _getTileMapLocation( x: Number, y: Number, elevationEnabled: Boolean, furnitureElevationEnabled: Boolean ):Point
public function getTileMapLocation( x: Number, y: Number, elevationEnabled: Boolean, furnitureElevationEnabled: Boolean ):Point
find the tile row/column on the map -- tileX, tileY by a coordinate
public function __getTileMapLocation( x: Number, y: Number, elevationEnabled: Boolean, furnitureElevationEnabled: Boolean ):Point
returns the nearest walkable tile
public function getNearestWalkableTile( tileX: Number, tileY: Number ):Point
return nearest walkable tile tile without any furniture on it
public function getNearestEmptyTile( tileX: Number, tileY: Number ):Point
returns next tile coordinates to any direction.
public function getNextTile( tileX: Number, tileY: Number, dir: Number ): Point
check if the tile is walkable and returns the cause if its not the codes for non--walkable tiles are defined in Constants
public function isWalkableTile( tileX: Number, tileY: Number, ignoreCharacter: Boolean ):Boolean
a situation when two characters are on the same tile is possible.
public function getCharactersOnTile( tileX: Number, tileY: Number ):Array
checks if it’s a valid tile coordinate (within a map, etc).
public function isValidTile( tileX: Number, tileY: Number ): Boolean
shows the mouse cursor depending on mouse events
private function showCursor():Void
calculates next available z--order for each object on a given tile tileX, tileY should be >0 and <=map width/height
private function getNextZOrder( tileX: Number, tileY: Number, oType: Number ): Number
calculates the zorder of the element by it’s tile and position in the stack a -- the array (aCharacter, aFurniture or aFloor)
private function getStackElZOrder( tileX: Number, tileY: Number, oType: Number, stackOrder: Number ): Number
gets the base z--order
private function getObjectBaseZOrder( objectType: Number ): Number
gets the maximum z--order
private function getObjectMaxZOrder( objectType: Number ): Number
removes the map object (character/furniture/floor) from the tile stack array simple Array.splice() shifts the items above the splice element down, closing the “gap” from the removed object their z--order has to be updated to be in sync with the stack order
private function removeObjectFromStack( tileX: Number, tileY: Number, objectType: Number, stackOrder: Number ):Number
returns the the 3rd index of aCharacters array -- his number in the “stack” of characters on the same tile
private function getObjectStackOrder( ID: Number, objectType: Number ): Number
gets the movieclip of a map object
private function getMapObjectByID( ID: Number, objectType: Number ): MapObject
returns aCharacters for CHARACTER_OBJECT and so on...
public function getObjectArray( objectType: Number ): Array
returns the container movieclip for particular Map Object
public function getContainerMC( objectType: Number ): MovieClip
clears the World
public function clear():Void
return the main (“I”) character
public function get iCharacter(): Character
getting local _xmouse coordinates
public function get mouseX():Number
getting local _ymouse
public function get mouseY():Number
getting tile width
public function get tileWidth(): Number
getting tile height
public function get tileHeight(): Number
public function set worldLogic( w: WorldLogic ):Void
sets the flag so the character can be selectable (not implemented yet)
public function set charactersAreSelectable( b: Boolean ):Void
returns the flag value (Boolean)
public function get isMasked():Boolean
returns the NAME of the action, that is saved in the BASE tile (depends on the actions that are assigned to the furniture on that tile) this method is needed for a better performance -- a name is enough in most cases otherwise we would need to use the heavy method World.getTileAction
public function getTileActionName( x, y ):String
retuns the copy action (Object).
public function getTileAction( x, y ):Object
public function getCharactersList():Array
public static function get EVENT_CHARACTER_MOVE():String
public static function get EVENT_CHARACTER_STOP():String
public static function get EVENT_CHARACTER_CHANGE_SETTINGS():String
public static function get EVENT_CHARACTER_DESTINATION_CORRECTION():String
public static function get EVENT_CHARACTER_ARRIVED_TELEPORT():String
public static function get EVENT_CHARACTER_IS_CLICKED():String
public function onRollOverFurniture( f: Furniture ):Void
public function onRollOutFurniture( f: Furniture ):Void
public function traceMapArrays():Void
// TODO
private function fillTilesArea( initObj: TileSettings, startRow: Number, startCol: Number, endRow: Number, endCol: Number ):Void
NOT WORKING
private function getTileMC( tileX: Number, tileY: Number ): Tile
NOT WORKING
private function drawDebugGrid():Void
static function get CHARACTER_OBJECT():Number
static function get FURNITURE_OBJECT():Number
static function get FLOOR_OBJECT():Number