예제 #1
0
    private void Awake()
    {
        // Grab the Navigation Parameter
        NavigationParameter = NavigationManager.Instance.Parameter as LevelNavigationParameter;
        if (NavigationParameter == null)
        {
            NavigationParameter = new LevelNavigationParameter();
        }

        // Grab the Level
        Level = FindObjectOfType <LevelController>();
    }
    private void StartTimer_Completed(IClockTimer sender, TimeEventArgs e)
    {
        Debug.Log("Timer Complete");
        //var timer = sender as CountdownTimer;
        if (TimerUIText != null)
        {
            TimerUIText.text = "";
        }

        // Create the Navigation Parameter
        LevelNavigationParameter navigationParameter = new LevelNavigationParameter();

        // Save the Players to static cache for recreation ingame
        foreach (var panel in PlayerPanels)
        {
            if (panel.HasJoinedGame)
            {
                navigationParameter.PlayersInGame.Add(panel.PlayerInfo);
            }
        }

        // Get the level vote winner
        LobbyLevelSelectPanelController levelMostVotes = LevelSelectionPanels[0];

        foreach (var level in LevelSelectionPanels)
        {
            if (level.TotalVotes > levelMostVotes.TotalVotes)
            {
                levelMostVotes = level;
            }
        }

        // If Random was selected, set a random one
        if (string.IsNullOrEmpty(levelMostVotes.Level.SceneName) || levelMostVotes.Level.Name == "Random")
        {
            var index = Random.Range(1, LevelSelectionPanels.Count);
            levelMostVotes = LevelSelectionPanels[index];
        }

        // Set the Selected Level
        navigationParameter.SelectedLevel = levelMostVotes.Level;

        // Begin loading the map
        NavigationManager.Instance.Navigate(navigationParameter.SelectedLevel.SceneName, navigationParameter);
    }