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; } }
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]; }
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); }
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; } }
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 }; }
public static Pokemon Create(Pokemon.PokemonType type, Point location) { return new Pokemon { Location = location, Size = defaultSize, Model = PokemonModelFactory.Create(type), ID = count++, Type = type }; }
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 }; }
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); }