Exemple #1
0
        private void SongTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            noteTimer.Stop();
            noteTimer.Elapsed -= SongTimer_Elapsed;
            noteTimer.Dispose();
            noteTimer = null;

            songTimer.Stop();
            songTimer.Elapsed -= SongTimer_Elapsed;
            songTimer.Dispose();
            songTimer = null;

            currentlyPlayingMap  = null;
            currentlyPlayingSong = null;
            currentMaxScore      = 0;

            Logger.Debug($"SENDING RESULTS: {(Self as Player).Score}");

            var songFinished = new SongFinished();

            songFinished.Type    = SongFinished.CompletionType.Passed;
            songFinished.User    = Self as Player;
            songFinished.Beatmap = currentlyPlayingMap;
            songFinished.Score   = (Self as Player).Score;
            Send(new Packet(songFinished));

            (Self as Player).PlayState = Player.PlayStates.Waiting;
            var playerUpdated = new Event();

            playerUpdated.Type          = Event.EventType.PlayerUpdated;
            playerUpdated.ChangedObject = Self;
            Send(new Packet(playerUpdated));
        }
        private void RemoveFromPlaylist(Playlist playlist, IEnumerable <int> indexes)
        {
            bool stopCurrentSong = playlist == CurrentPlaylist &&
                                   indexes.Any(index => index == CurrentPlaylist.CurrentSongIndex);

            playlist.RemoveSongs(indexes);

            PlaylistChanged.RaiseSafe(this, EventArgs.Empty);

            if (stopCurrentSong)
            {
                _currentPlayer.Stop();
                SongFinished.RaiseSafe(this, EventArgs.Empty);
            }
        }
        private void HandleSongFinish()
        {
            if (!CurrentPlaylist.CanPlayNextSong)
            {
                CurrentPlaylist.CurrentSongIndex = null;
            }

            _currentPlayer.Dispose();
            _currentPlayer = null;

            SongFinished.RaiseSafe(this, EventArgs.Empty);

            if (CurrentPlaylist.CanPlayNextSong)
            {
                InternPlayNextSong();
            }
        }
Exemple #4
0
        private void SongTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            noteTimer.Stop();
            noteTimer.Elapsed -= SongTimer_Elapsed;
            noteTimer.Dispose();
            noteTimer = null;

            songTimer.Stop();
            songTimer.Elapsed -= SongTimer_Elapsed;
            songTimer.Dispose();
            songTimer = null;

            currentlyPlayingMap  = null;
            currentlyPlayingSong = null;
            currentMaxScore      = 0;
            var selfPlayer = SelfObject as Player;

            Logger.Debug($"SENDING RESULTS: {selfPlayer.Score}");

            var songFinished = new SongFinished();

            songFinished.Type    = SongFinished.Types.CompletionType.Passed;
            songFinished.User    = selfPlayer;
            songFinished.Beatmap = currentlyPlayingMap;
            songFinished.Score   = selfPlayer.Score;
            Send(new Packet(songFinished));

            selfPlayer.PlayState = Player.Types.PlayStates.Waiting;
            var playerUpdated = new Event
            {
                Type          = Event.Types.EventType.PlayerUpdated,
                ChangedObject = Google.Protobuf.WellKnownTypes.Any.Pack(selfPlayer)
            };

            Send(new Packet(playerUpdated));
        }
Exemple #5
0
        public void SongFinished(StandardLevelScenesTransitionSetupDataSO standardLevelScenesTransitionSetupData, LevelCompletionResults results)
        {
            standardLevelScenesTransitionSetupData.didFinishEvent -= SongFinished;

            var map          = (standardLevelScenesTransitionSetupData.sceneSetupDataArray.First(x => x is GameplayCoreSceneSetupData) as GameplayCoreSceneSetupData).difficultyBeatmap;
            var localPlayer  = _playerDataModel.playerData;
            var localResults = localPlayer.GetPlayerLevelStatsData(map.level.levelID, map.difficulty, map.parentDifficultyBeatmapSet.beatmapCharacteristic);
            var highScore    = localResults.highScore < results.modifiedScore;

            //Send final score to Host
            if (Plugin.client.Connected)
            {
                Logger.Debug($"SENDING RESULTS: {results.modifiedScore}");

                var songFinished = new SongFinished();
                if (results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared)
                {
                    songFinished.Type = TournamentAssistantShared.Models.Packets.SongFinished.CompletionType.Passed;
                }
                if (results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Failed)
                {
                    songFinished.Type = TournamentAssistantShared.Models.Packets.SongFinished.CompletionType.Failed;
                }
                if (results.levelEndAction == LevelCompletionResults.LevelEndAction.Quit)
                {
                    songFinished.Type = TournamentAssistantShared.Models.Packets.SongFinished.CompletionType.Quit;
                }

                songFinished.User = Plugin.client.Self as Player;

                songFinished.Beatmap                = new Beatmap();
                songFinished.Beatmap.LevelId        = map.level.levelID;
                songFinished.Beatmap.Difficulty     = (SharedConstructs.BeatmapDifficulty)map.difficulty;
                songFinished.Beatmap.Characteristic = new Characteristic();
                songFinished.Beatmap.Characteristic.SerializedName = map.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName;
                songFinished.Beatmap.Characteristic.Difficulties   = map.parentDifficultyBeatmapSet.difficultyBeatmaps.Select(x => (SharedConstructs.BeatmapDifficulty)x.difficulty).ToArray();

                songFinished.Score = results.modifiedScore;

                Plugin.client.Send(new Packet(songFinished));
            }

            if (results.levelEndStateType != LevelCompletionResults.LevelEndStateType.None)
            {
                _menuLightsManager.SetColorPreset(_scoreLights, true);
                _resultsViewController.Init(results, map, false, highScore);
                _resultsViewController.GetField <Button>("_restartButton").gameObject.SetActive(false);
                _resultsViewController.continueButtonPressedEvent += resultsViewController_continueButtonPressedEvent;
                PresentViewController(_resultsViewController, null, true);
            }
            else if (ShouldDismissOnReturnToMenu)
            {
                Dismiss();
            }
            else if (!Plugin.client.State.Matches.Contains(Match))
            {
                if (tournamentMode)
                {
                    SwitchToWaitingForCoordinatorMode();
                }
                else
                {
                    Dismiss();
                }
            }
        }
Exemple #6
0
 protected void OnSongFinished()
 {
     SongFinished?
     .Invoke(this, EventArgs.Empty);
 }