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

            var root = new CreatureModifier(goblin);

            root.Add(new NoBonusesModifier(goblin));

            WriteLine("Lets double attack");
            root.Add(new DoubleAttackModifier(goblin));
            WriteLine("Lets Increase defense");
            root.Add(new IncreaseDefenseModifier(goblin));

            root.Handle();

            WriteLine(goblin);

            var game    = new Game();
            var goblin2 = new Creature2(game, "Strong Goblin", 3, 3);

            WriteLine(goblin2);

            using (new DoubleAttackModifier2(game, goblin2))
            {
                WriteLine(goblin2);
                using (new IncreaseDefenseModifier2(game, goblin2))
                {
                    WriteLine(goblin2);
                }
            }

            WriteLine(goblin2);
        }
コード例 #2
0
 public DoubleAttackModifier2(Game game, Creature2 creature2) : base(game, creature2)
 {
 }
コード例 #3
0
 public IncreaseDefenseModifier2(Game game, Creature2 creature2) : base(game, creature2)
 {
 }
コード例 #4
0
 protected CreatureModifier2(Game game, Creature2 creature2)
 {
     this.game      = game;
     this.creature2 = creature2;
     game.Queries  += Handle;
 }