Example #1
0
 public Sauvegarde(switch_map map, GamePlayer player)
 {
     this.Mapi = map;
     this.Player = player;
     fichier = new FileStream(@"save/Save.txt", FileMode.OpenOrCreate,FileAccess.Write);
     stream = new BinaryWriter(fichier);
 }
Example #2
0
 public override void update(MouseState mouse, KeyboardState keyboard, List<wall> walls, List<Personnage> personnages, switch_map map)
 {
     count_deplacement++;
     canmove++;
     if (canmove > 15)
     {
         bob = rd.Next(0, 5);
         switch (bob)
         {
             case 0:
                 this.direction = Templar.Direction.None;
                 break;
             case 1:
                 this.direction = Templar.Direction.Up;
                 break;
             case 2:
                 this.direction = Templar.Direction.Down;
                 break;
             case 3:
                 this.direction = Templar.Direction.Left;
                 break;
             case 4:
                 this.direction = Templar.Direction.Right;
                 break;
         }
         canmove = 0;
     }
     base.update(mouse, keyboard, walls, personnages, map);
 }
 public Chargement(GamePlayer player, switch_map mapi)
 {
     this.Mapi = mapi;
     this.Player = player;
     fichier = new FileStream("Save.txt", FileMode.Open, FileAccess.Read);
     load = new BinaryReader(fichier);
     load.Close();
 }
Example #4
0
 public Chargement(GamePlayer player, switch_map mapi, Personnage pos, gamemain main)
 {
     this.Mapi = mapi;
     this.Main = main;
     this.Player = player;
     Position = pos;
     fichier = new FileStream(@"save/Save.txt", FileMode.Open, FileAccess.Read);
     load = new BinaryReader(fichier);
 }
Example #5
0
        public gamemain(Game game, SpriteBatch spriteBatch, GameScreen activescreen)
            : base(game, spriteBatch)
        {
            #region init du jeu

            x = new Random();

            liste_sort = new List<sort>();
            list_zombi = new List<NPC>();
            Walls = new List<wall>();
            personnage = new List<Personnage>();
            liste_objet_map = new List<potion>();

            position_joueur = new Vector2(100, 100);

            localPlayer = new GamePlayer(34, 61, 4, 5, 2, 8, position_joueur, 100, ressource.sprite_player, this);
            localPlayer.Niveau = 1;

            pop_time = 0;
            score = 0;
            count_dead_zombi = 0;

            keyboard = new KeyboardState();

            #endregion init du jeu

            map = new switch_map(localPlayer, this);

            fenetre = new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height); //taille de la fenetre

            HUD = new HUD(localPlayer, this);

            # region media_player;
            MediaPlayer.Play(ressource.main_theme);
            MediaPlayer.Volume = 0.56f;
            MediaPlayer.IsRepeating = true;
               // SoundEffect.MasterVolume = 0.6f;
            # endregion
        }
Example #6
0
File: NPC.cs Project: kylox/Templar
        public override void update(MouseState mouse, KeyboardState keyboard, List<wall> walls, List<Personnage> personnages, switch_map map)
        {
            chrono++;
            if (chrono > 15)
            {
                //Deleg = new Thread(cheminement);
                CanMove = true;
                chrono = 0;
                //Partie new A*
                if (OldPosition != player.Position)
                {
                    PlayerMoved = true;
                    OldPosition = player.Position;
                }
                if (PlayerMoved)
                {
                    PlayerMoved = false;
                    if (Deleg != null)
                    {
                        Deleg.Abort();
                        Deleg = new Thread(cheminement);
                        Deleg.Start();
                    }
                    else
                        Deleg.Start();

                }
                //Fin Partie new A*

            }

            switch (direction)
            {
                case Direction.Down:
                    if (new Rectangle(Taille_image_x, (int)position.Y + 32, 32, 32).Intersects(new Rectangle((int)player.Position.X, (int)player.Position.Y, 32, 32)))
                        combat = true;
                    else
                        combat = false;
                    break;
                case Direction.Up:
                    if (new Rectangle(Taille_image_x, (int)position.Y - 32, 32, 32).Intersects(new Rectangle((int)player.Position.X, (int)player.Position.Y, 32, 32)))
                        combat = true;
                    else
                        combat = false;
                    break;
                case Direction.Left:
                    if (new Rectangle(Taille_image_x - 32, (int)position.Y, 32, 32).Intersects(new Rectangle((int)player.Position.X, (int)player.Position.Y, 32, 32)))
                        combat = true;
                    else
                        combat = false;
                    break;
                case Direction.Right:
                    if (new Rectangle(Taille_image_x + 32, (int)position.Y, 32, 32).Intersects(new Rectangle((int)player.Position.X, (int)player.Position.Y, 32, 32)))
                        combat = true;
                    else
                        combat = false;
                    break;
            }

            base.update(mouse, keyboard, walls, personnages, map);
        }
Example #7
0
        //update & draw
        public virtual void update(MouseState mouse, KeyboardState keyboard,
            List<wall> walls, List<Personnage> personnages, switch_map map)
        {
            timer_speed++;
            Hitbox = new Rectangle((int)position.X, (int)position.Y, Taille_image_x, Taille_image_y);
            if (Direction == Direction.Up)
            {
                this.newHitbox = new Rectangle((int)this.position.X, ((int)this.position.Y + (32 - 10)) - this.Speed, 20, 10);
                if (collide(walls) == true && this.invulnerable == false)
                    Pv--;
                if (position.X % 32 == 0 && position.Y % 32 == 0)
                    if ((int)position.Y / 32 - 1 >= 0 && map.Active_Map.colision[(int)position.X / 32, (int)position.Y / 32 - 1] != 1)
                        canwalk = true;
                    else
                        canwalk = false;

                if (!collision && canwalk)
                {
                    timer_speed = 0;
                    this.position.Y -= Speed;
                }
                this.animate();
            }
            else if (Direction == Direction.Down)
            {
                this.newHitbox = new Rectangle((int)this.position.X, ((int)this.position.Y + (32 - 10)) + this.Speed, 20, 10);

                if (collide(walls) == true && this.invulnerable == false)
                    Pv--;
                if (position.X % 32 == 0 && position.Y % 32 == 0)
                    if ((int)position.Y / 32 + 1 < 18 && map.Active_Map.colision[(int)position.X / 32, (int)position.Y / 32 + 1] != 1)
                        canwalk = true;
                    else
                        canwalk = false;
                if (!collision && canwalk)
                {
                    timer_speed = 0;
                    this.position.Y += Speed;
                }
                this.animate();
            }
            else if (Direction == Direction.Right) // same
            {
                this.newHitbox = new Rectangle((int)this.position.X + this.Speed, ((int)this.position.Y + (32 - 10)), 20, 10);
                if (collide(walls) == true && this.invulnerable == false)
                    Pv--;
                if (position.X % 32 == 0 && position.Y % 32 == 0)
                        if (map.Active_Map.colision[(int)position.X / 32 + 1, (int)position.Y / 32] != 1)
                        canwalk = true;
                    else
                        canwalk = false;
                if (!collision && canwalk)
                {
                    timer_speed = 0;
                    this.position.X += Speed;
                }
                this.animate();
            }
            else if (Direction == Direction.Left) // same
            {
                this.newHitbox = new Rectangle((int)this.position.X - this.Speed, ((int)this.position.Y + (32 - 10)), 20, 10);
                if (collide(walls) == true && this.invulnerable == false)
                    Pv--;
                if (position.X % 32 == 0 && position.Y % 32 == 0)
                    if (position.X / 32 - 1 >= 0 && map.Active_Map.colision[(int)position.X / 32 - 1, (int)position.Y / 32] != 1)
                        canwalk = true;
                    else
                        canwalk = false;
                if (!collision && canwalk)
                {
                    timer_speed = 0;
                    this.position.X -= Speed;
                }
                this.animate();
            }
            if (combat == true)
                switch (FrameLine)
                {
                    case 4:
                        frameline = 6;
                        break;
                    case 1:
                        frameline = 5;
                        break;
                    case 3:
                        frameline = 7;
                        break;
                    case 2:
                        frameline = 8;
                        break;
                }
            else
            {
                switch (this.Direction)
                {
                    case Direction.Up:
                        this.FrameLine = 3;
                        break;

                    case Direction.Down:
                        this.FrameLine = 1;
                        break;

                    case Direction.Left:
                        this.FrameLine = 2;
                        break;

                    case Direction.Right:
                        this.FrameLine = 4;
                        break;
                }
                if (Direction == Direction.None) // si toute les touches sont relacher alors tu affiche le personnage a l'arret
                {
                    this.Framecolumn = Frame_start;
                    this.timer = 0;
                }
            }
        }
Example #8
0
        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;
        }
Example #9
0
 public void Dash(switch_map map)
 {
     switch (Direction)
     {
         case Templar.Direction.Up:
             if ((int)position.Y / 32 - 1 >= 0 && map.Active_Map.colision[(int)position.X / 32, (int)position.Y / 32 - 1] != 1)
                 position.Y -= 32;
             else
                 dash = false;
             break;
         case Templar.Direction.Down:
             if (map.Active_Map.colision[(int)position.X / 32 + 1, (int)position.Y / 32] != 1)
                 position.Y += 32;
             else
                 dash = false;
             break;
         case Templar.Direction.Left:
             if (position.X / 32 - 1 >= 0 && map.Active_Map.colision[(int)position.X / 32 - 1, (int)position.Y / 32] != 1)
                 position.X -= 32;
             else
                 dash = false;
             break;
         case Templar.Direction.Right:
             if (map.Active_Map.colision[(int)position.X / 32 + 1, (int)position.Y / 32] != 1)
                 position.X += 32;
             else
                 dash = false;
             break;
     }
 }
Example #10
0
        public void action(switch_map map)
        {
            XmlReader reader;

            reader = XmlReader.Create("Francais.xml");
            if (!langue)
            {
                reader = XmlReader.Create("English.xml");
            }
            string op1 = "", op2 = "";
            while (reader.Read())
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    reader.Read();
                    if (reader.Name == "bouquins")
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            reader.Read();
                            if (reader.NodeType == XmlNodeType.Text)
                                op1 = reader.Value.ToString();
                        }
                        reader.Read();
                    }
                    if (reader.Name == "tonneaux")
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            reader.Read();
                            if (reader.NodeType == XmlNodeType.Text)
                                op2 = reader.Value.ToString();
                        }
                        reader.Read();
                    }
                }
            if (Data.keyboardState.IsKeyDown(Keys.E) && Data.prevKeyboardState.IsKeyUp(Keys.E))
            {
                if (main.princess != null && position == main.princess.position)
                    main.victoire = true;
                switch (frameline)
                {
                    // en haut
                    case 3:

                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 - 1] == new Vector2(2, 2))
                        {
                            text.Is_shown = true;
                            text.Saisie = op1;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 - 1] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 - 1] == new Vector2(0, 0))
                        {
                            map.Active_Map.Coffres[(int)position.X / 32, (int)position.Y / 32 - 1].is_open = true;
                            Coffre_ouvert = map.Active_Map.Coffres[(int)position.X / 32, (int)position.Y / 32 - 1];
                            in_action = true;
                        }
                        break;
                    // en bas
                    case 1:
                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 + 1] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        break;
                    // a gauche
                    case 2:
                        if (map.Active_Map.objet[(int)position.X / 32 - 1, (int)position.Y / 32] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        break;
                    // a droite
                    case 4:
                        if (map.Active_Map.objet[(int)position.X / 32 - 1, (int)position.Y / 32] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        break;
                }
            }
        }
Example #11
0
        public gamemain(Game game, SpriteBatch spriteBatch, GameScreen activescreen, Donjon donjon, bool is2p, string ip, string name_donjon, bool language)
            : base(game, spriteBatch)
        {
            victoire = false;
            langue = language;
            nom_donjon = name_donjon;
            fenetre = new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height); //taille de la fenetre
            text = new textbox(new Rectangle(0, 18 * 32 + 7, 200, 100));
            text.Is_shown = false;
            #region init du jeu
            x = new Random();
            keyboard = new KeyboardState();
            liste_sort = new List<sort>();
            //ICI POUR LOADMOB
            //FIN ICI
            Walls = new List<wall>();
            personnage = new List<Personnage>();
            liste_objet_map = new List<potion>();
            if (is2p)
            {
                position_joueur = new Vector2(32, 32);
                localPlayer = new GamePlayer(32, 48, 4, 8, 2, 15, 2, position_joueur, ressource.sprite_player, this, text, language);
                localPlayer.Niveau = 1;
            }
            if (!is2p)
            {
                position_joueur = donjon.position_J;
                localPlayer = new GamePlayer(32, 48, 4, 8, 2, 15, 2, position_joueur, ressource.sprite_player, this, text, language);
                localPlayer.Niveau = 1;
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (donjon.Map[i, j] != null)
                            donjon.Map[i, j].load_mob(@"Donjons\" + @name_donjon + @"\Map" + donjon.Map[i, j].Nb + @"\creature" + @".txt", this);
                    }
                }
            }
            donj = donjon;

            if (!is2p)
            {

                map = new switch_map(localPlayer/*, this*/, donjon, name_donjon);
                map.x = (int)donjon.map.X;
                map.y = (int)donjon.map.Y;
                mapx = map.x;
                mapy = map.y;
                list_zombi = map.Active_Map.monstre;
                HUD = new HUD(localPlayer, this);
            }
            pop_time = 0;
            score = 0;
            count_dead_zombi = 0;
            #endregion init du jeu
            # region media_player;
            MediaPlayer.Play(ressource.main_theme);
            MediaPlayer.Volume = 0.56f;
            MediaPlayer.IsRepeating = true;
            # endregion
            noir.A = 200;
            noir.B = noir.G = noir.R = 0;
            white = Color.White;
            white.A = 120;
            effect = new BasicEffect(game.GraphicsDevice);
            same_map = true;
        }