コード例 #1
0
        static void Main(string[] args)
        {
            // METHOD CHAIN
            var goblin = new Creature("Goblin", 2, 2);

            Console.WriteLine(goblin);

            var root = new CreatureModifier(goblin);

            root.Add(new NoBonusesModifier(goblin));

            Console.WriteLine("Let's double goblin's attack...");

            root.Add(new DoubleAttackModifier(goblin));

            Console.WriteLine("Let's increase goblin's defense");

            root.Add(new IncreaseDefenseModifier(goblin));

            // eventually...
            root.Handle();

            Console.WriteLine(goblin);

            // BROKER CHAIN
            var game     = new Game();
            var goblinBc = new CreatureBC(game, "Strong Goblin", 3, 3);

            Console.WriteLine(goblinBc);

            using (new DoubleAttackModifierBC(game, goblinBc))
            {
                Console.WriteLine(goblinBc);

                using (new IncreaseDefenseModifierBC(game, goblinBc))
                {
                    Console.WriteLine(goblinBc);
                }
            }

            Console.WriteLine(goblinBc);

            Console.ReadLine();
        }
 public DoubleAttackModifierBC(Game game, CreatureBC creature) : base(game, creature)
 {
 }
コード例 #3
0
 public IncreaseDefenseModifierBC(Game game, CreatureBC creature) : base(game, creature)
 {
 }