Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function IsCommandSetFinished() : Bool
- {
- var allDone : Bool = true; // assuming all commands are done
- for ( command in this.commandSet )
- {
- for ( enemy in this.enemyGroup )
- {
- if ( command.eid == enemy.ID )
- {
- if ( enemy.commandDone )
- enemy.commandDone = false;
- else
- {
- allDone = false;
- break;
- }
- }
- }
- if ( !allDone )
- break;
- }
- return( allDone );
- }
- public function ExecuteDropCommand( enemy : Enemy, command : GameGrid.Command )
- {
- // the drop command will only drop one space
- var targetX =
- ( command.x * this.charWidth ) +
- this.dropbox.x + enemy.offset.x;
- var targetY =
- ( ( command.y + 1 ) * this.charHeight ) +
- this.dropbox.y;
- enemy.boxTween = FlxTween.tween
- (
- enemy,
- {
- x : targetX,
- y : targetY
- },
- .20,
- {
- complete :
- function tweenDone( tween : FlxTween )
- {
- enemy.boxTween = null;
- enemy.commandDone = true;
- },
- ease : FlxEase.elasticInOut
- }
- );
- }
- public function ProcessCommands()
- {
- // make sure the command set is empty first
- // otherwise it will just pull off nothing and
- // only the first command is executed
- if( this.commandSet.length <= 0 )
- this.commandSet = this.gameGrid.PullCommandSet();
- // we want to exit early so check it again
- if ( this.commandSet.length <= 0 )
- return;
- for ( enemy in this.enemyGroup )
- {
- // boxTween should only be the dropping animations
- if ( enemy.boxTween == null )
- {
- var i : Int = 0;
- while( i < this.commandSet.length )
- {
- // Do we have a command and the correct enemy id?
- var command = this.commandSet[ i ];
- if ( command != null && enemy.ID == command.eid )
- {
- if ( command.name == "drop" )
- ExecuteDropCommand( enemy, command );
- else
- if ( command.name == "kill" )
- {
- enemy.hypnoMode = DYING;
- enemy.commandDone = true;
- }
- } // end if command
- i++;
- } // end while commands
- if( IsCommandSetFinished() )
- this.commandSet.splice( 0, this.commandSet.length ); // empty it
- } // end if not tweening
- } // end enemy loop
- } // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement