public Bullet( Player p_player, ContentManager p_Manager ) { if( s_Sprite == null ) { s_Sprite = p_Manager.Load<Texture2D>( "Bullet" ); } Visable = true; m_Owner = p_player; m_Position = new Vector2( m_Owner.Position.X + ( m_Owner.Position.Width / 2 ), m_Owner.Position.Y ); }
public Game1() { graphics = new GraphicsDeviceManager( this ); Content.RootDirectory = "Content"; CurrentState = GameStates.Loading; #if GameComponents m_Player = null; m_Bullets = new Collection<Bullet>(); m_Asteroids = new Collection<Asteroid>(); this.Components.ComponentAdded += new EventHandler<GameComponentCollectionEventArgs>( ComponentAdded ); this.Components.ComponentRemoved += new EventHandler<GameComponentCollectionEventArgs>( ComponentRemoved ); #endif }
void ComponentAdded( object sender, GameComponentCollectionEventArgs e ) { if( e.GameComponent is Player ) { if( m_Player != null ) { m_Player.Dispose(); } m_Bullets.Clear(); m_Asteroids.Clear(); m_Player = e.GameComponent as Player; } else if( e.GameComponent is Bullet ) { #if Audio Pew.Play(); #endif m_Bullets.Add( e.GameComponent as Bullet ); } else if( e.GameComponent is Xbox360IndieGameDesign.Asteroid ) { m_Asteroids.Add( e.GameComponent as Xbox360IndieGameDesign.Asteroid ); } }
public Bullet( Game p_game, Player p_player ) : base(p_game) { m_Owner = p_player; m_Position = new Vector2( m_Owner.Position.X + ( m_Owner.Position.Width / 2 ), m_Owner.Position.Y ); }