예제 #1
0
        //fonction appelée a chaque fois que le héros se déplace
        //lance également le combat si on va sur une case contenant un ennemi
        public void MovePlayer(HeroConstructor hero)
        {
            MapCase currentCase = FindHero();
            MapCase droite      = FindCase(currentCase.GetX() + 1, currentCase.GetY());
            MapCase gauche      = FindCase(currentCase.GetX() - 1, currentCase.GetY());
            MapCase bas         = FindCase(currentCase.GetX(), currentCase.GetY() - 1);
            MapCase haut        = FindCase(currentCase.GetX(), currentCase.GetY() + 1);

            ConsoleKeyInfo direction = Console.ReadKey();

            if (direction.KeyChar == 'z' && haut.GetY() <= 14)
            {
                currentCase.SetHeroHere(false);
                haut.SetHeroHere(true);
            }
            else if (direction.KeyChar == 'd' && droite.GetX() <= 14)
            {
                currentCase.SetHeroHere(false);
                droite.SetHeroHere(true);
            }
            else if (direction.KeyChar == 's' && bas.GetY() >= 1)
            {
                currentCase.SetHeroHere(false);
                bas.SetHeroHere(true);
            }
            else if (direction.KeyChar == 'q' && gauche.GetX() >= 1)
            {
                currentCase.SetHeroHere(false);
                gauche.SetHeroHere(true);
            }
        }
예제 #2
0
        //création de la map
        public void CreateMap()
        {
            int[,] grid = new int[abs, ord];
            for (int z = 0; z < ord; z++)
            {
                for (int x = 0; x < abs; x++)
                {
                    int     y     = ord - z - 1;
                    MapCase point = new MapCase(x, y);
                    if (((x >= 1 && x <= 9) && (y >= 11 && y <= 14)) || ((x >= 1 && x <= 7) && y == 10) || (x == 10 && (y == 14 || y == 13)))
                    {
                        point.SetTerrain("foret");
                    }
                    else if (((x >= 11 && x <= 14) && (y >= 9 && y <= 14)) || (x == 10 && (y <= 12 && y >= 10)))
                    {
                        point.SetTerrain("montagne");
                    }
                    else if (((x >= 10 && x <= 14) && (y >= 1 && y <= 3)) || (x == 9 && (y == 1 || y == 2)) || (y == 4 && (x == 12 || x == 13 || x == 14)))
                    {
                        point.SetTerrain("ruine");
                    }
                    else if (((x >= 1 && x <= 5) && (y >= 5 && y <= 9)) || (x == 6 && (y == 7 || y == 8)) || (y == 4 && (x >= 1 && x <= 4)) || (y == 3 && (x == 1 || x == 2)))
                    {
                        point.SetTerrain("plaine");
                    }
                    else if (((x >= 1 && x <= 8) && (y >= 1 && y <= 2)) || (y == 3 && (x >= 3 && x <= 9)) || (y == 4 && (x == 5 || x == 6)))
                    {
                        point.SetTerrain("mer");
                    }
                    else
                    {
                        point.SetTerrain("desert");
                    }

                    cases.Add(point);
                }
            }
        }
예제 #3
0
파일: Game.cs 프로젝트: thomas-NC/RPG_repo
        public void NewFrame()
        {
            MapCase currentCase = map.FindHero();

            if (currentCase.enemyHere != null)
            {
                Console.Clear();
                Console.WriteLine("\nCOMBAT!!!");
                Console.WriteLine("vs " + currentCase.enemyHere.GetName());
                bool result = Fight(hero, currentCase.enemyHere);
                if (result == true)
                {
                    if (map.FindHero().GetTerrain() == "plaine")
                    {
                        map.SpawnBoss("plaine", 4, 9, boss[0], 1);
                    }
                    else if (map.FindHero().GetTerrain() == "foret")
                    {
                        map.SpawnBoss("foret", 4, 12, boss[1], 1);
                    }
                    currentCase.enemyHere     = null;
                    currentCase.defeatedEnemy = true;
                }
                else if (result == false)
                {
                    Console.Clear();
                    Console.WriteLine("vous etes mort...");
                    hero.SetHp(100);
                }
            }
            else if (currentCase.chestHere == true)
            {
                Console.Clear();
                Chest chest = new Chest("coffre");
                Console.WriteLine("Vous avez trouvé un coffre!!!");
                Console.WriteLine("Voici son contenu: ");

                string content = chest.SetContent();
                chest.ShowContent();
                Console.ReadLine();
                if (content == "weapon")
                {
                    hero.inventory.weaponList.Add(chest.weapon[0]);
                    hero.SetAtt(hero.GetAtt() + chest.weapon[0].statAtt);
                    hero.SetDef(hero.GetDef() + chest.weapon[0].statDef);
                    hero.SetHp(hero.GetHp() + chest.weapon[0].statHp);
                }
                else if (content == "consommable")
                {
                    for (int i = 0; i < chest.herb.Count; i++)
                    {
                        hero.inventory.herbList.Add(chest.herb[i]);
                    }
                    for (int i = 0; i < chest.spice.Count; i++)
                    {
                        hero.inventory.spiceList.Add(chest.spice[i]);
                    }
                }


                currentCase.chestHere   = false;
                currentCase.openedChest = true;
            }
            else
            {
                Console.Clear();
                map.AfficheMap();
                GameMenu();
            }
        }