Пример #1
0
    // A function to get a random spawn point.
    public Transform GetRandomSpawnPoint()
    {
        // Getting random mech station.
        randNumber = Random.Range(0, mechRespawnStations.Count);
        Mech_Recovery randomSpawnPoint = mechRespawnStations[randNumber];

        // Checking if it is occupied.
        if (!randomSpawnPoint.IsOccupied)
        {
            randomSpawnPoint.IsOccupied = true;
            return(randomSpawnPoint.transform);
        }

        // Recursively searching for an avaliable mech station.
        return(GetRandomSpawnPoint());
    }
Пример #2
0
    // A function to respawn the player at a random respawn staion.
    public void RandomSpawn_FromDeath()
    {
        // Setting player to death incase they get here and they're not.
        if (isAlive)
        {
            isAlive = false;
        }

        // Turning off the players controls:
        isControllable = false;

        // Remembers the Mech Station/ Respawn point that the player will spawn at
        if (station == null)
        {
            station = RespawnArray.instance.GetRandomSpawnPoint().GetComponent <Mech_Recovery>();
        }

        // Enabling the respawn timer UI:
        respawnTimerUI.SetActive(true);

        // Starting the respawn timer:
        if (ReadyToRespawn())
        {
            // Disabling the respawn timer UI:
            respawnTimerUI.SetActive(false);

            // Spawning in the player:
            station.SpawnPlayer(this);

            // Enabling the players controls:
            if (!isTestDummy)
            {
                isControllable = true;
            }

            // Turning on invulnerablity:
            isInvulnerable = true;
        }
    }
Пример #3
0
 public void RandomSpawn_Unactive()
 {
     // Spawning in the player.
     station = RespawnArray.instance.GetRandomSpawnPoint().GetComponent <Mech_Recovery>();
     station.SpawnPlayer(this);
 }