示例#1
0
        public static IBombCreator GetBombCreator(string strategy, string type)
        {
            IBombCreator bombCreator = null;

            if (bombDictionary.ContainsKey(strategy + type))
            {
                bombCreator = bombDictionary[strategy + type];
            }
            else
            {
                BombStrategy bombStrategy = null;
                switch (strategy)
                {
                case "double": bombStrategy = new DoubleExplosion(); break;

                case "horizontal": bombStrategy = new HorizontalExplosion(); break;

                case "mine": bombStrategy = new MineExplosion(); break;

                case "vertical": bombStrategy = new VerticalExplosion(); break;
                }
                switch (type)
                {
                case "player": bombCreator = new SimplePlayerBomb(bombStrategy); break;

                case "enemy": bombCreator = new SimpleEnemyBomb(bombStrategy); break;
                }
                bombDictionary.Add(strategy + type, bombCreator);
            }
            return(bombCreator);
        }
示例#2
0
 public SimpleEnemyBomb(BombStrategy strategy)
 {
     bombColor = strategy.Explode();
 }
示例#3
0
 public SimplePlayerBomb(BombStrategy strategy)
 {
     bombColor = strategy.Explode();
 }