public static Enemy Enemy2() { Enemy character = new Enemy (GameResources.Characters["Enemy2"], "Black"); character.Weapon = null; character.Team = 11; return character; }
private void AddEnemy() { Animation enemyAnimation = new Animation(); enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true); Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100)); Enemy enemy = new Enemy(); enemy.Initialize(enemyAnimation, position); enemies.Add(enemy); }
public void RemoveEnemy(Enemy e) { m_enemies.Remove(e); }
public void AddEnemy(Enemy e) { m_enemies.Add(e); }
private void AddEnemy() { // Randomly generate the position of the enemy Vector2 position = new Vector2(random.Next(0, GraphicsDevice.Viewport.Width), -10); // Create an enemy Enemy enemy = new Enemy(); // Initialize the enemy enemy.Initialize(enemyTexture, position); // Add the enemy to the active enemies list enemies.Add(enemy); }
private void AddEnemy() { // Create the animation object Animation enemyAnimation = new Animation(); // Initialize the animation with the correct animation information enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true); // Randomly generate the position of the enemy Vector2 position = new Vector2(ScreenManager.GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, ScreenManager.GraphicsDevice.Viewport.Height - 100)); // Create an enemy Enemy enemy = new Enemy(); // Initialize the enemy enemy.Initialize(enemyAnimation, position); // Add the enemy to the active enemies list enemies.Add(enemy); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState keys = Keyboard.GetState(); if(startScreenIsOn == true) { if (keys.IsKeyDown(Keys.Enter)) { startScreenIsOn = false; LoadContent(); } } if(endScreenIsOn == true) { if (keys.IsKeyDown(Keys.Escape)) { Initialize(); } } if (startScreenIsOn == false && endScreenIsOn == false) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // Save the previous state of the keyboard and game pad so we can determinesingle key/button presses // previousGamePadState = currentGamePadState; previousKeyboardState = currentKeyboardState; // Read the current state of the keyboard and gamepad and store it currentKeyboardState = Keyboard.GetState(); //currentGamePadState = GamePad.GetState(PlayerIndex.One); UpgradeObject upgradeObject2 = new UpgradeObject(); Enemy enemy2 = new Enemy(); Projectile projectile2 = new Projectile(); UpdateUpgradeSprite(gameTime); //Update the player UpdatePlayer(gameTime); // Update the parallaxing background bgLayer1.Update(); //bgLayer2.Update(); // Update the enemies UpdateEnemies(gameTime); if (score >= metScore) { levelChange(); } UpdateCollision(); // Update the projectiles UpdateProjectiles(); UpdateUpgradeObjects(gameTime); // Update the explosions UpdateExplosions(gameTime); base.Update(gameTime); } }
private void AddEnemy() { // Create the animation object Animation enemyAnimation = new Animation(); // Initialize the animation with the correct animation information enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30,Color.White, 1f, true); // Randomly generate the position of the enemy Vector2 position = new Vector2(GraphicsDevice.Viewport.Width +enemyTexture.Width / 2, random.Next(50, GraphicsDevice.Viewport.Height -50)); // 50, and -50 represent the area in which they spawn (higher the number the smaller the area, closer to center) // Create an enemy Enemy enemy = new Enemy(); // Initialize the enemy enemy.Initialize(enemyAnimation, position); // Condition to see if the level changed then make my enemies harder /* if (level != prevLevel) { levelUp = true; } */ /* if (levelUp == true) { enemy.Damage = enemy.Damage + 20; enemy.Health = enemy.Health + 20; enemy.enemyMoveSpeed = enemy.enemyMoveSpeed + 2; enemy.Value = enemy.Value + 20; //UpdatePlayer(blah); // figure out parameter shit because I need to change player class attributes before leaving if statement :) AddProjectile(position); levelUp = false; } */ // Add the enemy to the active enemies list enemies.Add(enemy); }
private void LoadGameLevel(int level) { XmlDocument xml = new XmlDocument(); xml.Load("D:\\VS 2010 Projects\\Shooter\\Shooter\\ShooterContent\\Levels\\" + level.ToString() + ".xml"); XmlNode root = xml.FirstChild; XmlNode waveNode; XmlNode formationNode; XmlNode enemyNode; XmlAttributeCollection attributes; Level = new Level(); //level contains list of waves Wave nextWave; //wave contains list of formations Formation nextFormation; //formation contains list of enemies Enemy nextEnemy; //enemies will die horrible deaths AttackPattern nextAttackPattern; //attackPattern defines enemy movement between start and end positions ShotPattern nextShotPattern; //defines enemy bullets per shot and how those bullets move Texture2D shotImage; //duh float waveDuration = 0; float formationTrigger = 0; string attackPatternID = ""; //name identifier for AttackPattern string shotPatternID = ""; //name identifier for ShotPattern string enemyType = ""; //tells which texture will be drawn for enemy string enemyShot = ""; //tells which texture will be drawn for enemy shot float enemyHealth = 0; //duh float startX = 0; //Start and End positions the enemy ship will use float startY = 0; float endX = 0; float endY = 0; int fireCount = 0; //number of times the enemy will fire it's shotPattern float fireRate = 0; //how frequently the enemy will fire another shotPattern int shotSpeed = 0; //how fast each shot will move List<ShotPattern> shotPatterns; //list of shotPatterns that will be passed to enemy int count = 0; //counter for adding ShotPatterns if (root.HasChildNodes) { for (int i = 0; i < root.ChildNodes.Count; i++) //waves { waveNode = root.ChildNodes[i]; attributes = waveNode.Attributes; waveDuration = Convert.ToSingle(attributes.GetNamedItem("d").Value); nextWave = new Wave(waveDuration); //Create new wave if (waveNode.HasChildNodes) { for (int j = 0; j < waveNode.ChildNodes.Count; j++) //formations { formationNode = waveNode.ChildNodes[j]; attributes = formationNode.Attributes; formationTrigger = Convert.ToSingle(attributes.GetNamedItem("d").Value); nextFormation = new Formation(formationTrigger); if (formationNode.HasChildNodes) { for (int k = 0; k < formationNode.ChildNodes.Count; k++) //enemies { enemyNode = formationNode.ChildNodes[k]; attributes = enemyNode.Attributes; enemyType = attributes.GetNamedItem("type").Value; enemyShot = attributes.GetNamedItem("shot").Value; try { enemyHealth = Convert.ToInt32(attributes.GetNamedItem("health").Value); } catch (FormatException e) { Console.WriteLine("Enemy Health: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Health: The number cannot fit in an Int32."); } try { startX = Convert.ToInt32(attributes.GetNamedItem("startX").Value); } catch (FormatException e) { Console.WriteLine("Enemy Starting X: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Starting X: The number cannot fit in an Int32."); } try { startY = Convert.ToInt32(attributes.GetNamedItem("startY").Value); } catch (FormatException e) { Console.WriteLine("Enemy Starting Y: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Starting Y: The number cannot fit in an Int32."); } try { endX = Convert.ToInt32(attributes.GetNamedItem("endX").Value); } catch (FormatException e) { Console.WriteLine("Enemy Starting X: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Starting X: The number cannot fit in an Int32."); } try { endY = Convert.ToInt32(attributes.GetNamedItem("endY").Value); } catch (FormatException e) { Console.WriteLine("Enemy Starting Y: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Starting Y: The number cannot fit in an Int32."); } try { shotSpeed = Convert.ToInt32(attributes.GetNamedItem("shotSpeed").Value); } catch (FormatException e) { Console.WriteLine("Enemy Shot Speed: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Shot Speed: The number cannot fit in an Int32."); } try { fireCount = Convert.ToInt32(attributes.GetNamedItem("fireCount").Value); } catch (FormatException e) { Console.WriteLine("Enemy Shot Freqency: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Shot Freqency: The number cannot fit in an Int32."); } try { fireRate = Convert.ToSingle(attributes.GetNamedItem("fireRate").Value); } catch (FormatException e) { Console.WriteLine("Enemy Shot Freqency: Input string is not a sequence of digits."); } catch (OverflowException e) { Console.WriteLine("Enemy Shot Freqency: The number cannot fit in a float."); } //enemy attack pattern nextAttackPattern = new AttackPattern(); attackPatternID = attributes.GetNamedItem("ap").Value; nextAttackPattern.SetID(attackPatternID); nextAttackPattern.SetEndPosition(endX, endY); nextAttackPattern.SetStartPosition(startX, startY); if ((nextAttackPattern = PopulateAttackPattern(nextAttackPattern)) == null) //Load AttackPattern moveList { Console.WriteLine("Failed to load attack pattern " + attackPatternID.ToString()); } //enemy shot pattern shotPatternID = attributes.GetNamedItem("sp").Value; shotPatterns = new List<ShotPattern>(); //only one shotPattern List per enemy, so new outside while loop count = 0; while (count < fireCount) { nextShotPattern = new ShotPattern(shotPatternID, shotSpeed); //we potentially want multiple ShotPattern objects per enemy, so new in while loop shotImage = this.Content.Load<Texture2D>(enemyShot); //Create the appropriate number of shotPatterns for the enemy if ((nextShotPattern = PopulateShotPattern(nextShotPattern, shotImage)) == null) //populate ShotPattern's shotList { Console.WriteLine("Failed to load shot pattern " + shotPatternID.ToString()); } shotPatterns.Add(nextShotPattern); count++; } //ContentManager should only load textures if they aren't already cached nextEnemy = new Enemy(this.Content.Load<Texture2D>(enemyType), Convert.ToInt32(enemyHealth), nextAttackPattern, shotPatterns, fireCount, fireRate); LevelEnemies.Add(nextEnemy); nextFormation.AddEnemy(nextEnemy); } nextWave.AddFormation(nextFormation); } else { Console.WriteLine("Empty formation found"); } } Level.AddWave(nextWave); } else { Console.WriteLine("Empty wave found"); } } } else { Console.WriteLine("root node: no children found"); } }
public override void intersectEnemy(Enemy e) { World.remove(e); World.add(new DamageEffect(World, e.X, e.Y, 2)); }
// ��������� ������ private void AddEnemy() { // ��������� ��'���� ������� Animation enemyAnimation = new Animation(); // ����������� ������� ������ enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true); // ��������� ��������� ������� ������ Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100)); // ��������� ��'���� ����� Enemy enemy = new Enemy(); // ����������� ������ enemy.Initialize(enemyAnimation, position, enemyHealth, enemyMoveSpeed); // ��������� ������ �� ������ ��������, � ����� ������, ������ enemies.Add(enemy); }
public virtual void intersectEnemy(Enemy e) { }
private void RdnDropEnemy() { try { while (isGameStarted) { lock (locker) { Enemy e = new Enemy(player); int x = rnd.Next(GamePanel.Size.Width - e.Sprite.Width); int y = rnd.Next(GamePanel.Size.Height - e.Sprite.Height); e.Sprite.Location = new Point(x, y); e.MissileFiredEvent += new Enemy.MissileFiredDelegate(AddMissile); this.BeginInvoke(new ManageDisplayItem(AddGameObject), e); } Thread.Sleep(spawnDelay); } } catch (Exception e) { Debug.WriteLine(e); } }