public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState ) { if ( Owner.IsAlive && control is Projectile && !( control is IronRocket ) && Vector2.DistanceSquared( control.Position, Owner.Position ) <= Math.Pow( Radius, 2 ) && Tools.IsGoingTowardsMe( Owner.Position, control.Angle, control.Position ) ) { Projectile cont = ( Projectile )control; if ( ( !cont.Variables.ContainsKey( "IronRockets" ) || !( ( HashSet<Tank> )cont.Variables[ "IronRockets" ] ).Contains( Owner ) ) ) { if ( rand.Next( 100 ) < probability ) { IronRocket rocket = new IronRocket( IronLifeTime, IronSpeed, cont, Owner.Position, Owner.Angle ); rocket.Initialize( Game, gameTime, Owner ); rocket.LoadContent( Game.Content, Game.ScreenWidth, Game.ScreenHeight ); Game.QueueEntity( rocket ); launch.Play(); } if ( !cont.Variables.ContainsKey( "IronRockets" ) ) { cont.Variables[ "IronRockets" ] = new HashSet<Tank>(); } ( ( HashSet<Tank> )cont.Variables[ "IronRockets" ] ).Add( Owner ); } } return base.Control( control, gameTime, keyState ); }
public override Projectile Clone() { IronRocket clone = new IronRocket( lifeTime, Speed, Homer, Position, Angle ); return clone; }