Ejemplo n.º 1
0
        private void onUserStateAdded(int userId, SpectatorState state)
        {
            if (state.RulesetID == null || state.BeatmapID == null)
            {
                return;
            }

            if (!userMap.ContainsKey(userId))
            {
                return;
            }

            Schedule(() => OnUserStateChanged(userId, state));
            updateGameplayState(userId);
        }
Ejemplo n.º 2
0
        private void userFinishedPlaying(int userId, SpectatorState state)
        {
            if (userId != targetUser.Id)
            {
                return;
            }

            if (replay != null)
            {
                replay.HasReceivedAllFrames = true;
                replay = null;
            }

            Schedule(clearDisplay);
        }
Ejemplo n.º 3
0
        private void userBeganPlaying(int userId, SpectatorState state)
        {
            if (userId != score.ScoreInfo.UserID)
            {
                return;
            }

            Schedule(() =>
            {
                if (this.IsCurrentScreen())
                {
                    this.Exit();
                }
            });
        }
Ejemplo n.º 4
0
        Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
        {
            if (watchingUsers.Contains(userId))
            {
                Console.WriteLine($"{connection.ConnectionId} received began playing for already watched user {userId}");
            }
            else
            {
                Console.WriteLine($"{connection.ConnectionId} requesting watch other user {userId}");
                WatchUser(userId);
                watchingUsers.Add(userId);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 5
0
        protected override void EndGameplay(int userId, SpectatorState state)
        {
            // Allowed passed/failed users to complete their remaining replay frames.
            // The failed state isn't really possible in multiplayer (yet?) but is added here just for safety in case it starts being used.
            if (state.State == SpectatedUserState.Passed || state.State == SpectatedUserState.Failed)
            {
                return;
            }

            RemoveUser(userId);

            var instance = instances.Single(i => i.UserId == userId);

            instance.FadeColour(colours.Gray4, 400, Easing.OutQuint);
            syncManager.RemovePlayerClock(instance.GameplayClock);
        }
Ejemplo n.º 6
0
        private void showBeatmapPanel(SpectatorState state)
        {
            Debug.Assert(state.BeatmapID != null);

            onlineBeatmapRequest          = new GetBeatmapSetRequest(state.BeatmapID.Value, BeatmapSetLookupType.BeatmapId);
            onlineBeatmapRequest.Success += beatmapSet => Schedule(() =>
            {
                this.beatmapSet             = beatmapSet;
                beatmapPanelContainer.Child = new BeatmapCard(this.beatmapSet)
                {
                    Expanded = { Disabled = true }
                };
                checkForAutomaticDownload();
            });

            api.Queue(onlineBeatmapRequest);
        }
Ejemplo n.º 7
0
        private void onUserStateRemoved(int userId, SpectatorState state)
        {
            if (!userMap.ContainsKey(userId))
            {
                return;
            }

            if (!gameplayStates.TryGetValue(userId, out var gameplayState))
            {
                return;
            }

            gameplayState.Score.Replay.HasReceivedAllFrames = true;

            gameplayStates.Remove(userId);
            Schedule(() => EndGameplay(userId, state));
        }
Ejemplo n.º 8
0
        private void userBeganPlaying(int userId, SpectatorState state)
        {
            if (userId != targetUser.Id)
            {
                return;
            }

            this.state = state;

            if (this.IsCurrentScreen())
            {
                Schedule(attemptStart);
            }
            else
            {
                newStatePending = true;
            }
        }
Ejemplo n.º 9
0
        private void userFinishedPlaying(int userId, SpectatorState state)
        {
            if (userId != targetUser.Id)
            {
                return;
            }

            lock (scoreLock)
            {
                if (score != null)
                {
                    score.Replay.HasReceivedAllFrames = true;
                    score = null;
                }
            }

            Schedule(clearDisplay);
        }
Ejemplo n.º 10
0
        private void userBeganPlaying(int userId, SpectatorState state)
        {
            if (state.RulesetID == null || state.BeatmapID == null)
            {
                return;
            }

            lock (stateLock)
            {
                if (!userMap.ContainsKey(userId))
                {
                    return;
                }

                spectatorStates[userId] = state;
                Schedule(() => OnUserStateChanged(userId, state));

                updateGameplayState(userId);
            }
        }
Ejemplo n.º 11
0
        private void showBeatmapPanel(SpectatorState state)
        {
            if (state?.BeatmapID == null)
            {
                onlineBeatmap = null;
                return;
            }

            var req = new GetBeatmapSetRequest(state.BeatmapID.Value, BeatmapSetLookupType.BeatmapId);

            req.Success += res => Schedule(() =>
            {
                if (state != this.state)
                {
                    return;
                }

                onlineBeatmap = res.ToBeatmapSet(rulesets);
                beatmapPanelContainer.Child = new GridBeatmapPanel(onlineBeatmap);
                checkForAutomaticDownload();
            });

            api.Queue(req);
        }
Ejemplo n.º 12
0
 protected override void OnNewPlayingUserState(int userId, SpectatorState spectatorState)
 {
 }
Ejemplo n.º 13
0
 protected override Task EndPlayingInternal(SpectatorState state) => ((ISpectatorClient)this).UserFinishedPlaying(api.LocalUser.Value.Id, state);
Ejemplo n.º 14
0
 public Task EndPlaying(SpectatorState state) => connection.SendAsync(nameof(ISpectatorServer.EndPlaySession), state);
Ejemplo n.º 15
0
 protected override void OnUserStateChanged(int userId, SpectatorState spectatorState)
 {
 }
Ejemplo n.º 16
0
 protected override void OnUserStateChanged(int userId, SpectatorState spectatorState)
 {
     clearDisplay();
     showBeatmapPanel(spectatorState);
 }
Ejemplo n.º 17
0
 private async Task updateUserState(SpectatorState state)
 {
     await cache.SetStringAsync(GetStateId(currentContextUserId), JsonConvert.SerializeObject(state));
 }
Ejemplo n.º 18
0
 private async Task endPlaySession(int userId, SpectatorState state)
 {
     await Clients.All.UserFinishedPlaying(userId, state);
 }
Ejemplo n.º 19
0
 protected abstract void OnNewPlayingUserState(int userId, [NotNull] SpectatorState spectatorState);
Ejemplo n.º 20
0
 /// <summary>
 /// Invoked when a spectated user's state has changed.
 /// </summary>
 /// <param name="userId">The user whose state has changed.</param>
 /// <param name="spectatorState">The new state.</param>
 protected abstract void OnUserStateChanged(int userId, [NotNull] SpectatorState spectatorState);
Ejemplo n.º 21
0
 protected abstract void EndGameplay(int userId, SpectatorState state);
Ejemplo n.º 22
0
 protected override void OnNewPlayingUserState(int userId, SpectatorState spectatorState)
 {
     clearDisplay();
     showBeatmapPanel(spectatorState);
 }
Ejemplo n.º 23
0
 Task ISpectatorClient.UserFinishedPlaying(int userId, SpectatorState state)
 {
     Console.WriteLine($"{connection.ConnectionId} Received user finished event {state}");
     return(Task.CompletedTask);
 }