Exemple #1
0
        public void TestTrollCreator()
        {
            Troll troll = new Troll("Troll");

            int  HealthExpected = 150;
            bool actualStick    = troll.Items[0] is Stick;
            bool actualArmor    = troll.Items[1] is Armor;


            Assert.AreEqual(HealthExpected, troll.Health);
            Assert.AreEqual(actualStick, true);
            Assert.AreEqual(actualArmor, true);
        }
Exemple #2
0
        public void RecibeAtaqueTest()
        {
            Troll troll = new Troll("Troll");

            //ReciveAttack es el poder de ataque que pide la letra

            troll.ReceiveAttack(100);


            int excpectedAttack = 65;

            Assert.AreEqual(excpectedAttack, troll.Health);
        }
        public void TestCharacterCreationWithMagicDefensePowerIncreases()
        {
            Character character      = new Troll("Character");
            int       expectedBefore = 15;

            Assert.AreEqual(expectedBefore, character.DefensePower);
            Magic magic = new Magic();

            character.AddItem(magic);
            int expectedAfter = 45;

            Assert.AreEqual(expectedAfter, character.DefensePower);
        }
        public void TestAddTwoItemToWizard()
        {
            // Creamos un Troll y un elemento Magic
            Troll troll  = new Troll("name");
            Magic magic  = new Magic();
            Magic magic1 = new Magic();

            troll.AddItem(magic);
            troll.AddItem(magic1);
            int expected = magic.AttackPower + magic1.AttackPower;
            int actual   = troll.DefensePower;

            Assert.AreNotEqual(expected - magic.AttackPower, actual);
        }
        public void TestRemoveMagicAndDefensePowerDecreases()
        {
            Character character = new Troll("Troll");
            Magic     magic     = new Magic();

            character.AddItem(magic);
            int expectedBefore = 45;

            Assert.AreEqual(expectedBefore, character.DefensePower);
            character.RemoveItem(magic);
            int expectedAfter = 15;

            Assert.AreEqual(expectedAfter, character.DefensePower);
        }
Exemple #6
0
        public void TestQuitItemToWizard()
        {
            // Creamos un Troll y un elemento Magic
            Troll troll = new Troll("name");
            Magic magic = new Magic();

            troll.AddItem(magic);
            int expected = troll.AttackPower;

            //Quitamos el objeto Magic en Troll
            troll.RemoveItem(magic);
            int actual = troll.AttackPower;

            Assert.AreNotEqual(expected - magic.AttackPower, actual);
        }
Exemple #7
0
        public void TestArmor()
        {
            Troll Mateo    = new Troll("Nombre1");
            Armor Armadura = new Armor();
            IItem Variable = null;

            foreach (IItem Elemento in Mateo.Items)
            {
                if (Elemento.GetType() == Armadura.GetType())
                {
                    Variable = Elemento;
                }
            }

            Assert.AreEqual(Armadura.GetType(), Variable.GetType());
        }
Exemple #8
0
        public void TestExchangeEncounterItemNotFoundExceptionThowrn()
        {
            Troll             troll    = new Troll("Troll");
            Wizard            wizard   = new Wizard("Wizard");
            ExchangeEncounter exchange = new ExchangeEncounter(troll, wizard);
            Magic             magic    = new Magic();

            try
            {
                exchange.AddItemToExchange(magic);
            }
            catch (ItemNotFoundException e)
            {
                Assert.True(true, e.Message);
            }
        }
Exemple #9
0
        public void TestStick()
        {
            Troll Mateo    = new Troll("Nombre1");
            Stick Palo     = new Stick();
            IItem Variable = null;

            foreach (IItem Elemento in Mateo.Items)
            {
                if (Elemento.GetType() == Palo.GetType())
                {
                    Variable = Elemento;
                }
            }


            Assert.AreEqual(Palo.GetType(), Variable.GetType());
        }
        public static Troll CreateTroll(IPlayer player)
        {
            Random rnd      = new Random();
            Troll  newTroll = new Troll();

            newTroll.Level = rnd.Next(6, 10) + player.Level;
            if (newTroll.Level <= 0)
            {
                newTroll.Level = 1;
            }
            newTroll.Name     = "Troll";
            newTroll.Hp       = rnd.Next(100, 120) * newTroll.Level;
            newTroll.Strength = rnd.Next(25, 30) * newTroll.Level;
            newTroll.Armor    = rnd.Next(10, 15) * newTroll.Level;
            newTroll.Exp      = player.Level * newTroll.Level + 50;

            return(newTroll);
        }
Exemple #11
0
        ////25JUL2008 Lord_Greywolf fix for bad X *** END   ***

        protected virtual void SpawnGenerate(Point2D p, Map map)
        {
            BaseCreature spawn;

            switch (Utility.Random(4))
            {
            default:
            case 0: spawn = new Lich(); break;

            case 1: spawn = new Skeleton(); break;

            case 2: spawn = new Mongbat(); break;

            case 3: spawn = new Troll(); break;
            }

            Spawn(p, map, spawn);

            Delete();
        }
Exemple #12
0
        public ActionResult <string> GetUserById(int id) //todo add comment
        {
            Troll t = TrollContext.GetTroll(id);

            if (t == null)
            {
                return("Oh no!  That troll doesn't exist!");
            }
            var res = t.Feed("asdf"); //todo add comment

            //TODO add a 5 minute buffer or something

            if (res == FeedResult.LEVELUP)
            {
                return($"WOOOO {t.Name} Leveled up!  They are now level {t.Level}!");
            }
            else
            {
                return($"You fed {t.Name}!  They now have {t.Experience} experience, and need {t.NextLevelXp} to level up!");
            }
        }
        public void TestTrollCreationLife150withArmourAndStick()
        {
            Troll troll        = new Troll("Troll");
            int   lifeExpected = 150;
            bool  hasArmor     = false;
            bool  hasStick     = false;

            foreach (IItem item in troll.Items)
            {
                if (item.ToString().Equals("Stick"))
                {
                    hasStick = true;
                }
                else if (item.ToString().Equals("Armor"))
                {
                    hasArmor = true;
                }
            }
            Assert.AreEqual(true, hasArmor);
            Assert.AreEqual(true, hasStick);
            Assert.AreEqual(lifeExpected, troll.Health);
        }
        public static void Spawn(string creatureType)
        {
            ICreature creature;

            switch (creatureType)
            {
            case "Orc":
                creature = new Orc();
                break;

            case "Troll":
                creature = new Troll();
                break;

            default:
                creature = new Troll();
                break;
            }

            creature.Shout();
            creature.Walk();
        }
Exemple #15
0
 /*
  * Author: Dr Nexus
  * Modified by: Kroy
  *
  * Choose the race and set race specific attributes, for character c.
  *
  * Parameter c Character to set.
  * Parameter race of the character.
  * Return create basic stats.
  */
 public bool OnCharacterChooseRace(Character c, Races race)
 {
     //Skill lang = null;
     if (race == Races.Dwarf)
     {
         Dwarf.Start(c);
     }
     else if (race == Races.Gnome)
     {
         Gnome.Start(c);
     }
     else if (race == Races.Human)
     {
         Human.Start(c);
     }
     else if (race == Races.NightElf)
     {
         NightElf.Start(c);
     }
     else if (race == Races.Orc)
     {
         Orc.Start(c);
     }
     else if (race == Races.Tauren)
     {
         Tauren.Start(c);
     }
     else if (race == Races.Troll)
     {
         Troll.Start(c);
     }
     else if (race == Races.Undead)
     {
         Undead.Start(c);
     }
     ChooseClass(c);          // Coose class after race.
     return(true);            // execute the caller code
 }
Exemple #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("SuperTipo ");
            King king = new King();

            king.SetWeapon(new AxeBehavior());
            king.WeaponBehavior.UseWeapon();
            king.Fight();

            Queen queen = new Queen();

            queen.SetWeapon(new KnifeBehavior());
            queen.WeaponBehavior.UseWeapon();
            queen.Fight();

            Troll troll = new Troll();

            troll.SetWeapon(new SwordBehavior());
            troll.WeaponBehavior.UseWeapon();
            troll.Fight();

            Console.ReadKey();
        }
Exemple #17
0
 public void BindingPVm()
 {
     PVM.DataBindings.Clear();
     if (TirageJeu.ChoixMonstre == 1)
     {
         Gobi = Gobelin.Instance;
         PVM.DataBindings.Add(new Binding("Text", Gobi, "MVie", true));
     }
     else if (TirageJeu.ChoixMonstre == 2)
     {
         Bhou = Fantôme.Instance;
         PVM.DataBindings.Add(new Binding("Text", Bhou, "MVie", true));
     }
     else if (TirageJeu.ChoixMonstre == 3)
     {
         Trolly = Troll.Instance;
         PVM.DataBindings.Add(new Binding("Text", Trolly, "MVie", true));
     }
     else if (TirageJeu.ChoixMonstre == 4)
     {
         Barzak = BossBarzak.Instance;
         PVM.DataBindings.Add(new Binding("Text", Barzak, "MVie", true));
     }
 }
Exemple #18
0
        public override void Damage(Mobile m)
        {
            base.Damage(m);

            if (m.Alive)
            {
                Item item = m.FindItemOnLayer(Layer.OuterTorso);

                if (item is GMRobe)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                }
                else if (item is GMRobeExplosion)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    m.PlaySound(Utility.RandomList(0x307, 0x308));
                }
                else if (item is GMRobeHoly)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);

                    m.FixedParticles(0x375A, 1, 30, 9966, 88, 2, EffectLayer.Head);
                    m.FixedParticles(0x37B9, 1, 30, 9502, 85, 3, EffectLayer.Head);
                    m.FixedParticles(0x376A, 1, 31, 9961, 80, 0, EffectLayer.Waist);
                    m.FixedParticles(0x37C4, 1, 31, 9502, 88, 2, EffectLayer.Waist);
                }
                else if (item is GMRobeTrailfire)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);

                    m.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot);
                }
                else
                {
                    // Wind
                    if (Utility.RandomDouble() < 0.09)
                    {
                        m.PlaySound(Utility.RandomList(0x014, 0x15, 0x016, 0x5C7));
                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    }

                    // Thunderstorm
                    if (Utility.RandomDouble() < 0.06)
                    {
                        m.PlaySound(Utility.RandomList(0x028, 0x029, 0x206));
                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    }

                    // Lightning Strike
                    if (Utility.RandomDouble() < 0.01)
                    {
                        m.PlaySound(Utility.RandomList(0x5CE));
                        m.BoltEffect(0x480);
                        AOS.Damage(m, Utility.RandomMinMax(12, 35), 0, 0, 0, 0, 100);
                    }

                    // Random Encounter 1
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 12;
                            int y1 = m.Y + 12;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature encountera;
                                switch (Utility.Random(3))
                                {
                                default:
                                case 0: encountera = new Ettin(); break;

                                case 1: encountera = new Ogre(); break;

                                case 2: encountera = new Troll(); break;
                                }
                                encountera.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);
                                encountera.Combatant = m;

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(3.0), new TimerStateCallback(DeleteEncounterA), encountera);
                            }
                        }
                    }

                    // Random Encounter 2
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 12;
                            int y2 = m.Y - 12;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature encountera;
                                switch (Utility.Random(3))
                                {
                                default:
                                case 0: encountera = new Ettin(); break;

                                case 1: encountera = new Ogre(); break;

                                case 2: encountera = new Troll(); break;
                                }
                                encountera.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);
                                encountera.Combatant = m;

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(3.0), new TimerStateCallback(DeleteEncounterA), encountera);
                            }
                        }
                    }

                    // Tamable Encounter 1
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 12;
                            int y1 = m.Y + 12;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature tameable;
                                switch (Utility.Random(5))
                                {
                                default:
                                case 0: tameable = new Bird(); break;

                                case 1: tameable = new BlackBear(); break;

                                case 2: tameable = new DireWolf(); break;

                                case 3: tameable = new Goat(); break;

                                case 4: tameable = new Horse(); break;
                                }
                                tameable.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(2.0), new TimerStateCallback(DeleteTameable), tameable);
                            }
                        }
                    }

                    // Tamable Encounter 2
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 12;
                            int y2 = m.Y - 12;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature tameable;
                                switch (Utility.Random(5))
                                {
                                default:
                                case 0: tameable = new Bird(); break;

                                case 1: tameable = new BlackBear(); break;

                                case 2: tameable = new DireWolf(); break;

                                case 3: tameable = new Goat(); break;

                                case 4: tameable = new Horse(); break;
                                }
                                tameable.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(2.0), new TimerStateCallback(DeleteTameable), tameable);
                            }
                        }
                    }
                }
            }
        }
 public void SetUp()
 {
     elf   = new Elf("elf");
     troll = new Troll("troll");
 }
Exemple #20
0
    static void Main(string[] args)
    {
        //set the console size
        Console.BufferHeight = Console.WindowHeight = 40;
        Console.BufferWidth  = Console.WindowWidth = 90;

        int fieldWidth = 60;

        int lives = 3;

        int score = 0;

        Random random = new Random();

        char[] rocksSymbols = { '#', '@', '^', '&', '*', '$', '+', '%', '!', '.', ';', '-' }; //Rocks symbols

        //Create the troll
        Troll troll = new Troll();

        troll.x         = fieldWidth / 2;
        troll.y         = Console.WindowHeight - 2;
        troll.color     = ConsoleColor.Green;
        troll.character = 'O';



        List <Rock> rocks = new List <Rock>(); //Rocks list with positions and ...

        while (true)
        {
            //Adding random rock to the field
            Rock nextRock = new Rock();
            nextRock.color     = (ConsoleColor)Enum.GetValues(typeof(ConsoleColor)).GetValue(random.Next(16)); //Random color for rock
            nextRock.x         = random.Next(0, fieldWidth);
            nextRock.y         = 0;
            nextRock.character = (char)rocksSymbols.GetValue(random.Next(rocksSymbols.Length)); //Random char for rock
            rocks.Add(nextRock);

            //Check if key is pressed
            while (Console.KeyAvailable)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                //Clear key buffer
                while (Console.KeyAvailable)
                {
                    Console.ReadKey(true);
                }
                //Move car with left and right arrow
                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if (troll.x - 1 >= 0)
                    {
                        troll.x--;
                    }
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    if (troll.x + 1 <= fieldWidth)
                    {
                        troll.x++;
                    }
                }
            }

            //Create new list to fix the falling rocks
            List <Rock> newList = new List <Rock>();

            //Make rocks fall
            for (int i = 0; i < rocks.Count; i++)
            {
                Rock oldRock = rocks[i];
                Rock newRock = new Rock();
                newRock = oldRock;
                newRock.y++;

                //Check if rock hits the troll
                if (newRock.y == troll.y && newRock.x == troll.x)
                {
                    lives--;
                    rocks.Clear();
                    Console.Beep();
                    if (lives <= 0)
                    {
                        Console.Clear();
                        PrintInfoOnPosition(35, 15, "Score: " + score, ConsoleColor.White);
                        PrintInfoOnPosition(35, 20, "GAME OVER!!!", ConsoleColor.Red);
                        Environment.Exit(0);
                    }
                }

                //Add rock to the newList if newRock.y is not greater than the console height
                if (newRock.y < Console.WindowHeight - 1)
                {
                    newList.Add(newRock);
                }
                else
                {
                    score++;
                }
            }
            rocks = newList;

            //Clear the console to print new list and troll
            Console.Clear();

            //Print troll
            PrintOnPosition(troll.x, troll.y, troll.character, troll.color);

            //Print all rocks
            foreach (Rock rock in rocks)
            {
                PrintOnPosition(rock.x, rock.y, rock.character, rock.color);
            }

            //Print info
            PrintInfoOnPosition(65, 1, "Falling Rocks game", ConsoleColor.Blue);
            PrintInfoOnPosition(70, 17, "Lives: " + lives, ConsoleColor.White);
            PrintInfoOnPosition(70, 18, "Score: " + score, ConsoleColor.White);

            //Slow the game speed
            Thread.Sleep(150);
        }
    }
Exemple #21
0
 public abstract void Execute(Troll troll);
Exemple #22
0
 public void SetTroll(Troll troll)
 {
     this.troll = troll;
 }
Exemple #23
0
 public static void test(Troll troll)
 {
     troll.rigidBody.AddForce(troll.transform.up * 1000);
     troll.printState("staeteujkkdasf");
 }
Exemple #24
0
        //todo Potion()
        //todo Scoll()
        //todo Weapon()
        //todo Shield()
        //todo Jewelry()
        //todo Quest Item, Junk, Gems, Keys, Runes, Charms, Tomes, Arrows, Bolts, Bows, Crossbow, Staves, Wands, etc ....

        public static void Monster(Monster monster) //todo needs looked into, a better way - add to list maybe
        {
            int _monster = random.Next(1, 7);

            switch (_monster)
            {
            case 1:
                Goblin goblin = new Goblin();
                monster.Name             = goblin.Name;
                monster.HealthMax        = monster.Health = random.Next(goblin.HealthLow, goblin.HealthHigh);
                monster.WeaponDamageLow  = goblin.WeaponDamageLow;
                monster.WeaponDamageHigh = goblin.WeaponDamageHigh;
                monster.Gold             = goblin.Gold;
                break;

            case 2:
                Rat rat = new Rat();
                monster.Name             = rat.Name;
                monster.HealthMax        = monster.Health = random.Next(rat.HealthLow, rat.HealthHigh);
                monster.WeaponDamageLow  = rat.WeaponDamageLow;
                monster.WeaponDamageHigh = rat.WeaponDamageHigh;
                monster.Gold             = rat.Gold;
                break;

            case 3:
                Zombie zombie = new Zombie();
                monster.Name             = zombie.Name;
                monster.HealthMax        = monster.Health = random.Next(zombie.HealthLow, zombie.HealthHigh);
                monster.WeaponDamageLow  = zombie.WeaponDamageLow;
                monster.WeaponDamageHigh = zombie.WeaponDamageHigh;
                monster.Gold             = zombie.Gold;
                break;

            case 4:
                Skeleton skeleton = new Skeleton();
                monster.Name             = skeleton.Name;
                monster.HealthMax        = monster.Health = random.Next(skeleton.HealthLow, skeleton.HealthHigh);
                monster.WeaponDamageLow  = skeleton.WeaponDamageLow;
                monster.WeaponDamageHigh = skeleton.WeaponDamageHigh;
                monster.Gold             = skeleton.Gold;
                break;

            case 5:
                Troll troll = new Troll();
                monster.Name             = troll.Name;
                monster.HealthMax        = monster.Health = random.Next(troll.HealthLow, troll.HealthHigh);
                monster.WeaponDamageLow  = troll.WeaponDamageLow;
                monster.WeaponDamageHigh = troll.WeaponDamageHigh;
                monster.Gold             = troll.Gold;
                break;

            case 6:
                Spirit spirit = new Spirit();
                monster.Name             = spirit.Name;
                monster.HealthMax        = monster.Health = random.Next(spirit.HealthLow, spirit.HealthHigh);
                monster.WeaponDamageLow  = spirit.WeaponDamageLow;
                monster.WeaponDamageHigh = spirit.WeaponDamageHigh;
                monster.Gold             = spirit.Gold;
                break;
            }
        }
Exemple #25
0
        public static async void CombattreTroll()
        {
            Joueur Vivi   = Joueur.Instance;
            Troll  Trolly = Troll.Instance;
            Query  query  = new Query();
            Page   page   = Page.Instance;
            bool   jeu    = true;

            DelegAsync.MethAsyncTexteJ("Combat: un troll.");
            await Task.Delay(2000);

            while (jeu)
            {
                while (Vivi.Vivant && Trolly.Vivant)
                {
                    Form1.PanelJeu.Invoke(new MethodInvoker(delegate { Vivi.LibereAttaque(); }));
                    MesBouttons.stop.WaitOne();
                    await Task.Delay(3000);

                    MesBouttons.stop.WaitOne();
                    Form1.PanelJeu.Invoke(new MethodInvoker(delegate { Vivi.BlockAttaque(); }));
                    Trolly.Attaque(Vivi);
                    if (Trolly.Degats == Trolly.AttaqueRapide && Vivi.Degats == Vivi.Bouclier || Trolly.Degats == Trolly.AttaqueLourde && Vivi.Degats == Vivi.AttaqueRapide || Trolly.Degats == Trolly.Bouclier && Vivi.Degats == Vivi.AttaqueLourde || Vivi.Degats == Vivi.Magie)
                    {
                        Trolly.SubirDegats(Vivi.Degats);
                        MesLabels.PVM.Invoke(new MethodInvoker(delegate { Trolly.UpMVie(); }));
                        if (Trolly.MVie > 0)
                        {
                            DelegAsync.MethAsyncTexteC("Ton attaque réussit.\nIl reste " +
                                                       Convert.ToString(Trolly.MVie) +
                                                       " point de vie au troll et tu en as encore " +
                                                       Convert.ToString(Vivi.Vie) +
                                                       " point de vies!");
                            await Task.Delay(3000);
                        }
                        else
                        {
                            DelegAsync.MethAsyncTexteJ("Le troll meurs!");
                            DelegAsync.MethAsyncTexteM("");
                        }
                    }
                    else if (Trolly.Degats == Trolly.AttaqueRapide && Vivi.Degats == Vivi.AttaqueLourde || Trolly.Degats == Trolly.AttaqueLourde && Vivi.Degats == Vivi.Bouclier || Trolly.Degats == Trolly.Bouclier && Vivi.Degats == Vivi.AttaqueRapide)
                    {
                        Vivi.SubitDegats(Trolly.Degats);
                        MesLabels.PV.Invoke(new MethodInvoker(delegate { Vivi.UpVie(); }));
                        if (Vivi.Vie > 0)
                        {
                            DelegAsync.MethAsyncTexteC("Le troll te touche.\nIl te reste " +
                                                       Convert.ToString(Vivi.Vie) +
                                                       " point de vie et le troll possède encore " +
                                                       Convert.ToString(Trolly.MVie) +
                                                       " point de vies!");
                            await Task.Delay(3000);
                        }
                        else
                        {
                            DelegAsync.MethAsyncTexteJ("Tu meurs!\nLe troll se délecte de ton cadavre!");
                            DelegAsync.MethAsyncTexteM("");
                        }
                    }
                    else
                    {
                        DelegAsync.MethAsyncTexteC("Le coup est contré!");
                        await Task.Delay(3000);
                    }

                    if (Vivi.Vivant && !Trolly.Vivant)
                    {
                        Vivi.Experience += 20;
                        Vivi.NiveauGagner();
                        Stuff stuff = Stuff.Lotterie;
                        stuff.EquipementLourd();
                        Vivi.PotionDeVie();
                        MesLabels.TexteCombat.Invoke(new MethodInvoker(delegate { Vivi.UpVie(); }));
                        query.SauvegardeDuJeu();
                        jeu = false;
                        Form1.PanelJeu.Invoke(new MethodInvoker(delegate { page.PageCombatFinit(); }));
                    }
                    else if (!Vivi.Vivant)
                    {
                        DelegAsync.MethAsyncTexteC("Perdu!!!");
                        jeu = false;
                    }
                }
            }
        }
Exemple #26
0
 public void TestTrollWeapon()
 {
     HeadFirstDesignPatterns.Strategy.Character.Troll TrollWeapon = new Troll();
     Assert.AreEqual("I will chop thine head off!", TrollWeapon.Fight());
 }
Exemple #27
0
        private void CreateMonsters()
        {
            for (int i = 0; i < 10; i++)
            {
                Troll t = new Troll("Troll", 15, 8);
                Point pos = level.GetRandomEmptyPosition();
                t.Position = pos;
                level.Map[pos.X, pos.Y].Monster = t;
                creatures.Add(t);
            }

            for (int i = 0; i < 25; i++)
            {
                Goblin g = new Goblin("Cowardly Goblin", 10, 3);
                Point pos = level.GetRandomEmptyPosition();
                g.Position = pos;
                level.Map[pos.X, pos.Y].Monster = g;
                creatures.Add(g);
            }
        }
Exemple #28
0
        public static void initTroll(Troll troll)
        {
            /*
             *在这里,我们将动画中添加到的所有标签写入(state中的tag属性)
             * 还有,需要添加Trigger的攻击动画的名称呼也要写入
             */
            troll.aniStateTag = new string[] { "Sleep", "Idle", "Run", "BackMove"
                                               , "BeforeAttack", "Attack", "AfterAttack", "Die", "AfterDie", "Evade",
                                               "AfterRun", "AfterEvade" };
            troll.aniStateName_EffectOrAttack = new string[] { "Sleep" };

            /*
             *在这里,我们初始化所有的状态机,并添加好退出状态机所对应的的动画(当播放到这几个动画时,我们退出状态机)
             * dic1,dic2,list只是临时变量,无须在意
             *在dic1中,我们写入需要打开的变量,第一个string是需要修改动画变量的当前state的tag,第二个是需要修改为true
             *的动画变量名,写完后,我们必须在dic2中同样添加一个相同的需要修改动画变量的当前state的tag,但第二个是需要修
             * 改为false的动画变量名
             * list中为退出状态机所对应的的动画的tag名(当播放到这几个动画时,我们退出状态机)
             */
            Dictionary <string, string> dic1 = new Dictionary <string, string>();
            Dictionary <string, string> dic2 = new Dictionary <string, string>();

            string[] list = new string[5];
            //攻击状态机初始化
            list         = new string[] { "AfterAttack" };
            troll.attack = new State_Attack_TypeA(dic1, dic2, list, 100);
            troll.attack.SetTroll(troll);
            //睡眠状态机初始化
            list        = new string[] { "Idle" };
            troll.sleep = new State_Sleep_TypeA(dic1, dic2, list);
            troll.sleep.SetTroll(troll);
            //移动状态机初始化(包括追击和后移调整方向)
            list       = new string[] { "AfterRun" };
            troll.move = new State_Move_TypeA(dic1, dic2, new string[] { "AfterRun" });
            troll.move.SetTroll(troll);
            //紧急退避状态机初始化
            list        = new string[] { "AfterEvade" };
            troll.evade = new State_Evade_TypeA(dic1, dic2, list);
            troll.evade.SetTroll(troll);
            //死亡状态机初始化
            troll.die = new State_Die_TypeA(dic1, dic2, list);
            troll.die.SetTroll(troll);
            //ai实体当前状态机初始化
            troll.nowState = troll.sleep;

            /*
             * 在这里,我们对ai体的决策树进行初始化
             *第一个值控制决策树的适应速度,值越大,速度越快,怪物越聪明,但不能大于1
             *第二个值反映决策完成后,决策的执行力度,0是做出相反的决定,1是彻底的按照决策执行,最好控制在0.6到0.8之间
             */
            troll.decisionTree = new DecisionTree(0.1f, 0.7f);
            troll.decisionTree.renewDecisionTree(1,
                                                 troll.trollAttribute.Hp);
            troll.warmWindows  = new DecisionTree.ControlWindows(27f, 0.2f, 0.2f, false);
            troll.deterWindows = new DecisionTree.ControlWindows(12f, 0.2f, 0.2f, true);

            /*
             *下面这个用于控制ai体退出当前状态,“new Dictionary<string, Dictionary<string, string>>()”中,第一个string
             *指当前的状态,在前面我们已经设置过了,如:State_Attack_TypeA,第二个值是退出时,动画播放到的state的tag属性,
             *第三个指需要转移的状态,分别有:sleep,attack,move,die,evade
             * temp是临时变量无须在意
             */
            troll.exitAniTag = new Dictionary <string, Dictionary <string, string> >();
            Dictionary <string, string> temp = new Dictionary <string, string>();

            //睡眠状态机状态转移初始化
            temp.Add("Idle", "move");
            troll.exitAniTag.Add("State_Sleep_TypeA", temp);
            //移动状态机状态转移初始化(包括追击和后移调整方向)
            Dictionary <string, string> temp1 = new Dictionary <string, string>();

            temp1.Add("AfterRun", "attack");
            troll.exitAniTag.Add("State_Move_TypeA", temp1);
            //攻击状态机状态转移初始化
            temp = new Dictionary <string, string>();
            temp.Add("AfterAttack", "move");
            temp.Add("this", "attack");
            troll.exitAniTag.Add("State_Attack_TypeA", temp);
            //紧急闪避状态机初始化
            temp = new Dictionary <string, string>();
            temp.Add("AfterAttack", "move");
            troll.exitAniTag.Add("State_Evade_TypeA", temp);
            //这里,我们开始组装各种特效和攻击的Trigger
            //
            //allAniNameToEffectsNumberDiactionary记录动画的名字和效果的索引号(在Unity中)
            //attackAniNameToTriggerDiactionary记录攻击动画的名称和它们对应的Trigger
            Dictionary <string, int> tempTrigger = new Dictionary <string, int>();
            //tempTrigger.Add("AttackGT1", 0);
            Dictionary <string, int> tempEffect = new Dictionary <string, int>();

            //tempEffect.Add("AttackGT1", 0);
            //tempEffect.Add("Run", 1);
            troll.allAniNameToEffectsNumberDiactionary = tempEffect;
            troll.attackAniNameToTriggerDiactionary    = tempTrigger;
            //在这里,我们规定攻击能够触及的角度
            //readAttackPointToAttackAngleDiactionary
            //用于声明Animator中的attackPoint范围
            //attackPointToAttackAngleDiactionary用于规定相对应的角度
            troll.readAttackPointToAttackAngleDiactionary = new int[] { 0, 30, 60, 9999 };
            Dictionary <int, int> tempAttack = new Dictionary <int, int>();

            tempAttack.Add(0, 35);
            tempAttack.Add(30, 60);
            tempAttack.Add(60, 25);
            troll.attackPointToAttackAngleDiactionary = tempAttack;
            //在这里,我们增强方法
            EnhanceTheFunction enhanceTheFunction = new EnhanceTheFunction(test);
            Dictionary <string, EnhanceTheFunction> tempEnhance = new Dictionary <string, EnhanceTheFunction>();

            tempEnhance.Add("Sleep", enhanceTheFunction);
            troll.allAniNameToEnhanceTheFunctionDiactionary = tempEnhance;

            //完成所有工作后,打开状态机
            troll.nowState.Enter();
        }
Exemple #29
0
 public void SetTroll(Troll troll)
 {
     this.troll           = troll;
     troll.afterScaredTag = exitAniTag[0];
 }
Exemple #30
0
        public Character GetEnemy(int id)
        {
            Character nextChar;

            switch (id)
            {
            //Low level
            case 100:
                nextChar = new Bat();
                return(nextChar);

            case 101:
                nextChar = new Rat();
                return(nextChar);

            case 102:
                nextChar = new Kobold();
                return(nextChar);

            case 103:
                nextChar = new Slime();
                return(nextChar);

            case 104:
                nextChar = new Farmer();
                return(nextChar);

            case 105:
                nextChar = new Imp();
                return(nextChar);

            case 106:
                nextChar = new Zombie();
                return(nextChar);

            case 107:
                nextChar = new Phantom();
                return(nextChar);

            case 108:
                nextChar = new Goblin();
                return(nextChar);

            case 109:
                nextChar = new Witch();
                return(nextChar);

            //Mid level
            case 110:
                nextChar = new Harpy();
                return(nextChar);

            case 111:
                nextChar = new Elemental();
                return(nextChar);

            case 112:
                nextChar = new Nymph();
                return(nextChar);

            case 113:
                nextChar = new Vampire();
                return(nextChar);

            case 114:
                nextChar = new Lamia();
                return(nextChar);

            case 115:
                nextChar = new Qilin();
                return(nextChar);

            case 116:
                nextChar = new Unicorn();
                return(nextChar);

            case 117:
                nextChar = new Jinn();
                return(nextChar);

            case 118:
                nextChar = new Xorn();
                return(nextChar);

            case 119:
                nextChar = new Antlion();
                return(nextChar);

            //High level
            case 120:
                nextChar = new Yeti();
                return(nextChar);

            case 121:
                nextChar = new Orc();
                return(nextChar);

            case 122:
                nextChar = new Minotaur();
                return(nextChar);

            case 123:
                nextChar = new Troll();
                return(nextChar);

            case 124:
                nextChar = new Cyclop();
                return(nextChar);

            case 125:
                nextChar = new Drake();
                return(nextChar);

            default:
                nextChar = new Slime();
                return(nextChar);
            }
        }
    public void SpawnCharacters()
    {
        for (int i = 0; i < 3; i++)
        {
            int choice = Random.Range(1, 7);

            if (choice == 1)
            {
                Character currentCharacter = new Warlock();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Warlock);
                Inventory AddPerso(Character Warlock);
            }
            if (choice == 2)
            {
                Character currentCharacter = new Archer();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Archer);
                Inventory AddPerso(Character Archer);
            }
            if (choice == 3)
            {
                Character currentCharacter = new Knight();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Knight);
                Inventory AddPerso(Character Knight);
            }
            if (choice == 4)
            {
                Character currentCharacter = new Goblin();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Goblin);
                Inventory AddPerso(Character Goblin);
            }
            if (choice == 5)
            {
                Character currentCharacter = new Orc();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Orc);
                Inventory AddPerso(Character Orc);
            }
            if (choice == 6)
            {
                Character currentCharacter = new Troll();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Troll);
                Inventory AddPerso(Character Troll);
            }
        }
    }