Esempio n. 1
0
    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;
            }
        }
    }
Esempio n. 2
0
    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;
            }
        }
    }
Esempio n. 3
0
 public void Set(CharacterSoldier soldier)
 {
     holder = soldier;
 }