public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState ) { if ( !control.Variables.ContainsKey( "VacuumSpeed" ) ) { control.Variables[ "VacuumSpeed" ] = baseSpeed; } float vacSpeed = ( float )control.Variables[ "VacuumSpeed" ]; float d = Vector2.Distance( Owner.Position, control.Position ); if ( d * 2 <= Owner.GameWidth + Owner.GameHeight ) { control.Variables.Remove( "VacuumSpeed" ); control.ForceDestroy(); } else { control.Move( vacSpeed, Tools.Angle( control, Owner ) ); if ( spiral ) { control.Move( vacSpeed + 10, Tools.Angle( control, Owner ) + 90 ); } } if ( vacSpeed < maxSpeed ) { vacSpeed += acceleration; } else { vacSpeed = maxSpeed; } control.Variables[ "VacuumSpeed" ] = vacSpeed; if ( t != null ) { Tank ta = ( Tank )Owner; if ( !Game.HasController( this ) ) { destroyTime += 1; if ( destroyTime > 1000 ) { ta.RemoveTankController(); } } } return true; }
public override bool Control( GameEntity control, TimeSpan gameTime, KeyboardState keyState ) { if ( !control.Variables.ContainsKey( "VacuumSpeed" ) ) { control.Variables[ "VacuumSpeed" ] = baseSpeed; } float vacSpeed = ( float )control.Variables[ "VacuumSpeed" ]; // The current pull speed float d = Vector2.Distance( Position, control.Position ); // The current distance if ( d <= 16 * Scale ) // if the distance is smaller than that value, the entity is inside the black hole and therefore should be destroyed. { // Destroy control.Variables.Remove( "VacuumSpeed" ); control.ForceDestroy(); } else // Else the control is outside so do the orbit { control.Move( vacSpeed, Tools.Angle( control.Position, Position ) ); // The pull control.Move( vacSpeed + spiralFactor, Tools.Angle( control.Position, Position ) + 90 ); // The turn } // Accelerate the pull speed vacSpeed += acceleration; if ( vacSpeed > maxSpeed && maxSpeed >= 0 ) { // Limit the pull speed from the top vacSpeed = maxSpeed; } if ( vacSpeed < minSpeed && minSpeed >= 0 ) { // Limit the pull speed from the bottom vacSpeed = minSpeed; } control.Variables[ "VacuumSpeed" ] = vacSpeed; return true; }