com.theoworlds.builder.CharacterLogic |
CharacterLogic class - stores the character logic. This is a base class that is extended by other CharacterLogic classes that implement different logics
1.0
© TheoWorlds.com, 2007-2009.
| com. | CharacterLogic class - stores the character logic. |
| Variables | |
| _intThinking | for setInterval -- thinkingLoop |
| _intMoving | for setInterval -- moving |
| _character | link to the Character |
| _destinationTile | the destination tile coordinates (where the characters moves to) |
| _intermediateTile | the current tile -- the one the character is stepping on now |
| _minLatency | for dead--reconing -- the minimum lag value (between the client and the server), that can be ignored |
| _latency | the lag value (between the client and the server) |
| _smoothStep | dead reconing corrects the movement of the character to compensate for the lag during the _maxSmoothSteps step. |
| _maxSmoothSteps | the maximum number of steps used for dead reconing correction. |
| _forkD | “Fork” direction. |
| _prevTile | remember previous walked tile |
| _maxSteps | number of steps the character will try to go around before giving up |
| _aSteps | counts the steps till _maxSteps |
| _libSpeed | stores the character speed from the Library TODO -- add the method set libSpeed, because many actions are supported now and we will need to run them with different speed as well. |
| Functions and Properties | |
| CharacterLogic | |
| startThinking | add the call to the thinkingLoop in the children function |
| stopThinking | stops the character “thinking” (the brain -- character logic). |
| stopMoving | stops the path finding algorithm to be called on mouse clicks |
| thinkingLoop | this function keeps running, emulating the thinking process. |
| clear | clear assets |
| moving | the method called by setInterval -- calls the path finding function |
| moveToTile | moves a character to the given tile |
| showShortestPath | DEBUG |
| getNextDirectionProcessing | path finding function. |
| CHARACTER_THINKING_SPEED | left from v1 -- not used right now |
| isMovingToTile | detects if the character is moving somewhere after a mouse click |
| getDestinationTile | coordinates ( Point(col, row) ) of the tile that the character moves to |
private var _character: Character
link to the Character
private var _libSpeed: Number
stores the character speed from the Library TODO -- add the method set libSpeed, because many actions are supported now and we will need to run them with different speed as well. So we will need to call the path finding algorithm with a different frequency (it is synhronized with the character movement)
public function CharacterLogic( character: Character, autoStart: Boolean, initObj: Object )
| character | (Character) |
| autoStart | |
| initObj |
private function getNextDirectionProcessing( ignoreCharacterCollision: Boolean ):Number
path finding function. It’s called in a loop by CharacterLogic.moving()
| ignoreCharacterCollision | , by default is false; |
the direction of the next step (1--8). 0 -- means “stop”.
for setInterval -- thinkingLoop
private var _intThinking: Number
for setInterval -- moving
private var _intMoving: Number
link to the Character
private var _character: Character
the destination tile coordinates (where the characters moves to)
private var _destinationTile: Point
the current tile -- the one the character is stepping on now
private var _intermediateTile: Point
for dead--reconing -- the minimum lag value (between the client and the server), that can be ignored
private var _minLatency: Number
the lag value (between the client and the server)
private var _latency: Number
dead reconing corrects the movement of the character to compensate for the lag during the _maxSmoothSteps step.
private var _smoothStep: Number
the maximum number of steps used for dead reconing correction.
private var _maxSmoothSteps: Number
“Fork” direction.
private var _forkD: Boolean
remember previous walked tile
private var _prevTile: Point
number of steps the character will try to go around before giving up
private var _maxSteps: Number
counts the steps till _maxSteps
private var _aSteps: Number
stores the character speed from the Library TODO -- add the method set libSpeed, because many actions are supported now and we will need to run them with different speed as well.
private var _libSpeed: Number
public function CharacterLogic( character: Character, autoStart: Boolean, initObj: Object )
add the call to the thinkingLoop in the children function
public function startThinking():Void
stops the character “thinking” (the brain -- character logic).
public function stopThinking():Void
stops the path finding algorithm to be called on mouse clicks
public function stopMoving():Void
this function keeps running, emulating the thinking process.
private function thinkingLoop():Void
clear assets
public function clear():Void
the method called by setInterval -- calls the path finding function
private function moving():Void
moves a character to the given tile
public function moveToTile( tileX: Number, tileY: Number, latency: Number ):Void
DEBUG
private function showShortestPath( ignoreCharacterCollision: Boolean ):Void
path finding function.
private function getNextDirectionProcessing( ignoreCharacterCollision: Boolean ):Number
left from v1 -- not used right now
static function get CHARACTER_THINKING_SPEED():Number
detects if the character is moving somewhere after a mouse click
public function isMovingToTile():Boolean
coordinates ( Point(col, row) ) of the tile that the character moves to
public function getDestinationTile():Point