public void CheckForWinner() { var winner = players.Find((x) => x.Points >= settings.pointsToWin); if (winner != null) { winner.YouWin(); players.FindAll((x) => x != winner).ForEach((x) => x.YouLose()); fsm.AdvanceTo(new GameManagerBattleOverState(fsm, winner)); } }
void Start() { var levelConfigs = FindObjectOfType <LevelConfigs>(); int playerCount = levelConfigs == null? defaultPlayerCount : levelConfigs.playerCount; settings.pointsToWin = levelConfigs == null? settings.pointsToWin : levelConfigs.PointsToWin; Debug.Assert(playerPrefabs.Length >= playerCount); fsm = new GameManagerFSM(this); fsm.AdvanceTo(new GameManagerStartState(fsm)); players = new List <Player>(); CameraRig.m_Targets = new Transform[playerCount]; for (int i = 0; i < playerPrefabs.Length && i < playerCount; i++) { players.Add(GameObject.Instantiate(playerPrefabs[i]).GetComponent <Player>()); players[i].OnDie += Player_OnDie; CameraRig.m_Targets[i] = players[i].transform; } }