예제 #1
0
 public static void Lunge(PCharacter character)
 {
     character.Position += new Vector2f(MathF.Cos((MathF.PI / 180) * (character.Display.State.facing + 90)) * character.Speed * 3,
                                        MathF.Sin((MathF.PI / 180) * (character.Display.State.facing + 90)) * character.Speed * 3);
     if (character.Position.X < 0)
     {
         character.Position.X = 0;
     }
     if (character.Position.X > character.Game.Map.Size.X)
     {
         character.Position.X = character.Game.Map.Size.X;
     }
     if (character.Position.Y < 0)
     {
         character.Position.Y = 0;
     }
     if (character.Position.Y > character.Game.Map.Size.Y)
     {
         character.Position.Y = character.Game.Map.Size.Y;
     }
     foreach (var gameCharacter in character.Game.Characters)
     {
         if (gameCharacter != character && character.InReach(gameCharacter))
         {
             character.Hit(gameCharacter);
         }
     }
 }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
 public static void WhirlWind(PCharacter character)
 {
     foreach (var gameCharacter in character.Game.Characters)
     {
         if (gameCharacter != character && character.InReach(gameCharacter, 2))
         {
             character.Hit(gameCharacter);
         }
     }
 }
예제 #5
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);
        }
예제 #6
0
        public static void Throw(PCharacter character)
        {
            PProjectile sword = new PProjectile("Sword", character.Game);

            sword.Owner    = character;
            sword.Position = character.Position;
            sword.Velocity = new Vector2f(MathF.Cos((MathF.PI / 180) * (character.Display.State.facing + 90)) * 300,
                                          MathF.Sin((MathF.PI / 180) * (character.Display.State.facing + 90)) * 300);
            sword.Display.State.facing = character.Display.State.facing;
            character.Game.Pentities.Add(sword);
        }
예제 #7
0
 public override int TakeDamage(PCharacter pCharacter, int attack)
 {
     Health -= (int)(attack * (1 - DamageReduction()));
     if (Health < 0)
     {
         Health = 0;
     }
     if (Health == 0)
     {
         return(Level);
     }
     return(0);
 }
예제 #8
0
        private PEntity ClosestPlayer(Vector2f enemyPosition)
        {
            PCharacter player = null;

            foreach (var character in Characters)
            {
                if (!Enemies.Contains(character))
                {
                    if (player == null)
                    {
                        player = character;
                    }
                    else if ((enemyPosition.X - character.Position.X) * (enemyPosition.X - character.Position.X) +
                             (enemyPosition.Y - character.Position.Y) * (enemyPosition.Y - character.Position.Y) <
                             (enemyPosition.X - player.Position.X) * (enemyPosition.X - player.Position.X) +
                             (enemyPosition.Y - player.Position.Y) * (enemyPosition.Y - player.Position.Y))
                    {
                        player = character;
                    }
                }
            }

            return(player);
        }
예제 #9
0
 public void AddCharacter(PCharacter character)
 {
     Characters.Add(character);
     Pentities.Add(character);
 }
예제 #10
0
 public override int TakeDamage(PCharacter pCharacter, int attack)
 {
     return(0);
 }
예제 #11
0
 public abstract int TakeDamage(PCharacter pCharacter, int attack);