コード例 #1
0
        static void Main()
        {
            /*
             *  Iterator decorator example
             */
            Iterator naturals = new Naturals();
            Iterator evens    = new Evens(naturals);
            Iterator offset   = new Offset(evens, 10);

            Iterator naturalsEvensOffset =
                new Offset(new Evens(new Naturals()), 10);

            for (int i = 0; i < 5; i++)
            {
                Console.Write("{0}, ", offset.GetNext());
            }

            /*
             *  Monster decorator example
             */
            IMonster orc   = new Orc();
            IMonster troll = new Troll();

            IMonster wackyStrongOrc = new StrongMonster(new WackyMonster(troll));

            wackyStrongOrc.Greet();
        }
コード例 #2
0
        private static void Initialize(Engine engine)
        {
            // int startRow = 5;
            // int startCol = 5;

            Character playerKnight = new Knight("Goliath", "Bla bla bla", new MatrixCoords(RowIni(), ColIni()));
            Character creature1    = new Orc("Generic orc", new MatrixCoords(RowIni(), ColIni()));
            Character creature2    = new Ninja("Generic ninja", new MatrixCoords(RowIni(), ColIni()));
            Character creature3    = new Bat("Generic bat", new MatrixCoords(RowIni(), ColIni()));
            Character creature4    = new Rat("Generic rat", new MatrixCoords(RowIni(), ColIni()));

            //Character creature5 = new Boss("Bad boss", new MatrixCoords(RowIni(), ColIni()));

            engine.AddObject(playerKnight);
            engine.AddObject(creature1);
            engine.AddObject(creature2);
            engine.AddObject(creature3);
            engine.AddObject(creature4);

            //engine.AddObject(creature5);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            GoldenShield goldenShield = new GoldenShield("GoldenShield", 0, 25, "Escudo Protector", false);
            Sword        sword1       = new Sword("Katana", 50, 0, "Corte Fugaz", false);
            Orc          orc          = new Orc("Grom", sword1, goldenShield, "Tanque");
            Sword        sword2       = new Sword("Excalibur", 10, 0, "Corte Diagonal", false);

            orc.AttachSword(sword2);

            InvisibilityCloak invisibilityCloak = new InvisibilityCloak("Capa maxima", 0, 85, "Invisibilidad", false);
            Bow bow1 = new Bow("Arco gigante", 75, 5, "Tira fuego", false);
            Elf elf  = new Elf("Frank", bow1, invisibilityCloak, "Escurridizo");
            Bow bow2 = new Bow("Arco", 60, 5, "Automatico", false);

            elf.AttachBow(bow2);

            MagicStaff magicStaff = new MagicStaff("Varita", "Es mágica(?)", true);
            SpellBook  spellBook  = new SpellBook("Libro de Hechizos", "Tiene hechizos(?)", true);
            Wizard     wizard     = new Wizard("Harry", magicStaff, spellBook, "Support");
            Spell      spell      = new Spell("Lumos", "La varita enciende luz", true);

            wizard.LearnSpell(spell);

            Axe       axe1      = new Axe("El ejecutor", 65, 5, "Hacha giratoria", false);
            Axe       axe2      = new Axe("Verdugo", 70, 0, "Juicio final", false);
            Warhammer warhammer = new Warhammer("Mjölnir", 90, 10, "Aplastar y machacar", false);
            Dwarf     dwarf     = new Dwarf("Thorin", axe1, warhammer, "Luchador");

            dwarf.AttachAxe(axe2);

            wizard.Attack(orc);
            orc.Attack(dwarf);
            wizard.HealOrc(orc);
            dwarf.Attack(orc);
            dwarf.HealWizard(wizard);
            elf.Attack(orc);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Shield shield = new Shield("Golden Shield", 75, "Escudo Protector");
            Sword  sword  = new Sword("Katana", 125, "Corte Fugaz");

            Orc orc = new Orc("Grom", 25, "Tanque");

            orc.Equip(sword);
            orc.Equip(shield);


            Axe       axe       = new Axe("Verdugo", 70, "Juicio final");
            Warhammer warhammer = new Warhammer("Mjölnir", 90, "Aplastar y machacar");

            Dwarf dwarf = new Dwarf("Thorin", 35, "Luchador");

            dwarf.Equip(axe);
            dwarf.Equip(warhammer);

            Bow   bow   = new Bow("Arco gigante", 75, "Tira fuego");
            Cloak cloak = new Cloak("Capa maxima", 85, "Invisibilidad");

            Elf elf = new Elf("Galardiel", 15, "Escurridizo");

            elf.Equip(bow);
            elf.Equip(cloak);

            SpellBook  spellBook  = new SpellBook("Libro de Hechizos Oscuros", "Hechizos oscuros");
            Spell      spell      = new Spell("Lumos", "La varita enciende luz", 65, 0);
            MagicStaff magicStaff = new MagicStaff("Baculo Oscuro", 150, "Baculo perdido de Toran");

            Wizard wizard = new Wizard("Harry", "Mago De Apoyo", spellBook);

            dwarf.Attack(orc);
            Console.WriteLine("👳 " + dwarf.Name + " cura a 🤢 " + orc.Name);
            dwarf.HealCharacter(orc);
            Console.WriteLine();

            orc.Attack(wizard);
            wizard.Respawn();
            Console.WriteLine(wizard.Name + " ha respawneado");
            Console.WriteLine("La vida actual de 🧙 " + wizard.Name + " ahora es: " + wizard.Health + " ❤");
            Console.WriteLine();

            elf.UnEquip(bow);
            elf.Equip(sword);
            Console.WriteLine("El daño total que causa 🧝‍♀️ " + elf.Name + " es: " + elf.TotalDamage() + " 🗡");
            Console.WriteLine("La protección total de 🧝‍♀️ " + elf.Name + " es: " + elf.TotalProtection() + " 🛡");
            Console.WriteLine();

            orc.UnEquip(sword);
            orc.Equip(axe);
            Console.WriteLine("El daño total que causa 🤢 " + orc.Name + " es: " + orc.TotalDamage() + " 🗡");
            Console.WriteLine("La protección total de 🤢 " + orc.Name + " es: " + orc.TotalProtection() + " 🛡");
            Console.WriteLine();

            dwarf.UnEquip(axe);
            dwarf.Equip(shield);
            Console.WriteLine("El daño total que causa 👳 " + dwarf.Name + " es: " + dwarf.TotalDamage() + " 🗡");
            Console.WriteLine("La protección total de 👳 " + dwarf.Name + " es: " + dwarf.TotalProtection() + " 🛡");
            Console.WriteLine();

            wizard.Equip(magicStaff);
            wizard.Equip(spellBook);
            wizard.LearnSpell(spell);
            Console.WriteLine();

            Console.WriteLine("El daño total que causa 🧙 " + wizard.Name + " es: " + wizard.TotalDamage() + " 🗡");
            Console.WriteLine("La protección total de 🧙 " + wizard.Name + " es: " + wizard.TotalProtection() + " 🛡");
            Console.WriteLine();

            wizard.UnEquip(magicStaff);
            Console.WriteLine();
            wizard.Equip(sword);
            wizard.Equip(shield);
            Console.WriteLine("Se añadieron los items: " + sword.Name + " y " + shield.Name + " al inventario de " + wizard.Name);
            Console.WriteLine("El daño total que causa 🧙 " + wizard.Name + " ahora es: " + wizard.TotalDamage() + " 🗡");
            Console.WriteLine("La protección total de 🧙 " + wizard.Name + " ahora es: " + wizard.TotalProtection() + " 🛡");
        }