static void Main(string[] args) { Factory[] factories = new Factory[2]; factories[0] = new ConcreteFactoryA(); factories[1] = new ConcreteFactoryB(); foreach (Factory item in factories) { Product product = item.CreateProduct(); Console.WriteLine("Created {0}", product.GetType().Name); } //练习 // 定义一个鸡腿工厂 IKFCFactory factory = new ChickenFactory(); // 生产鸡腿 KFCFood food1 = factory.CreateFood(); food1.Display(); // 生产鸡腿 KFCFood food2 = factory.CreateFood(); food2.Display(); // 生产鸡腿 KFCFood food3 = factory.CreateFood(); food3.Display(); Console.ReadKey(); }
static void Main(string[] args) { #region 结构实现 Factory[] factories = new Factory[2]; factories[0] = new ConcreteFactoryA(); factories[1] = new ConcreteFactoryB(); foreach (Factory factory in factories) { Product product = factory.CreateProduct(); Console.WriteLine("Created {0}", product.GetType().Name); } #endregion Console.WriteLine("******************************"); #region 实践应用 // 定义一个鸡腿工厂 IKFCFactory kfcFactory = new ChickenFactory(); // 生产鸡腿 KFCFood food1 = kfcFactory.CreateFood(); food1.Display(); kfcFactory = new WingsFactory(); // 生产鸡翅 KFCFood food2 = kfcFactory.CreateFood(); food2.Display(); #endregion Console.ReadKey(); }
private void populate() { MovingEntityFactory chickenFactory = new ChickenFactory(); movingEntities.AddRange(chickenFactory.GetMovingEntities(200)); Target = new Vehicle(new Vector2D(100, 60)) { VColor = Color.DarkRed, Pos = new Vector2D(100, 40) }; }
// Use this for initialization void Start() { //spawn players GameObject enemy = ChickenFactory.createChicken(new Vector3(-5, 2, 0), ChickenTeam.Red, 0f); GameObject player = ChickenFactory.createPlayerChicken(new Vector3(5, 2, 0), ChickenTeam.Blue); ChickenControlBehavior playerChickenBehavior = player.GetComponent <ChickenControlBehavior> (); playerChickenBehavior.setTarget(enemy); enemy.GetComponent <ChickenControlBehavior> ().setTarget(player); // Disable enemy attack AI. enemy.GetComponent <ChickenAttackAIBehavior>().enabled = false; }
/// <summary> /// Starts the game off! /// Spawns all players appropriately /// </summary> void startGame() { GameState.getInstance().setGameModeBeingPlayed(this); Team currentTeamSpawning = Team.One; bool spawningTeams = true; while (spawningTeams) { ChickenTeam chickenTeam = ChickenTeam.Blue; if (currentTeamSpawning == Team.Two) { chickenTeam = ChickenTeam.Red; } for (int teamMemberIndex = 0; teamMemberIndex < teamSize; teamMemberIndex++) { for (int i = 0; i < spawnPoints.Length; i++) { if (spawnPoints[i].priority == teamMemberIndex && spawnPoints[i].teamAtStart == currentTeamSpawning) { //Spawn the players as the first chicken on the first team if (currentTeamSpawning == Team.One && teamMemberIndex == 0 && !AIOnly) { ChickenFactory.createPlayerChicken(spawnPoints[i].point.transform.position, chickenTeam); } else //Spawn a computer player { ChickenFactory.createChicken(spawnPoints[i].point.transform.position, chickenTeam, Random.Range(0f, 1f)); } } } } //Breaks us from the while loop if we've spawned both teams if (currentTeamSpawning == Team.One) { currentTeamSpawning = Team.Two; } else { spawningTeams = false; } } }
/// <summary> /// Used to transition to the dead state. /// </summary> void enterDeadState() { currentState = ChickenState.Dead; GameState.getInstance().removeCharacter(this); timeOfDeath = Time.time; SpecialEffectsFactory.createEffect(transform.position, SpecialEffectType.ChickenDeath); if (gameObject.GetComponent <PhotonView> () != null) { ChickenFactory.createNetworkPlayerChicken(new Vector3(0, 1, 0), ChickenTeam.None); PhotonNetwork.Destroy(gameObject); } }
public void onLivingThingDeath(ChickenControlBehavior chicken) { Vector3 spawnLocation = spawnPoints [Random.Range(0, spawnPoints.Length)].point.transform.position; if (chicken.getChickensTeam() == ChickenTeam.Blue) { teamTwoPoints++; } else { teamOnePoints++; } if (chicken.gameObject.GetComponent <PlayerBehavior> () != null) { ChickenFactory.createPlayerChicken(spawnLocation, chicken.getChickensTeam()); } else { ChickenFactory.createChicken(spawnLocation, chicken.getChickensTeam(), 0); } }