public override void Initialize( TanksDrop game ) { Helpers = new List<LazerHelper>(); lastHelper = new LazerHelper( Position, Angle, game, owner ); hasCollided = false; Tanks = null; //lifeTime = 2000; base.Initialize( game ); }
public override void Update( TimeSpan gameTime, HashSet<GameEntity> Entities, Microsoft.Xna.Framework.Input.KeyboardState keyState ) { if ( Tanks == null ) { Tanks = from e in Entities where e is Tank select e; } for ( int i = 0; i < Speed; i++ ) { if ( ( Helpers.Count >= Trail || hasCollided ) && Helpers.Count > 0 ) { try { Helpers.RemoveAt( 0 ); } catch ( Exception ) { } } if ( Helpers.Count <= 2 && hasCollided ) { Helpers = new List<LazerHelper>(); lastHelper.Destroy( gameTime ); } if ( !hasCollided ) { foreach ( GameEntity e in Tanks ) { if ( e.CollidesWith( lastHelper ) && ( ( Tank )e ).IsAlive ) { if ( ( ( Tank )e ).ProjectileHit( lastHelper, gameTime ) ) { hasCollided = true; break; } } } if ( lastHelper.Destroyed ) { hasCollided = true; break; } LazerHelper nextHelper = ( LazerHelper )lastHelper.Clone(); Helpers.Add( lastHelper ); nextHelper.Move( Entities ); Game.RemoveEntity( lastHelper ); lastHelper = nextHelper; Game.QueueEntity( lastHelper ); } } base.Update( gameTime, Entities, keyState ); }