public static void NotifyOfSoldierDeath(CharacterSoldier soldier) { soldier.playerInstance.soldiers.Remove(soldier); if (soldier.playerInstance.soldiers.Count == 0) { soldier.playerInstance.dead = true; int numberOfDeadPlayers = 0; foreach (PlayerInstance player in Instance.players) { if (player.dead) { numberOfDeadPlayers++; } else { Instance.playerThatWon = player; } } if (numberOfDeadPlayers >= levelSetupInfo.numberOfPlayers - 1) { Instance.LevelFinish(); } else { Instance.playerThatWon = null; } } }
protected override void SingletonAwake() { if (levelSetupInfo == null) { levelSetupInfo = LevelSetupInfo.DefaultLevelSetupInfo(); } soldierSpawnPoints = FindObjectsOfType <SpawnPoint>().ToList(); for (int i = 0; i < levelSetupInfo.numberOfPlayers; i++) { PlayerInstance player = new PlayerInstance(i, Database.PlayerInfos[i], Database.WeaponInformations.Clone()); if (levelSetupInfo.infiniteAmmo) { foreach (WeaponInformation w in player.weaponInformations.weapons) { w.usagesForStart = 999; } } players.Add(player); for (int j = 0; j < levelSetupInfo.numberOfCharacters; j++) { int randomSpawnPointNumber = Random.Range(0, soldierSpawnPoints.Count); CharacterSoldier soldier = Instantiate(characterSoldierPrefab, soldierSpawnPoints[randomSpawnPointNumber].transform.position, soldierSpawnPoints[randomSpawnPointNumber].transform.rotation).GetComponent <CharacterSoldier>(); soldier.transform.SetParent(charactersParent); soldierSpawnPoints.RemoveAt(randomSpawnPointNumber); player.soldiers.Add(soldier); soldier.playerInstance = player; } } }
public void Set(CharacterSoldier soldier) { holder = soldier; }