public Shot(Shot copy_shot) { m_image = copy_shot.m_image; m_pos = copy_shot.m_pos; m_angle = copy_shot.m_angle; m_speed = copy_shot.m_speed; m_textureData = copy_shot.m_textureData; m_image.GetData(m_textureData); m_center = copy_shot.m_center; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); LoadGameLevel(1); // TODO: use this.Content to load your game content here sound_explosion = this.Content.Load<SoundEffect>("sound_explosion"); sound_laser = this.Content.Load<SoundEffect>("sound_laser"); song = this.Content.Load<Song>("theme_v2"); gameOverFont = this.Content.Load<SpriteFont>("GameOverFont"); scoreFont = this.Content.Load<SpriteFont>("ScoreFont"); Texture2D player_tex = this.Content.Load<Texture2D>("fighter"); Texture2D energyShot_tex = this.Content.Load<Texture2D>("energy_shot"); Texture2D fighter_sil_tex = this.Content.Load<Texture2D>("fighter_silhouette"); //create HUD Element playerLife1 = new Element(fighter_sil_tex, (5 * GameValues.Instance.SCALEX), 5); Element playerLife2 = new Element(fighter_sil_tex, playerLife1.m_pos.X + fighter_sil_tex.Width + (5 * GameValues.Instance.SCALEX), 5); Element playerLife3 = new Element(fighter_sil_tex, playerLife2.m_pos.X + fighter_sil_tex.Width + (5 * GameValues.Instance.SCALEX), 5); PlayerLifes.Add(playerLife1); PlayerLifes.Add(playerLife2); PlayerLifes.Add(playerLife3); //create player elements Shot playerShot = new Shot(energyShot_tex, 0, 30); InitPlayerWeapons(playerShot); Player = new Player(player_tex, PlayerWeapons, WIDTH / 4, HEIGHT / 2); //star field List<Texture2D> starField_textures = new List<Texture2D>(); starField_textures.Add(Content.Load<Texture2D>("star_dot")); starField = new StarField(starField_textures, new Vector2(500, 300), SCALE); MediaPlayer.Play(song); }
public ShotPattern PopulateShotPattern(ShotPattern pattern, Texture2D image) { XmlDocument xml = new XmlDocument(); xml.Load("D:\\VS 2010 Projects\\Shooter\\Shooter\\ShooterContent\\ShotPatterns\\" + pattern.m_id + ".xml"); XmlNode root = xml.FirstChild; XmlNode child; XmlAttributeCollection attributes; Shot nextShot; int numShots = 0; int angle = 0; if (root == null) { return null; } attributes = root.Attributes; try { numShots = Convert.ToInt32(attributes.GetNamedItem("numShots").Value); } catch (FormatException e) { Console.WriteLine("ShotPattern numShots: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("ShotPattern numShots: The number cannot fit in an Int32."); } if (root.HasChildNodes) { for (int j = 0; j < root.ChildNodes.Count; j++) { child = root.ChildNodes[j]; attributes = child.Attributes; try { angle = Convert.ToInt32(attributes.GetNamedItem("angle").Value); } catch (FormatException e) { Console.WriteLine("ShotPattern angle: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("ShotPattern angle: The number cannot fit in an Int32."); } nextShot = new Shot(image, angle, pattern.m_speed); GameValues.Instance.EnemyWeapons.Add(nextShot); pattern.AddShot(nextShot); } } return pattern; }
public void InitPlayerWeapons(Shot energy_shot) { int i = 0; while (i < 5) //HARD CODED!!!! { PlayerWeapons.Add(new Shot(energy_shot)); i++; } }
public void AddShot(Shot s) { m_shots.Add(s); }