Beispiel #1
0
        static void Main(string[] args)
        {
            Dictionary<string, Dictionary<string, float>> WeaponConfigs = instantiateWeaponConfigs();
            Dictionary<string, Dictionary<string, float>> PlayersConfigs = instantiatePlayersConfigs();

            Player player = new Player("Michael", PlayersConfigs["Michael"]);
            Item harpe = new Item(false, "Harpe");
            MeleeWeapon sword = new MeleeWeapon("Sword", WeaponConfigs["Sword"]);
            MeleeWeapon axe = new MeleeWeapon("Axe", WeaponConfigs["Axe"]);
            RangeWeapon bow = new RangeWeapon("Bow", WeaponConfigs["Bow"]);

            player.addStuff(harpe);
            player.addStuff(sword);
            player.addStuff(axe);
            player.addStuff(bow);

            Dictionary<string, Player> opponents = new Dictionary<string, Player>();
            Player joseph = new Player("Joseph",PlayersConfigs["Joseph"]);
            Item harpe2 = new Item(false, "Harpe");
            joseph.addStuff(harpe2);
            opponents.Add("Joseph", joseph);
            Player connor = new Player("Connor", PlayersConfigs["Connor"]);
            MeleeWeapon sword2 = new MeleeWeapon("Sword", WeaponConfigs["Sword"]);
            connor.addStuff(sword2);
            opponents.Add("Connor", connor);
            Engine e = new Engine(player, opponents);
            e.start();
        }
Beispiel #2
0
 public void use(Player p)
 {
     Random r = new Random();
     int numberOfHits = r.Next(hitsMin, hitsMax);
     for (int i = 0; i < numberOfHits; ++i)
     {
         if (p.dead) break;
         int damages = r.Next(damagesMin, damagesMax);
         p.takeDamages(damages);
     }
 }
Beispiel #3
0
        public Engine(Player p, Dictionary<string, Player> op)
        {
            player = p;
            opponents = op;

            indexKeys.Add('0');
            indexKeys.Add('1');
            indexKeys.Add('2');
            indexKeys.Add('3');
            indexKeys.Add('4');
            indexKeys.Add('5');
            indexKeys.Add('6');
            indexKeys.Add('7');
            indexKeys.Add('8');
            indexKeys.Add('9');
            indexKeys.Add('a');
            indexKeys.Add('b');
            indexKeys.Add('c');
            indexKeys.Add('d');
            indexKeys.Add('e');
            indexKeys.Add('f');
        }
Beispiel #4
0
        private void AIturn(Player ai)
        {
            Console.WriteLine(ai.name + " turn.");
            Random rand = new Random();
            if(ai.inventory.Count>0)
            {
                List<string> invList = ai.inventory.Keys.ToList();
                string selectedItem = invList[rand.Next(ai.inventory.Count - 1)];
                Console.WriteLine(ai.name + " using " + ai.inventory[selectedItem].name);
                ai.inventory[selectedItem].use();
            }
            List<string> combatStyle = new List<string>();
            if (ai.meleeWeapons.Count > 0) combatStyle.Add("Melee Weapons");
            if (ai.rangeWeapons.Count > 0) combatStyle.Add("Range Weapons");
            if (ai.magic.Count > 0) combatStyle.Add("Magic");
            if(combatStyle.Count>0)
            {
                string selectedCombatStyle = combatStyle[rand.Next(combatStyle.Count - 1)];
                if(selectedCombatStyle == "Melee Weapons")
                {
                    List<string> weaponsList = ai.meleeWeapons.Keys.ToList();
                    string selectedWeapon = weaponsList[rand.Next(weaponsList.Count - 1)];
                    Console.WriteLine(ai.name + " uses " + ai.meleeWeapons[selectedWeapon].name + " on you.");
                    ai.meleeWeapons[selectedWeapon].use(player);
                }
                if (selectedCombatStyle == "Range Weapons")
                {
                    List<string> weaponsList = ai.rangeWeapons.Keys.ToList();
                    string selectedWeapon = weaponsList[rand.Next(weaponsList.Count - 1)];
                    Console.WriteLine(ai.name + " uses " + ai.rangeWeapons[selectedWeapon].name + " on you.");
                    ai.rangeWeapons[selectedWeapon].use(player);
                }
                if (selectedCombatStyle == "Magic")
                {

                }
            }
        }