/// <summary> /// Fonction qui gère l'attaque à distance du singe /// </summary> public void Shoot_monkey(GameTime gameTime) { Bullet newBullet_monkey = new Bullet(Content.Load<Texture2D>("sprite_projectile_monkey")); timeShoot += (float)gameTime.ElapsedGameTime.TotalSeconds; if (timeShoot > 1f) { if (hero.position.X > singe.position.X) { isMirror2 = false; newBullet_monkey.velocity = new Vector2(1, 0) * buff.SPEEDBULLET + singe.velocity; newBullet_monkey.position.X = (singe.position.X) + 25; newBullet_monkey.position.Y = singe.position.Y; } if (hero.position.X < singe.position.X) { isMirror2 = true; newBullet_monkey.velocity = new Vector2(-1, 0) * buff.SPEEDBULLET + singe.velocity; newBullet_monkey.position.X = (singe.position.X) + 25; newBullet_monkey.position.Y = singe.position.Y; } newBullet_monkey.isVisible = true; if (bullets_monkey.Count() < 20) { bullets_monkey.Add(newBullet_monkey); } timeShoot = 0f; } }
/// <summary> /// Fonction qui gère l'attaque à distance du héro /// </summary> public void Shoot() { Bullet newBullet = new Bullet(Content.Load<Texture2D>("bullet")); if (hero.b == 1) { newBullet.velocity = new Vector2(0, 1) * buff.SPEEDBULLET + hero.velocity; newBullet.position.X = hero.position.X + 25 + hero.velocity.X; newBullet.position.Y = hero.position.Y + hero.velocity.Y; } else if (hero.h == 1) { newBullet.velocity = new Vector2(0, -1) * buff.SPEEDBULLET + hero.velocity; newBullet.position.X = hero.position.X + 25 + hero.velocity.X; newBullet.position.Y = hero.position.Y + hero.velocity.Y; } else if (hero.d == 1) { newBullet.velocity = new Vector2(1, 0) * buff.SPEEDBULLET + hero.velocity; newBullet.position.X = hero.position.X + 25 + hero.velocity.X; newBullet.position.Y = hero.position.Y + hero.velocity.Y; } else if (hero.g == 1) { newBullet.velocity = new Vector2(-1, 0) * buff.SPEEDBULLET + hero.velocity; newBullet.position.X = hero.position.X + 25 + hero.velocity.X; newBullet.position.Y = hero.position.Y + hero.velocity.Y; } newBullet.isVisible = true; _bulletSound.Play(volumeSoundEffect, 0.0f, 0.0f); if (bullets.Count() < buff.MAXBULLET) bullets.Add(newBullet); // 20 projectiles max sur l'écran }