/// <summary> /// Multiply the number of goals for any team that aren't the team that triggered this power-up /// </summary> /// <param name="team">The team that triggered this power-up.</param> public void MultiGoal(PongTeam team) { // At first we destroy each temporary goal foreach (var goal in goals) { if (goal.tempGoal) { Destroy(goal); } } // We create a temporary goal at the top if there's no permanent goal already there. if (!goals.Exists(x => x.side == Side.Top)) { var topGoal = GameObject.Instantiate(_goalPrefab); topGoal.Init(OpposingTeam(team).PickRandom(), _startingRatio, Side.Top, true); if (_powerUpSettings.multiGoalTime > 0) { Destroy(topGoal.gameObject, _powerUpSettings.multiGoalTime); } } // We create a temporary goal at the bottom if there's no permanent goal already there. if (!goals.Exists(x => x.side == Side.Bottom)) { var bottomGoal = GameObject.Instantiate(_goalPrefab); bottomGoal.Init(OpposingTeam(team).PickRandom(), _startingRatio, Side.Bottom, true); if (_powerUpSettings.multiGoalTime > 0) { Destroy(bottomGoal.gameObject, _powerUpSettings.multiGoalTime); } } }
void InitSetUp() { ClearAll(); var team1 = new PongTeam("Team 1", Color.red); var team2 = new PongTeam("Team 2", Color.green); pongTeams.Add(team1); pongTeams.Add(team2); }
/// <summary> /// Init the values of the pong goal /// </summary> public void Init(PongTeam team, float ratio, Side side, bool tempGoal = false) { this.GetComponent <SpriteRenderer> ().color = team.color; SetGoalSide(side); this.team = team; this.side = side; this._ratio = ratio; this.tempGoal = tempGoal; ResizeSprite(ratio); }
IEnumerator TimedGoalSizeDecrease(float multiplicator, PongTeam team) { foreach (var goal in goals) { if (goal.team == team) { goal.ratio = goal.ratio / multiplicator; } } if (_powerUpSettings.goalDecreaseTime > 0.0f) { yield return(new WaitForSeconds(_powerUpSettings.goalIncreaseTime)); foreach (var goal in goals) { if (goal.team == team) { goal.ratio = goal.ratio * multiplicator; } } } }
/// <summary> /// Returns all teams that are not the given team /// </summary> /// <returns>The team.</returns> /// <param name="team">All of the other teams.</param> public List <PongTeam> OpposingTeam(PongTeam team) { return(pongTeams.FindAll(x => x != team)); }
/// <summary> /// Decrease the size of the goal of the team that triggered this power-up. /// </summary> /// <param name="multiplicator">Multiplicator.</param> /// <param name="team">The team that triggered this power up.</param> public void DecreaseGoalSize(float multiplicator, PongTeam team) { StartCoroutine(TimedGoalSizeDecrease(multiplicator, team)); }