Exemple #1
0
        public PCharacter LoadCharacter(Vector2f position, Vector2f size)
        {
            PCharacter character = new PCharacter("Player", this);

            try
            {
                string[] lines = System.IO.File.ReadAllLines("../../../Resources/Saves/save.txt");
                character.Level        = int.Parse(lines[0]);
                character.Experience   = int.Parse(lines[1]);
                character.SkillPoints  = int.Parse(lines[2]);
                character.Vigor        = int.Parse(lines[3]);
                character.Health       = character.Vigor;
                character.Strength     = int.Parse(lines[4]);
                character.Agility      = int.Parse(lines[5]);
                character.Intelligence = int.Parse(lines[6]);
                character.Mana         = character.Intelligence;
                character.Spirit       = int.Parse(lines[7]);
            }
            catch (FileNotFoundException fileNotFoundException)
            {
                Console.WriteLine("No save file found");
            }
            catch (DirectoryNotFoundException directoryNotFoundException)
            {
                Console.WriteLine("No save directory found");
            }
            character.Position = position;
            character.Size     = size;
            character.GenerateHitmesh();
            return(character);
        }
Exemple #2
0
        public void AddCharacter(string name, Vector2f size, Vector2f position)
        {
            PCharacter character = new PCharacter(name, this);

            character.Position = position;
            character.Size     = size;
            character.GenerateHitmesh();
            Characters.Add(character);
            Pentities.Add(character);
        }
Exemple #3
0
        public void GenerateRoom()
        {
            Random   rand = new Random();
            GameRoom room = new GameRoom(this, new Vector2i(rand.Next(30, 70), rand.Next(30, 70)));

            room.Game = this;
            int enemyNum = rand.Next(1, room.Size.X * 32 / 500 * room.Size.Y * 32 / 500);

            for (int i = 0; i < enemyNum; i++)
            {
                PCharacter enemy = new PCharacter("Enemy", this);
                enemy.Size     = new Vector2f(70, 100);
                enemy.Position = new Vector2f(rand.Next(0, room.Size.X * 32), rand.Next(0, room.Size.Y * 32 - 200));
                enemy.GenerateHitmesh();
                enemy.Agility      = 1;
                enemy.Vigor        = 5;
                enemy.Strength     = 3;
                enemy.Intelligence = 3;
                enemy.Spirit       = 3;
                enemy.Level        = Characters[0].Level;
                while (enemy.SkillPoints > 0)
                {
                    switch (rand.Next(5))
                    {
                    case 0:
                        enemy.Agility++;
                        break;

                    case 1:
                        enemy.Strength++;
                        break;

                    case 2:
                        enemy.Intelligence++;
                        break;

                    case 3:
                        enemy.Spirit++;
                        break;

                    case 4:
                        enemy.Vigor++;
                        break;
                    }

                    enemy.SkillPoints--;
                }

                enemy.Health = enemy.Vigor;
                enemy.Mana   = enemy.Intelligence;
                Characters.Add(enemy);
                Enemies.Add(enemy);
            }
            LoadRoom(room);
        }