public GamePlayer(int taille_image_x, int taille_image_y, int nb_frameLine, int nb__framecolumn, int frame_start, int animation_speed, Vector2 position, int pv, Texture2D image, gamemain main) : base(taille_image_x, taille_image_y, nb_frameLine, nb__framecolumn, frame_start, animation_speed, position, image, main) { this.main = main; spriteFont = ressource.ecriture; position_pv.X = 300; position_pv.Y = 0; this.Direction = Direction.None; Endurance = 100; Mana = 100; Pv = 100; timer_endurance = 0; sort_selec = 1; active_sort = new sort(ressource.boule_de_feu, this); click_down = false; }
public GamePlayer(int taille_image_x, int taille_image_y, int nb_frameLine, int nb__framecolumn, int frame_start, int animation_speed, int speed, Vector2 position, Texture2D image, gamemain main, textbox text, bool language) : base(taille_image_x, taille_image_y, nb_frameLine, nb__framecolumn, frame_start, animation_speed, speed, position, image) { equipement = new item[4]; dash = false; invulnerable = false; precInvulnarable = false; timer_invulnarable = 600; timer_inv2 = 10; timer_dash = 2; langue = language; CanMove = 0; this.main = main; this.text = text; spriteFont = ressource.ecriture; position_pv.X = 300; position_pv.Y = 0; this.Direction = Direction.None; attaque = 10; defense = 10; magie = 10; Endurance = 100; Mana = 100; Pv = 100; timer_endurance = 0; sort_selec = 1; obj_selec = 1; active_sort = new sort(ressource.boule_de_feu, this); click_down = false; levelup = false; nb_amelioration = 0; inventaire = new item[5, 5]; nb_objet = new int[25]; HitBox = new Rectangle((int)position.X, (int)position.Y, 32, 32); in_action = false; text.Is_shown = false; speed_max = Speed; }
public override void update(MouseState mouse, KeyboardState keyboard, List<wall> walls, List<Personnage> personnages, switch_map map) { animaitonspeed = 5; if (invulnerable == true) timer_invulnarable--; if (invulnerable && timer_invulnarable % 60 == 0) affichage_invul = true; if (timer_invulnarable == 0) { timer_invulnarable = 600; invulnerable = false; timer_inv2 = 10; } if (timer_inv2 == 0 & invulnerable) { affichage_invul = false; timer_inv2 = 10; } if (dash == true) { timer_dash--; canwalk = false; Dash(map); } if (timer_dash == 0) { dash = false; timer_dash = 2; canwalk = true; } if (dash == false) { base.update(mouse, keyboard, walls, personnages, map); collision_bord(); CanMove++; deplacement(); action(map); HitBox = new Rectangle((int)position.X, (int)position.Y, 32, 32); #region sort & item if (keyboard.IsKeyDown(Keys.D1)) sort_selec = 1; if (keyboard.IsKeyDown(Keys.D2)) sort_selec = 2; if (keyboard.IsKeyDown(Keys.D3)) sort_selec = 3; if (keyboard.IsKeyDown(Keys.D4)) sort_selec = 4; if (Data.keyboardState.IsKeyDown(Keys.NumPad1)) obj_selec = 1; if (Data.keyboardState.IsKeyDown(Keys.NumPad2)) obj_selec = 2; if (Data.keyboardState.IsKeyDown(Keys.NumPad3)) obj_selec = 3; if (Data.keyboardState.IsKeyDown(Keys.NumPad4)) obj_selec = 4; if (Data.keyboardState.IsKeyDown(Keys.NumPad5)) obj_selec = 5; switch (sort_selec) { case 1: active_sort = new sort(ressource.boule_de_feu, this); active = "feu"; break; case 2: active_sort = new sort(ressource.glace, this); active = "glace"; break; } attaque_mana(keyboard); if (Data.keyboardState.IsKeyDown(Keys.LeftControl) && Data.prevKeyboardState.IsKeyUp(Keys.LeftControl)) if (this.nb_item(this.inventaire) != 0 && obj_selec - 1 < this.nb_item(this.inventaire)) { utilise_objet(inventaire[obj_selec - 1, 0]); inventaire[obj_selec - 1, 0] = null; } #endregion //si le tile ou se trouve le joueur est des troude pique alors il devient de piques ! if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32] == new Vector2(0, 2)) { map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32] = new Vector2(1, 2); Pv -= 15; ressource.pique.Play(); } else if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32] != new Vector2(0, 2) && map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32] != new Vector2(1, 2)) for (int i = 0; i < 25; i++) for (int j = 0; j < 18; j++) if (main.map.Active_Map.objet[i, j] == new Vector2(1, 2)) main.map.Active_Map.objet[i, j] = new Vector2(0, 2); #region endurance timer_endurance++; if (Data.keyboardState.IsKeyDown(Keys.LeftShift) && Data.prevKeyboardState.IsKeyDown(Keys.LeftShift) && Endurance > 50) { dash = true; Endurance -= 50; } if (keyboard.IsKeyUp(Keys.LeftShift) && timer_endurance >= 5 && Endurance < 100) { Endurance++; timer = 0; } if (Endurance <= 0) Endurance = 0; #endregion #region attaque if (Data.keyboardState.IsKeyDown(Keys.A) && Data.prevKeyboardState.IsKeyUp(Keys.A) && direction == Templar.Direction.None && !combat) combat = true; #endregion if (levelup == true) { nb_amelioration++; XP -= 100; mana_player = pv_player; Niveau++; levelup = false; } if (keyboard.IsKeyUp(Keys.Space)) click_down = false; } precInvulnarable = invulnerable; }
public override void update(MouseState mouse, KeyboardState keyboard, List<wall> walls, List<Personnage> personnages) { if (keyboard.IsKeyDown(Keys.LeftShift) && Endurance > 0) { animate(); Endurance--; Speed = 4; animaitonspeed = 5; } else { animate(); Speed = 2; animaitonspeed = 8; } timer_endurance++; if (position.X + 34 >= main.Fenetre.Width) position.X = main.Fenetre.Width - 34; if (position.X <= 0) position.X = 0; if (position.Y + 61 >= main.Fenetre.Height) position.Y = main.Fenetre.Height - 61; if (position.Y <= 0) position.Y = 0; //modifie la selection des sorts if (keyboard.IsKeyDown(Keys.D1)) { sort_selec = 1; } if (keyboard.IsKeyDown(Keys.D2)) { sort_selec = 2; } //lance le nouveau sort suivant la selection switch (sort_selec) { case 1: active_sort = new sort(ressource.boule_de_feu, this); active = "feu"; break; case 2: active_sort = new sort(ressource.glace, this); active = "glace"; break; } //verifie si le joueur peut courir //recharge l'endurance if (keyboard.IsKeyUp(Keys.LeftShift) && timer_endurance >= 5 && Endurance < 100) { Endurance++; timer = 0; } //ces deux test marche aps specialement bien A MODIFIER if (Endurance <= 0) Endurance = 0; if (Pv <= 0) Pv = 0; if (pv_player >= 100) pv_player = 100; //change la direction du player if (keyboard.IsKeyDown(Keys.Z)) direction = Direction.Up; if (keyboard.IsKeyDown(Keys.S)) direction = Direction.Down; if (keyboard.IsKeyDown(Keys.D)) direction = Direction.Right; if (keyboard.IsKeyDown(Keys.Q)) direction = Direction.Left; if (keyboard.IsKeyUp(Keys.Z) && keyboard.IsKeyUp(Keys.S) && keyboard.IsKeyUp(Keys.Q) && keyboard.IsKeyUp(Keys.D)) direction = Direction.None; //evite de trop cliquer if (keyboard.IsKeyUp(Keys.Space)) click_down = false; //diminue le mana a chaque sort lancer if (keyboard.IsKeyDown(Keys.Space) && Mana >= 0 && click_down == false) { Mana -= 10; click_down = true; } base.update(mouse, keyboard, walls, personnages); }