static List <EnemyNPC> SelectEnemies()
        {
            List <EnemyNPC> EnemyNPCs = new List <EnemyNPC>();

            if (Player.GetLevel() == 1)
            {
                int      Ran = DiceRoller.RollDice(2) - 1;
                EnemyNPC Foe = new EnemyNPC();
                Foe = GameObjects.NPCs[Ran];
                EnemyNPCs.Add(Foe);
            }
            else
            {
                int Ran = DiceRoller.RollDice(6);
                switch (Ran)
                {
                case 1:
                case 2:
                    Ran = Player.GetLevel() - 1;
                    break;

                case 3:
                case 4:
                case 5:
                    Ran = Player.GetLevel();
                    break;

                case 6:
                    Ran = Player.GetLevel() + 1;
                    break;
                }
                List <EnemyNPC> Temp = new List <EnemyNPC>();
                foreach (EnemyNPC NPC in GameObjects.NPCs)
                {
                    if (NPC.DifBonus == Ran)
                    {
                        Temp.Add(NPC);
                    }
                }
                Ran = DiceRoller.RollDice(Temp.Count);
                EnemyNPC Foe = Temp[Ran];
                EnemyNPCs.Add(Foe);
            }
            return(EnemyNPCs);
        }
예제 #2
0
        static void AttackPlayer(EnemyNPC NPC, byte AttackType)
        {
            int Attack = DiceRoller.RollDice(12) + NPC.StrMod + (NPC.DifBonus / 3);

            if (Attack >= Player.GetAC())
            {
                Events.NewEvent("AttackRoll", Attack - (NPC.StrMod + NPC.DifBonus), NPC.StrMod, NPC.DifBonus, Attack, Player.GetAC(), NPC.Name, Player.GetName(),
                                "HIT");
                DamagePlayer(NPC, AttackType);
            }
            else
            {
                Events.NewEvent("AttackRoll", Attack - (NPC.StrMod + NPC.DifBonus), NPC.StrMod, NPC.DifBonus, Attack, Player.GetAC(), NPC.Name, Player.GetName(),
                                "MISS");
                string Update = NPC.Name + " attacked you and missed!";
                IO.GameUpdate(Update);
            }
            Thread.Sleep(Settings.GetPauseTime());
        }
예제 #3
0
        static int DamageEnemy(string AttackType, EnemyNPC NPC)
        {
            int Damage  = DiceRoller.RollDice(Player.Weapon.Damage) + Player.GetStrMod();
            int Damage2 = Damage;

            if (AttackType == "Light")
            {
                Damage2 = (Damage / 3) * 2;
                Events.NewEvent("LightDamageRoll", EN1: Damage - Player.GetStrMod(), EN2: Player.GetStrMod(), EN3: Damage2, ES1: Player.GetName(),
                                ES2: NPC.Name);
            }
            else
            {
                Events.NewEvent("HeavyDamageRoll", EN1: Damage - Player.GetStrMod(), EN2: Player.GetStrMod(), EN3: Damage2, ES1: Player.GetName(),
                                ES2: NPC.Name);
            }

            return(Damage2);
        }
예제 #4
0
        static void DamagePlayer(EnemyNPC NPC, byte AttackType)
        {
            int Damage  = DiceRoller.RollDice(NPC.Weapon.Damage) + NPC.StrMod;
            int Damage2 = Damage;

            if (AttackType == 1)
            {
                Damage2 = (Damage / 3) * 2;
                Events.NewEvent("LightDamageRoll", EN1: Damage - NPC.StrMod, EN2: NPC.StrMod, EN3: Damage2, ES1: NPC.Name, ES2: Player.GetName());
            }
            else
            {
                Events.NewEvent("HeavyDamageRoll", EN1: Damage - NPC.StrMod, EN2: NPC.StrMod, EN3: Damage, ES1: NPC.Name, ES2: Player.GetName());
            }
            Player.SetHP(Player.GetHP() - Damage2);
            string Update = NPC.Name + " attacked you for " + Damage2 + " Damage!";

            IO.PlayerHP(Player.GetHP(), Player.GetMaxHP());
            IO.GameUpdate(Update);
        }
예제 #5
0
 public static void SortFightOrder()
 {
     if (EncounterNPCs.Count > 0)
     {
         Player.SetInitiative(RollInitiative(Player.GetDexMod()));
         foreach (EnemyNPC Enemy in EncounterNPCs)
         {
             Enemy.Initiative = RollInitiative(Enemy.DexMod);
         }
         int Ini = Initiatives.Max();
         while (Ini != 0)
         {
             if (Player.GetInitiative() == Ini)
             {
                 EnemyNPC PlayerIni = new EnemyNPC();
                 PlayerIni.Name = Player.GetName();;
                 FightOrder.Add(PlayerIni);
             }
             foreach (EnemyNPC Enemy in EncounterNPCs)
             {
                 if (Enemy.Initiative == Ini)
                 {
                     FightOrder.Add(Enemy);
                 }
             }
             Ini--;
         }
     }
     else
     {
         EnemyNPC DefaultNPC = new EnemyNPC();
         DefaultNPC = GameObjects.NPCs[0];
         EncounterNPCs.Add(DefaultNPC);
         SortFightOrder();
     }
     IO.NPCs(EncounterNPCs);
 }
        public static void LoadGameObjects()
        {
            ClearGameObjects();
            XmlDocument Doc = new XmlDocument();

            Doc.Load("GameObjects.xml");
            foreach (XmlNode Node in Doc.DocumentElement)
            {
                if (Node.Name == "Weapons")
                {
                    int      Count      = 0;
                    int      ChildCount = Convert.ToInt32(Node.Attributes[0].Value);
                    Weapon[] WeapTemp   = new Weapon[ChildCount];
                    foreach (XmlNode Child in Node.ChildNodes)
                    {
                        WeapTemp[Count]           = new Weapon();
                        WeapTemp[Count].Name      = Child.Name;
                        WeapTemp[Count].Damage    = Convert.ToInt32(Child.Attributes[1].Value);
                        WeapTemp[Count].TwoHanded = Convert.ToBoolean(Child.Attributes[2].Value);
                        WeapTemp[Count].Versatile = Convert.ToBoolean(Child.Attributes[3].Value);
                        WeapTemp[Count].Cost      = Convert.ToInt32(Child.Attributes[4].Value);
                        Count++;
                    }
                    foreach (Weapon Weapon in WeapTemp)
                    {
                        Weapons.Add(Weapon);
                    }
                }
                else if (Node.Name == "Armour")
                {
                    int      Count      = 0;
                    int      ChildCount = Convert.ToInt32(Node.Attributes[0].Value);
                    Armour[] ArmTemp    = new Armour[ChildCount];
                    foreach (XmlNode Child in Node.ChildNodes)
                    {
                        ArmTemp[Count]        = new Armour();
                        ArmTemp[Count].Name   = Child.Name;
                        ArmTemp[Count].AC     = Convert.ToInt32(Child.Attributes[1].Value);
                        ArmTemp[Count].Weight = Child.Attributes[2].Value;
                        ArmTemp[Count].Cost   = Convert.ToInt32(Child.Attributes[3].Value);
                        Count++;
                    }
                    foreach (Armour Arm in ArmTemp)
                    {
                        Armour.Add(Arm);
                    }
                }
                else if (Node.Name == "Potions")
                {
                    int      Count      = 0;
                    int      ChildCount = Convert.ToInt32(Node.Attributes[0].Value);
                    Potion[] PotTemp    = new Potion[ChildCount];
                    foreach (XmlNode Child in Node.ChildNodes)
                    {
                        PotTemp[Count]          = new Potion();
                        PotTemp[Count].Name     = Child.Attributes[0].Value;
                        PotTemp[Count].DiceNum  = Convert.ToInt32(Child.Attributes[1].Value);
                        PotTemp[Count].DiceSize = Convert.ToInt32(Child.Attributes[2].Value);
                        PotTemp[Count].Modifier = Convert.ToInt32(Child.Attributes[3].Value);
                    }
                    foreach (Potion Potion in PotTemp)
                    {
                        Potions.Add(Potion);
                    }
                }
                else if (Node.Name == "Enemies")
                {
                    int        Count      = 0;
                    int        ChildCount = Convert.ToInt32(Node.Attributes[0].Value);
                    EnemyNPC[] EnmTemp    = new EnemyNPC[ChildCount];
                    foreach (XmlNode Child in Node.ChildNodes)
                    {
                        EnmTemp[Count]            = new EnemyNPC();
                        EnmTemp[Count].Name       = Child.Name;
                        EnmTemp[Count].HP         = Convert.ToInt32(Child.Attributes[0].Value);
                        EnmTemp[Count].MaxHP      = EnmTemp[Count].HP;
                        EnmTemp[Count].AC         = Convert.ToInt32(Child.Attributes[1].Value);
                        EnmTemp[Count].Str        = Convert.ToInt32(Child.Attributes[2].Value);
                        EnmTemp[Count].StrMod     = Convert.ToInt32(Child.Attributes[3].Value);
                        EnmTemp[Count].Dex        = Convert.ToInt32(Child.Attributes[4].Value);
                        EnmTemp[Count].DexMod     = Convert.ToInt32(Child.Attributes[5].Value);
                        EnmTemp[Count].Con        = Convert.ToInt32(Child.Attributes[6].Value);
                        EnmTemp[Count].ConMod     = Convert.ToInt32(Child.Attributes[7].Value);
                        EnmTemp[Count].Stamina    = Convert.ToInt32(Child.Attributes[8].Value);
                        EnmTemp[Count].StaminaMax = Convert.ToInt32(Child.Attributes[9].Value);
                        EnmTemp[Count].DifBonus   = Convert.ToInt32(Child.Attributes[10].Value);
                        EnmTemp[Count].Weapon.UpdateWeaponString(Child.Attributes[11].Value);
                        EnmTemp[Count].OffHand = Child.Attributes[12].Value;
                        EnmTemp[Count].Armour.UpdateArmourString(Child.Attributes[13].Value);
                        EnmTemp[Count].XPValue = Convert.ToInt32(Child.Attributes[14].Value);
                        Count++;
                    }
                    foreach (EnemyNPC NPC in EnmTemp)
                    {
                        NPCs.Add(NPC);
                    }
                }
            }
        }