Exemple #1
0
        private void load()
        {
            Container leaderboardContainer;

            masterClockContainer = new MasterGameplayClockContainer(Beatmap.Value, 0);

            InternalChildren = new[]
            {
                (Drawable)(syncManager = new CatchUpSyncManager(masterClockContainer)),
                masterClockContainer.WithChild(new GridContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    ColumnDimensions = new[]
                    {
                        new Dimension(GridSizeMode.AutoSize)
                    },
                    Content = new[]
                    {
                        new Drawable[]
                        {
                            leaderboardContainer = new Container
                            {
                                RelativeSizeAxes = Axes.Y,
                                AutoSizeAxes     = Axes.X
                            },
                            grid = new PlayerGrid {
                                RelativeSizeAxes = Axes.Both
                            }
                        }
                    }
                })
            };

            for (int i = 0; i < UserIds.Count; i++)
            {
                grid.Add(instances[i] = new PlayerArea(UserIds[i], masterClockContainer.GameplayClock));
                syncManager.AddPlayerClock(instances[i].GameplayClock);
            }

            // Todo: This is not quite correct - it should be per-user to adjust for other mod combinations.
            var playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
            var scoreProcessor  = Ruleset.Value.CreateInstance().CreateScoreProcessor();

            scoreProcessor.ApplyBeatmap(playableBeatmap);

            LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(scoreProcessor, UserIds.ToArray())
            {
                Expanded = { Value = true },
                Anchor   = Anchor.CentreLeft,
                Origin   = Anchor.CentreLeft,
            }, l =>
            {
                foreach (var instance in instances)
                {
                    leaderboard.AddClock(instance.UserId, instance.GameplayClock);
                }

                leaderboardContainer.Add(leaderboard);
            });
        }
        protected override void StartGameplay(int userId, GameplayState gameplayState)
        {
            var instance = instances.Single(i => i.UserId == userId);

            instance.LoadScore(gameplayState.Score);

            syncManager.AddPlayerClock(instance.GameplayClock);
            leaderboard.AddClock(instance.UserId, instance.GameplayClock);
        }
Exemple #3
0
        private void load()
        {
            FillFlowContainer leaderboardFlow;
            Container         scoreDisplayContainer;

            masterClockContainer = CreateMasterGameplayClockContainer(Beatmap.Value);

            InternalChildren = new[]
            {
                (Drawable)(syncManager = new CatchUpSyncManager(masterClockContainer)),
                masterClockContainer.WithChild(new GridContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    RowDimensions    = new[] { new Dimension(GridSizeMode.AutoSize) },
                    Content          = new[]
                    {
                        new Drawable[]
                        {
                            scoreDisplayContainer = new Container
                            {
                                RelativeSizeAxes = Axes.X,
                                AutoSizeAxes     = Axes.Y
                            },
                        },
                        new Drawable[]
                        {
                            new GridContainer
                            {
                                RelativeSizeAxes = Axes.Both,
                                ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
                                Content          = new[]
                                {
                                    new Drawable[]
                                    {
                                        leaderboardFlow = new FillFlowContainer
                                        {
                                            Anchor       = Anchor.CentreLeft,
                                            Origin       = Anchor.CentreLeft,
                                            AutoSizeAxes = Axes.Both,
                                            Direction    = FillDirection.Vertical,
                                            Spacing      = new Vector2(5)
                                        },
                                        grid = new PlayerGrid {
                                            RelativeSizeAxes = Axes.Both
                                        }
                                    }
                                }
                            }
                        }
                    }
                })
            };

            for (int i = 0; i < Users.Count; i++)
            {
                grid.Add(instances[i] = new PlayerArea(Users[i], masterClockContainer.GameplayClock));
                syncManager.AddPlayerClock(instances[i].GameplayClock);
            }

            // Todo: This is not quite correct - it should be per-user to adjust for other mod combinations.
            var playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
            var scoreProcessor  = Ruleset.Value.CreateInstance().CreateScoreProcessor();

            scoreProcessor.ApplyBeatmap(playableBeatmap);

            LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(Ruleset.Value, scoreProcessor, users)
            {
                Expanded = { Value = true },
            }, l =>
            {
                foreach (var instance in instances)
                {
                    leaderboard.AddClock(instance.UserId, instance.GameplayClock);
                }

                leaderboardFlow.Insert(0, leaderboard);

                if (leaderboard.TeamScores.Count == 2)
                {
                    LoadComponentAsync(new MatchScoreDisplay
                    {
                        Team1Score = { BindTarget = leaderboard.TeamScores.First().Value },
                        Team2Score = { BindTarget = leaderboard.TeamScores.Last().Value },
                    }, scoreDisplayContainer.Add);
                }
            });

            LoadComponentAsync(new GameplayChatDisplay(room)
            {
                Expanded = { Value = true },
            }, chat => leaderboardFlow.Insert(1, chat));
        }