private void PrepareNPlayerLayout()
    {
        nPlayerLayout.GetComponentsInChildren <SingingResultsPlayerUiController>().ForEach(it => it.gameObject.SetActive(false));
        GameObjectUtils.DestroyAllDirectChildren(nPlayerLayout.transform);
        for (int i = 0; i < sceneData.PlayerProfiles.Count; i++)
        {
            Instantiate(singingResultsPlayerUiControllerPrefab, nPlayerLayout.transform);
        }

        PlayerUiArea.SetupPlayerUiGrid(sceneData.PlayerProfiles.Count, nPlayerLayout.GetComponent <GridLayoutGroupCellSizer>());
    }
Example #2
0
    public void Init(SongMeta songMeta, PlayerProfile playerProfile, string voiceIdentifier)
    {
        this.SongMeta      = songMeta;
        this.PlayerProfile = playerProfile;

        Voice = LoadVoice(songMeta, voiceIdentifier);

        playerUiArea = FindObjectOfType <PlayerUiArea>();

        PlayerScoreController = GetComponentInChildren <PlayerScoreController>();
        PlayerScoreController.Init(Voice);

        PlayerNoteRecorder = GetComponentInChildren <PlayerNoteRecorder>();
        if (PlayerNoteRecorder == null)
        {
            throw new NullReferenceException("PlayerNoteRecorder is null!");
        }
        PlayerNoteRecorder.Init(this, playerProfile.Difficulty.RoundingDistance);

        CreatePlayerUi();

        sentenceIndex = 0;
        UpdateSentences(sentenceIndex);
    }
Example #3
0
    void Start()
    {
        string playerProfilesCsv = SceneData.SelectedPlayerProfiles.Select(it => it.Name).ToCsv();

        Debug.Log($"{playerProfilesCsv} start (or continue) singing of {SongMeta.Title} at {SceneData.PositionInSongInMillis} ms.");

        // Prepare columns and rows for player UI
        PlayerUiArea.SetupPlayerUiGrid(SceneData.SelectedPlayerProfiles.Count, playerUiArea.GetComponent <GridLayoutGroupCellSizer>());

        // Handle players
        List <PlayerProfile> playerProfilesWithoutMic = new List <PlayerProfile>();

        foreach (PlayerProfile playerProfile in SceneData.SelectedPlayerProfiles)
        {
            SceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile);
            if (micProfile == null)
            {
                playerProfilesWithoutMic.Add(playerProfile);
            }
            PlayerController playerController = CreatePlayerController(playerProfile, micProfile);

            if (SceneData.PlayerProfileToScoreDataMap.TryGetValue(playerProfile, out PlayerScoreControllerData scoreData))
            {
                playerController.PlayerScoreController.ScoreData = scoreData;
            }

            // Handle crown display
            if (SceneData.SelectedPlayerProfiles.Count > 1)
            {
                playerController.PlayerScoreController.NoteScoreEventStream.Subscribe(noteScoreEvent => { RecomputeCrowns(); });
                playerController.PlayerScoreController.SentenceScoreEventStream.Subscribe(sentenceScoreEvent => { RecomputeCrowns(); });
            }
            playerController.PlayerUiController.PlayerCrownDisplayer.ShowCrown(false);
        }

        // Handle dummy singers
        if (Application.isEditor)
        {
            DummySingers = FindObjectsOfType <AbstractDummySinger>().ToList();
            foreach (AbstractDummySinger dummySinger in DummySingers)
            {
                if (dummySinger.playerIndexToSimulate < PlayerControllers.Count)
                {
                    dummySinger.SetPlayerController(PlayerControllers[dummySinger.playerIndexToSimulate]);
                }
                else
                {
                    Debug.LogWarning("DummySinger cannot simulate player with index " + dummySinger.playerIndexToSimulate);
                    dummySinger.gameObject.SetActive(false);
                }
            }
        }

        // Create warning about missing microphones
        string playerNameCsv = string.Join(",", playerProfilesWithoutMic.Select(it => it.Name).ToList());

        if (!playerProfilesWithoutMic.IsNullOrEmpty())
        {
            UiManager.Instance.CreateWarningDialog(
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_title),
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_message, "playerNameCsv", playerNameCsv));
        }

        // Associate LyricsDisplayer with one of the (duett) players
        InitLyricsDisplayers();

        //Save information about the song being started into stats
        Statistics stats = StatsManager.Instance.Statistics;

        stats.RecordSongStarted(SongMeta);

        songVideoPlayer.Init(SongMeta, songAudioPlayer);

        StartCoroutine(StartMusicAndVideo());

        // Rebuild whole UI
        LayoutRebuilder.ForceRebuildLayoutImmediate(CanvasUtils.FindCanvas().GetComponent <RectTransform>());
    }
Example #4
0
 void Awake()
 {
     playerUiArea          = FindObjectOfType <PlayerUiArea>();
     PlayerScoreController = GetComponentInChildren <PlayerScoreController>();
     PlayerNoteRecorder    = GetComponentInChildren <PlayerNoteRecorder>();
 }