private static PokemonModel CreateModel(Pokemon.PokemonType type)
        {
            switch (type)
            {
                case Pokemon.PokemonType.Bulbasaur:
                    return Bulbasaur.GetInstance();

                case Pokemon.PokemonType.Charmander:
                    return Charmander.GetInstance();

                case Pokemon.PokemonType.Squirtle:
                    return Squirtle.GetInstance();

                case Pokemon.PokemonType.Pikachu:
                    return Pikachu.GetInstance();

                case Pokemon.PokemonType.Slowpoke:
                    return Slowpoke.GetInstance();

                case Pokemon.PokemonType.Diglett:
                    return Diglett.GetInstance();

                default:
                    return null;
            }
        }
示例#2
0
 public override void Execute(Drawing drawing)
 {
     oldPokemon = drawing.SelectedPokemon;
     if (pokemon != null)
     {
         drawing.SelectedPokemon = drawing.PokemonList[pokemon.ID];
         base.Execute(drawing);
     }
     else
         drawing.SelectedPokemon = null;
 }
        public static PokemonModel Create(Pokemon.PokemonType type)
        {
            lock(myLock)
            {
                if (pokemon == null)
                {
                    pokemon = new Dictionary<Pokemon.PokemonType, PokemonModel>();
                }
            }

            if (pokemon.Keys.Contains(type))
                return pokemon[type];

            pokemon.Add(type, CreateModel(type));
            return pokemon[type];
        }
示例#4
0
        public void PokemonFactoryCreate()
        {
            Pokemon expected = new Pokemon()
            {
                Type = Pokemon.PokemonType.Bulbasaur,
                Location = new Point(15, 15),
                Model = PokemonModelFactory.Create(Pokemon.PokemonType.Bulbasaur),
                Size = new Size(40, 40),
                ID = 0
            };
            Pokemon actual = PokemonFactory.Create(Pokemon.PokemonType.Bulbasaur, new Point(15, 15));

            Assert.AreEqual(expected.Type, actual.Type);
            Assert.AreEqual(expected.Location, actual.Location);
            Assert.AreSame(expected.Model, actual.Model);
            Assert.AreEqual(expected.Size, actual.Size);
        }
示例#5
0
 public static Command Create(CommandType type, Pokemon pokemon)
 {
     switch (type)
     {
         case CommandType.Create:
             return new CreateCommand() { pokemon = pokemon };
         case CommandType.Delete:
             return new DeleteCommand() { pokemon = pokemon };
         case CommandType.Move:
             return new MoveCommand() { pokemon = pokemon };
         case CommandType.Select:
             return new SelectCommand() { pokemon = pokemon };
         case CommandType.Shrink:
             return new ShrinkCommand() { pokemon = pokemon };
         case CommandType.Grow:
             return new GrowCommand() { pokemon = pokemon };
         case CommandType.Duplicate:
             return new DuplicateCommand() { pokemon = pokemon };
         default:
             return null;
     }
 }
示例#6
0
 public static Pokemon Create(Pokemon other)
 {
     if (other == null)
         return null;
     return new Pokemon { Location = other.Location, Size = other.Size, Model = other.Model, ID = count++, Type = other.Type };
 }
示例#7
0
 public static Pokemon Create(Pokemon.PokemonType type, Point location)
 {
     return new Pokemon { Location = location, Size = defaultSize, Model = PokemonModelFactory.Create(type), ID = count++, Type = type };
 }
示例#8
0
 public static Pokemon Copy(Pokemon other)
 {
     if (other == null)
         return null;
     return new Pokemon { Location = other.Location, Size = other.Size, Model = other.Model, ID = other.ID, Type = other.Type };
 }
示例#9
0
        public void PokemonFactoryCreateNull()
        {
            Pokemon expected = new Pokemon()
            {
                Type = Pokemon.PokemonType.Bulbasaur,
                Location = new Point(15, 15),
                Model = PokemonModelFactory.Create(Pokemon.PokemonType.Bulbasaur),
                Size = new Size(40, 40),
                ID = 0
            };
            Pokemon actual3 = PokemonFactory.Create(null);

            Assert.IsNull(actual3);
        }