public override void Initialize(Animation animation, Vector2 position, float vyska) { ani_enemyAnimation = animation; v2_enemyPosition = position; b_enemyActive = true; i_enemyHealth = 1; // indestructible }
public void Initialize(Animation animation, Vector2 position) { ani_exploAnimation = animation; v2_exploPosition = position; b_exploActive = true; i_timeToLive = 30; }
// What happens at the beginning public void Initialize(Animation animation, Vector2 position, float movspeed) { ani_playerAnimation = animation; v2_playerPosition = position; b_playerActive = true; i_playerHealth = 100; f_playerSpeed = movspeed; }
public override void Initialize(Animation animation, Vector2 position, float f_windowHeight) { ani_enemyAnimation = animation; v2_enemyPosition = position; b_enemyActive = true; i_enemyHealth = 300; f_enemyTDMoveSpeedY = 2f; f_enemyTDLowBound = f_windowHeight - 30 - Height/2; f_enemyTDUpBound = Height + 20; }
public virtual void Initialize(Animation animation, Vector2 position, float placeholder) { ani_enemyAnimation = animation; v2_enemyPosition = position; b_enemyActive = true; i_enemyHealth = 50; // random previous shot, this is to make the first enemies not shoot at the same time Random rnd = new Random((int)v2_enemyPosition.Y); TS_prevShot = TimeSpan.FromMilliseconds(rnd.Next(-5000, -1000)); }
// Updated initialization with more random factors public override void Initialize(Animation animation, Vector2 position,float vyska) { ani_enemyAnimation = animation; v2_enemyPosition = position; b_enemyActive = true; i_enemyHealth = 50; Random rand = new Random(); f_enemyTDLowBound = rand.Next((int)vyska*2 / 3, (int)vyska - 140); f_enemyTDUpBound = rand.Next(30, (int)vyska / 3); Random rnd = new Random((int)v2_enemyPosition.Y); TS_prevShot = TimeSpan.FromMilliseconds(rnd.Next(-5000, -2000)); }
public void Initialize(Animation animation, Vector2 position) { ani_laserAnimation = animation; v2_laserPosition = position; b_laserActive = true; }
// Enemies' methods // Spawns a enemy of a type given by the number 'whichEnemy' private void AddEnemy(int whichEnemy) { // Instance Enemy enemy; int loc_width, loc_height, loc_frameCount, loc_frameTime, loc_X, loc_Y; // local variables, for easier animation initialize // Where do enemies spawn by default loc_X = GraphicsDevice.Viewport.Width + t2dar_enemies[whichEnemy].Width / 2; loc_Y = random.Next(100, GraphicsDevice.Viewport.Height - 140); // Setting the enemies' specific information switch (whichEnemy) { case 0: enemy = new Enemy(); loc_width = 47; loc_height = 61; loc_frameCount = 8; loc_frameTime = 30; break; case 1: enemy = new TopDownEnemy(); loc_width = 47; loc_height = 61; loc_frameCount = 8; loc_frameTime = 30; break; case 2: enemy = new BuildingEnemy(); loc_width = 175; loc_height = 140; loc_frameCount = 1; loc_frameTime = 500; loc_Y = GraphicsDevice.Viewport.Height - t2dar_enemies[whichEnemy].Height/2; break; case 3: enemy = new BossEnemy(); loc_width = 239; loc_height = 161; loc_frameCount = 1; loc_frameTime = 500; loc_Y = (GraphicsDevice.Viewport.Height + t2dar_enemies[whichEnemy].Height) / 2; break; default: // redundant, it's here just because C# wants it enemy = new Enemy(); loc_width = 0; loc_height = 0; loc_frameCount = 0; loc_frameTime = 0; Console.WriteLine("ERROR AT SWITCH IN AddEnemy(whichenemy)"); break; } // Create enemy animation Animation enemyAnimation = new Animation(); enemyAnimation.Initialize(t2dar_enemies[whichEnemy], Vector2.Zero, loc_width, loc_height, loc_frameCount, loc_frameTime, Color.White, 1f, true); Vector2 position = new Vector2(loc_X, loc_Y); // Initiate the enemy enemy.Initialize(enemyAnimation, position, GraphicsDevice.Viewport.Height); // Remember the enemy list_enemies.Add(enemy); }
// (Un)Loads content into the Game protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2); Animation playerAnimation = new Animation(); t2d_mainbg = Content.Load<Texture2D>("bg2"); Texture2D t2d_playerTexture = Content.Load<Texture2D>("shipAnimation"); t2dar_enemies = new Texture2D[NUMBER_OF_ENEMY_TYPES]; t2dar_enemies[0] = Content.Load<Texture2D>("EnemyAnimation"); t2dar_enemies[1] = Content.Load<Texture2D>("EnemyAnimation2"); t2dar_enemies[2] = Content.Load<Texture2D>("Budova2"); t2dar_enemies[3] = Content.Load<Texture2D>("boss"); t2d_laserTexture = Content.Load<Texture2D>("laser"); t2d_enemyLaserTexture = Content.Load<Texture2D>("Enemylaser"); t2d_exploTexture = Content.Load<Texture2D>("explosion"); font_smallCalibri = Content.Load<SpriteFont>("smallfont"); font_bigCalibri = Content.Load<SpriteFont>("bigfont"); playerAnimation.Initialize(t2d_playerTexture, Vector2.Zero, 115, 69, 8, 50, Color.White, 1f, true); player.Initialize(playerAnimation, playerPosition, 7.5f); }
// Handles the spawn of the laser and adding it to the active lasers lists protected void AddLaser(IFlier flier, float shotDirection) { // declaration of locals variables Texture2D loc_texture; Vector2 loc_flierPosition; Vector2 loc_laserPostion; Laser laser; // we set the laser position to the position of the flier loc_flierPosition = flier.GetPosition(); loc_laserPostion = loc_flierPosition; // each flier has it's offset to make the laser come out of the gun Vector2 loc_laserFlier = flier.GetGunOffset(); loc_laserPostion += loc_laserFlier; // we adjust the laser position with the offset // we spawn the laser, standard laser for the player // boss-specific is handled in the FireLaser(), a bit of player tracking for the enemies if ((flier is Player)) { loc_texture = t2d_laserTexture; laser = new Laser(); } else if ((flier is BossEnemy)) { loc_texture = t2d_enemyLaserTexture; laser = new EnemyLaser(shotDirection); } else if ((flier is Enemy)) { loc_texture = t2d_enemyLaserTexture; // Enemies track the player's position and adjust aim very slightly float a = 0f; if (player.v2_playerPosition.Y < loc_flierPosition.Y) { a = -2f; } else if (player.v2_playerPosition.Y > loc_flierPosition.Y) { a = 2f; } laser = new EnemyLaser(a); } else { // DEFAULT because C# knows what is good better than us :-) loc_texture = t2d_laserTexture; laser = new Laser(); } Animation laserAnimation = new Animation(); // initlize the laser animation laserAnimation.Initialize(loc_texture, loc_flierPosition, 46, 16, 1, 30, Color.White, 1f, true); // init the laser laser.Initialize(laserAnimation, loc_laserPostion); // add the laser to the proper list if(laser is EnemyLaser) { list_enemiesLasers.Add(laser); } else { list_lasers.Add(laser); } }
// Explosions' methods // Spawns the explosion and initializes protected void AddExplosion(Vector2 enemyPosition) { Animation explosionAnimation = new Animation(); explosionAnimation.Initialize(t2d_exploTexture, enemyPosition, 134, 134, 12, 30, Color.White, 1.0f, true); Explosion explosion = new Explosion(); explosion.Initialize(explosionAnimation, enemyPosition); list_explos.Add(explosion); }