//UPDATE & DRAW public void Update(GameTime gameTime, List <Player> liste_joueurs, List <IA> liste_ia, List <DestructibleItems> liste_barrel, List <ParticuleExplosion> liste_explosion, List <ParticuleExplosion> liste_explosion2, List <ParticuleExplosion> liste_blood, List <Turret> liste_turret) { // Do not update the game if we are not active if (Active == false) { return; } // Update the elapsed time elapsedTime += (int)gameTime.ElapsedGameTime.TotalMilliseconds; // If the elapsed time is larger than the frame time // we need to switch frames if (elapsedTime > frameTime) { // Move to the next frame currentFrame++; // If the currentFrame is equal to frameCount reset currentFrame to zero if (currentFrame == frameCount) { currentFrame = 0; // If we are not looping deactivate the animation if (Looping == false) { Active = false; } } // Reset the elapsed time to zero elapsedTime = 0; } // Grab the correct frame in the image strip by multiplying the currentFrame index by the frame width sourceRect = new Rectangle(currentFrame * FrameWidth, 0, FrameWidth, FrameHeight); // Grab the correct frame in the image strip by multiplying the currentFrame index by the frame width destinationRect = new Rectangle((int)Position.X - (int)(FrameWidth * scale) / 2, (int)Position.Y - (int)(FrameHeight * scale) / 2, (int)(FrameWidth * scale), (int)(FrameHeight * scale)); //Player ou IA et Barrel dans la zone d'explosion = DEAD foreach (Player joueur in liste_joueurs) { if ((joueur.PlayerTexture.Intersects(this.Aire_explosionBomb)) && type == "explosion") { joueur.Health -= 100; } } foreach (IA ia in liste_ia) { if ((ia.IATexture.Intersects(this.Aire_explosionBomb)) && type == "explosion") { if (ia.id_texture != 6) { ia.Health -= 100; } else { ia.Health -= 1; } } } foreach (DestructibleItems barrel in liste_barrel) { if ((barrel.BarrelTexture.Intersects(this.Aire_explosionBomb)) && type == "explosion") { barrel.isVisible = false; ParticuleExplosion explosion = new ParticuleExplosion(); explosion.Initialize(Ressources.ExplosionParticule, new Vector2(barrel.Aire_barrel.X + 8, barrel.Aire_barrel.Y + 8), 134, 134, 12, 45, Color.White, 1f, false, barrel.Aire_barrel.X - 16, barrel.Aire_barrel.Y - 16, 48, "explosion"); liste_explosion2.Add(explosion); } } foreach (Turret turret in liste_turret) { if (turret.turretTexture.Intersects(this.Aire_explosionBomb)) { turret.munition = 0; turret.isActive = false; } } }
public void AddExplosion(Vector2 position, int x, int y, int largeur) { ParticuleExplosion explosion = new ParticuleExplosion(); explosion.Initialize(Ressources.ExplosionParticule, position, 134, 134, 12, 45, Color.White, 1f, false, x, y, largeur, "explosion"); liste_explosions.Add(explosion); }
//UPDATE & DRAW public void Update(GameTime gameTime, List<Player> liste_joueurs, List<IA> liste_ia, List<DestructibleItems> liste_barrel, List<ParticuleExplosion> liste_explosion, List<ParticuleExplosion> liste_explosion2, List<ParticuleExplosion> liste_blood) { // Do not update the game if we are not active if (Active == false) return; // Update the elapsed time elapsedTime += (int)gameTime.ElapsedGameTime.TotalMilliseconds; // If the elapsed time is larger than the frame time // we need to switch frames if (elapsedTime > frameTime) { // Move to the next frame currentFrame++; // If the currentFrame is equal to frameCount reset currentFrame to zero if (currentFrame == frameCount) { currentFrame = 0; // If we are not looping deactivate the animation if (Looping == false) Active = false; } // Reset the elapsed time to zero elapsedTime = 0; } // Grab the correct frame in the image strip by multiplying the currentFrame index by the frame width sourceRect = new Rectangle(currentFrame * FrameWidth, 0, FrameWidth, FrameHeight); // Grab the correct frame in the image strip by multiplying the currentFrame index by the frame width destinationRect = new Rectangle((int)Position.X - (int)(FrameWidth * scale) / 2, (int)Position.Y - (int)(FrameHeight * scale) / 2, (int)(FrameWidth * scale), (int)(FrameHeight * scale)); //Player ou IA et Barrel dans la zone d'explosion = DEAD foreach (Player joueur in liste_joueurs) { if ((joueur.PlayerTexture.Intersects(this.Aire_explosionBomb)) && type == "explosion") { joueur.Health = 0; } } foreach (IA ia in liste_ia) { if ((ia.IATexture.Intersects(this.Aire_explosionBomb)) && type == "explosion") { ia.Health = 0; } } foreach (DestructibleItems barrel in liste_barrel) { if ((barrel.BarrelTexture.Intersects(this.Aire_explosionBomb)) && type == "explosion") { barrel.isVisible = false; ParticuleExplosion explosion = new ParticuleExplosion(); explosion.Initialize(Ressources.ExplosionParticule, new Vector2(barrel.Aire_barrel.X + 8, barrel.Aire_barrel.Y + 8), 134, 134, 12, 45, Color.White, 1f, false, barrel.Aire_barrel.X - 16, barrel.Aire_barrel.Y - 16, 48, "explosion"); liste_explosion2.Add(explosion); } } }
public void AddBloodEffect(Vector2 position, int x, int y, int largeur) { ParticuleExplosion blood = new ParticuleExplosion(); blood.Initialize(Ressources.BloodParticule, position, 150, 186, 12, 45, Color.White, 1f, false, x, y, largeur, "blood"); liste_blood.Add(blood); }