示例#1
0
 public bool StartLevel()
 {
     StartingLevel     = true;
     StartingLevelTime = Network.time;
     OnLevelStartInitiatedEvent.Fire();
     return(AttemptToStartLevel());
 }
示例#2
0
 public void StartLobby()
 {
     CurrentLevelId++;
     ModeTimeOffset = 0;
     IsInLobby      = true;
     foreach (var player in ValidPlayers)
     {
         player.Car       = null;
         player.Countdown = -1.0;
     }
     SendAllPlayersToLobby();
     OnLobbyStartedEvent.Fire();
 }
示例#3
0
 public void Update()
 {
     ModeTime = Network.time + ModeTimeOffset;
     PrivateUtilities.setPrivateProperty(typeof(Distance::Timex), null, "ModeTime_", ModeTime);
     OnUpdateEvent.Fire();
     if (StartingLevel)
     {
         AttemptToStartLevel();
     }
     else if (StartingMode && StartingModeTime != -1.0 && Network.time - StartingModeTime >= StartingModeTimeout && !StartingModeDelay)
     {
         AttemptToStartMode();
     }
 }
示例#4
0
 public void NextLevel()
 {
     OnAdvancingToNextLevel.Fire();
     if (OverridePlaylist.Count > 0)
     {
         Server.CurrentLevel = OverridePlaylist[0];
         OverridePlaylist.RemoveAt(0);
     }
     else
     {
         currentLevelIndex++;
         if (currentLevelIndex >= Playlist.Count)
         {
             currentLevelIndex = 0;
         }
         Server.CurrentLevel = Playlist[currentLevelIndex];
     }
     StartLevel();
 }
示例#5
0
 public bool AttemptToStartLevel()
 {
     if (StartingLevelTime == -1.0 || Network.time - StartingLevelTime < StartingLevelTimeout)
     {
         // Wait for any loading players to stop loading
         foreach (var player in ValidPlayers)
         {
             if (!player.Stuck && player.IsLoading())
             {
                 return(false);
             }
         }
     }
     else
     {
         foreach (var player in ValidPlayers)
         {
             if (player.IsLoading())
             {
                 player.Stuck = true;
             }
         }
     }
     StartingLevel  = false;
     IsInLobby      = false;
     HasModeStarted = false;
     foreach (var player in ValidPlayers)
     {
         player.Car       = null;
         player.Countdown = -1.0;
     }
     StartingMode     = true;
     StartingModeTime = Network.time;
     SendAllPlayersToLevel();
     OnLevelStartedEvent.Fire();
     if (ValidPlayers.Count == 0)
     {
         AttemptToStartMode();
     }
     return(true);
 }
示例#6
0
    public System.Collections.IEnumerator StartModeAfterDelay(float delayTime)
    {
        StartingMode      = false;
        StartingModeDelay = false;

        foreach (var player in ValidPlayers)
        {
            if (!player.HasLoadedLevel(true))
            {
                player.Stuck = true;
            }
        }
        foreach (var player in ValidPlayers)
        {
            if (!player.Stuck && player.State == DistancePlayer.PlayerState.SubmittedGameModeInfo)
            {
                player.State = DistancePlayer.PlayerState.StartedMode;
            }
        }

        ModeStartTime  = Network.time + 7.0 + delayTime; // Shift start sooner/later
        ModeTimeOffset = -ModeStartTime;
        ModeTime       = 0.0;
        HasModeStarted = true;

        yield return(new WaitForSeconds(delayTime));

        foreach (var player in ValidPlayers)
        {
            if (player.State == DistancePlayer.PlayerState.StartedMode)
            {
                DistanceServerMain.GetEvent <Events.ServerToClient.StartMode>().Fire(
                    player.UnityPlayer,
                    new Distance::Events.ServerToClient.StartMode.Data(ModeStartTime, false)
                    );
            }
        }
        OnModeStartedEvent.Fire();
    }
示例#7
0
 public void OnServerInitialized()
 {
     Log.WriteLine("Started server");
     DoReportToMasterServer();
     OnServerInitializedEvent.Fire();
 }