/// <summary> /// Creates the player chicken. /// </summary> /// <returns>The player chicken.</returns> /// <param name="position">Location where you want the chicken to spawn.</param> /// <param name="team">The team the player will be fighting for.</param> public static GameObject createPlayerChicken(Vector3 position, ChickenTeam team) { GameObject chickenGameObject = Resources.Load("Chicken/Player") as GameObject; chickenGameObject = (GameObject)Object.Instantiate (chickenGameObject, position, Quaternion.identity); chickenGameObject.GetComponent<ChickenControlBehavior> ().setChickensTeam (team); GameState.getInstance ().addCharacter (chickenGameObject.GetComponent<ChickenControlBehavior> ()); return chickenGameObject; }
/// <summary> /// Creates the player chicken. /// </summary> /// <returns>The player chicken.</returns> /// <param name="position">Location where you want the chicken to spawn.</param> /// <param name="team">The team the player will be fighting for.</param> public static GameObject createPlayerChicken(Vector3 position, ChickenTeam team) { GameObject chickenGameObject = Resources.Load("Chicken/Player") as GameObject; chickenGameObject = (GameObject)Object.Instantiate(chickenGameObject, position, Quaternion.identity); chickenGameObject.GetComponent <ChickenControlBehavior> ().setChickensTeam(team); GameState.getInstance().addCharacter(chickenGameObject.GetComponent <ChickenControlBehavior> ()); return(chickenGameObject); }
/// <summary> /// Based on all characters in the game state, we return those that are not on /// the team that is specified /// </summary> /// <returns>The all characters not on team.</returns> /// <param name="teamTheirNotOn">Team their not on.</param> public ChickenControlBehavior[] getAllCharactersNotOnTeam(ChickenTeam teamTheirNotOn) { List<ChickenControlBehavior> charactersNotOnTeam = new List<ChickenControlBehavior>(); foreach (ChickenControlBehavior character in charactersInScene) { if(character.getChickensTeam() != teamTheirNotOn){ charactersNotOnTeam.Add(character); } } return charactersNotOnTeam.ToArray(); }
/// <summary> /// Creates a chicken in the scene. /// </summary> /// <returns>The chicken.</returns> /// <param name="position">Location where you want the chicken to spawn.</param> /// <param name="team">Team.</param> /// <param name="skillLevel">How skilled the chicken is on a scale from 0 to 1</param> public static GameObject createChicken(Vector3 position, ChickenTeam team, float skillLevel) { skillLevel = Mathf.Clamp (skillLevel, 0f, 1f); GameObject chickenGameObject = Resources.Load("Chicken/Standard Chicken") as GameObject; chickenGameObject = (GameObject)Object.Instantiate (chickenGameObject, position, Quaternion.identity); chickenGameObject.GetComponent<ChickenControlBehavior> ().setChickensTeam (team); GameState.getInstance ().addCharacter (chickenGameObject.GetComponent<ChickenControlBehavior> ()); return chickenGameObject; }
/// <summary> /// Based on all characters in the game state, we return those that are not on /// the team that is specified /// </summary> /// <returns>The all characters not on team.</returns> /// <param name="teamTheirNotOn">Team their not on.</param> public ChickenControlBehavior[] getAllCharactersNotOnTeam(ChickenTeam teamTheirNotOn) { List <ChickenControlBehavior> charactersNotOnTeam = new List <ChickenControlBehavior>(); foreach (ChickenControlBehavior character in charactersInScene) { if (character.getChickensTeam() != teamTheirNotOn) { charactersNotOnTeam.Add(character); } } return(charactersNotOnTeam.ToArray()); }
/// <summary> /// Creates the player chicken. /// Meant for only play. Set up for Networking. /// </summary> /// <returns>The player chicken.</returns> /// <param name="position">Location where you want the chicken to spawn.</param> /// <param name="team">The team the player will be fighting for.</param> public static GameObject createNetworkPlayerChicken(Vector3 position, ChickenTeam team) { GameObject chicken = PhotonNetwork.Instantiate("Chicken/NetworkingPlayer", Vector3.up, Quaternion.identity, 0); chicken.GetComponent<PlayerBehavior>().enabled = true; chicken.GetComponent<ChickenControlBehavior> ().setChickensTeam (team); chicken.transform.FindChild ("Main Camera").GetComponent<Camera>().enabled = true; chicken.transform.FindChild ("Main Camera").GetComponent<AudioListener>().enabled = true; GameState.getInstance ().addCharacter (chicken.GetComponent<ChickenControlBehavior> ()); return chicken; }
/// <summary> /// Creates the player chicken. /// Meant for only play. Set up for Networking. /// </summary> /// <returns>The player chicken.</returns> /// <param name="position">Location where you want the chicken to spawn.</param> /// <param name="team">The team the player will be fighting for.</param> public static GameObject createNetworkPlayerChicken(Vector3 position, ChickenTeam team) { GameObject chicken = PhotonNetwork.Instantiate("Chicken/NetworkingPlayer", Vector3.up, Quaternion.identity, 0); chicken.GetComponent <PlayerBehavior>().enabled = true; chicken.GetComponent <ChickenControlBehavior> ().setChickensTeam(team); chicken.transform.FindChild("Main Camera").GetComponent <Camera>().enabled = true; chicken.transform.FindChild("Main Camera").GetComponent <AudioListener>().enabled = true; GameState.getInstance().addCharacter(chicken.GetComponent <ChickenControlBehavior> ()); return(chicken); }
/// <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> /// Creates a chicken in the scene. /// </summary> /// <returns>The chicken.</returns> /// <param name="position">Location where you want the chicken to spawn.</param> /// <param name="team">Team.</param> /// <param name="skillLevel">How skilled the chicken is on a scale from 0 to 1</param> /// public static GameObject createChicken(Vector3 position, ChickenTeam team, float skillLevel) { skillLevel = Mathf.Clamp(skillLevel, 0f, 1f); GameObject chickenGameObject = Resources.Load("Chicken/Standard Chicken") as GameObject; chickenGameObject = (GameObject)Object.Instantiate(chickenGameObject, position, Quaternion.identity); chickenGameObject.GetComponent <ChickenControlBehavior> ().setChickensTeam(team); GameState.getInstance().addCharacter(chickenGameObject.GetComponent <ChickenControlBehavior> ()); ///Add code to spawn text related to chicken. List <string> names = new List <string>(); return(chickenGameObject); }
/// <summary> /// The Update function that is called when the chicken is dead. /// </summary> void deadUpdate() { if (currentState != ChickenState.Dead) { return; } print("You are dead!!!"); speed = 0; jumpSpeed = 0; team = ChickenTeam.Dead; transform.FindChild("graphics").GetComponent <MeshRenderer> ().material.color = Color.green; if (Time.time - timeOfDeath > 1f) { Destroy(gameObject); } }
/// <summary> /// Changes what team the chicken is currentely on. /// </summary> /// <param name="team">Team.</param> public void setChickensTeam(ChickenTeam team) { this.team = team; }
/// <summary> /// The Update function that is called when the chicken is dead. /// </summary> void deadUpdate() { if (currentState != ChickenState.Dead) { return; } print ("You are dead!!!"); speed = 0; jumpSpeed = 0; team = ChickenTeam.Dead; transform.FindChild ("graphics").GetComponent<MeshRenderer> ().material.color = Color.green; if(Time.time - timeOfDeath > 1f){ Destroy(gameObject); } }