Ejemplo n.º 1
0
        private async ETVoid PlaySound()
        {
            this.isPlaying = true;
            while (soundQueue.Count > 0)
            {
                Sound sound = soundQueue.Dequeue();
                sound.bytes = GzipHelper.Decompress(sound.bytes);
                SetData(soundSource.clip, sound.bytes);
                float volume = musicSource.volume;
                musicSource.volume = volume > 0.1f ? 0.1f : volume;
                soundSource.mute   = false;
                soundSource.Play();
                playingSound?.Invoke(sound.seatId);
                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync((long)(sound.time * 1000));

                musicSource.volume = volume;
            }
            while (clipQueue.Count > 0)
            {
                soundSource.clip = clipQueue.Dequeue();
                soundSource.Play();
                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(1000);
            }
            this.isPlaying = false;
        }
Ejemplo n.º 2
0
        public void Gzip压缩字符串()
        {
            string str1 = "aaaaaaaaaaaaaaaaaa";

            // 压缩字符串
            string base64 = GzipHelper.Compress(str1);

            // 解压缩
            string str2 = GzipHelper.Decompress(base64);

            Assert.AreEqual(str1, str2);
        }
Ejemplo n.º 3
0
        public void Test_Gzip压缩字符串()
        {
            string s = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
";

            string b = GzipHelper.Compress(s);

            string s2 = GzipHelper.Decompress(b);

            Assert.AreEqual(s, s2);
        }
Ejemplo n.º 4
0
        public bool DownloadCityFile()
        {
            if (!File.Exists(_fileUrlsAndPaths.CompressedCityListFilePath))
            {
                using var client = new WebClient();
                client.DownloadFile(_fileUrlsAndPaths.CityListFileUrl, _fileUrlsAndPaths.CompressedCityListFilePath);
            }

            if (!File.Exists(_fileUrlsAndPaths.DecompressedCityListFilePath))
            {
                var fileInfo = new FileInfo(_fileUrlsAndPaths.DecompressedCityListFilePath);

                GzipHelper.Decompress(fileInfo);
            }

            return(File.Exists(_fileUrlsAndPaths.DecompressedCityListFilePath));
        }
Ejemplo n.º 5
0
        public void Test_Gzip压缩二进制字节()
        {
            string s = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
";

            byte[] bb = Encoding.UTF8.GetBytes(s);

            byte[] b1 = GzipHelper.Compress(bb);
            byte[] b2 = GzipHelper.Decompress(b1);

            Assert.AreEqual(bb.Length, b2.Length);

            for (int i = 0; i < bb.Length; i++)
            {
                Assert.AreEqual((int)bb[i], (int)b2[i]);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Checks if there are new scoreboard users.
        /// </summary>
        private void CheckIfNewScoreboardUsers()
        {
            var mapScores = MapManager.Selected.Value.Scores.Value;

            if (mapScores == null || mapScores.Count <= 0 || Scoreboard.Users.Count != 1)
            {
                return;
            }

            for (var i = 0; i < 4 && i < mapScores.Count; i++)
            {
                ScoreboardUser user;

                // For online scores we want to just give them their score in the processor,
                // since we don't have access to their judgement breakdown.
                if (mapScores[i].IsOnline)
                {
                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              new List <Judgement>(), UserInterface.UnknownAvatar, mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    user.Scoreboard = Scoreboard;

                    var processor = user.Processor as ScoreProcessorKeys;
                    processor.Accuracy = (float)mapScores[i].Accuracy;
                    processor.MaxCombo = mapScores[i].MaxCombo;
                    processor.Score    = mapScores[i].TotalScore;

                    user.Score.Text = $"{user.RatingProcessor.CalculateRating(processor.Accuracy):0.00} / {StringHelper.AccuracyToString(processor.Accuracy)}";
                    user.Combo.Text = $"{processor.MaxCombo}x";
                }
                // Allow the user to play against their own local scores.
                else
                {
                    // Decompress score
                    var breakdownHits = GzipHelper.Decompress(mapScores[i].JudgementBreakdown);

                    var judgements = new List <Judgement>();

                    // Get all of the hit stats for the score.
                    foreach (var hit in breakdownHits)
                    {
                        judgements.Add((Judgement)int.Parse(hit.ToString()));
                    }

                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              judgements, UserInterface.UnknownAvatar, mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    user.Scoreboard = Scoreboard;

                    // Make sure the user's score is updated with the current user.
                    for (var j = 0; j < Screen.Ruleset.ScoreProcessor.TotalJudgementCount && i < judgements.Count; j++)
                    {
                        var processor = user.Processor as ScoreProcessorKeys;
                        processor?.CalculateScore(judgements[i]);
                    }
                }

                Scoreboard.Users.Add(user);
            }

            Scoreboard.SetTargetYPositions();

            // Re-change the transitioner and pause screen's parent so that they appear on top of the scoreboard
            // again.
            Transitioner.Parent = Container;
            PauseScreen.Parent  = Container;
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Checks if there are new scoreboard users.
        /// </summary>
        private void CheckIfNewScoreboardUsers()
        {
            if (Screen.IsPlayTesting || StopCheckingForScoreboardUsers)
            {
                return;
            }

            var mapScores = MapManager.Selected.Value.Scores.Value;

            if (mapScores == null || mapScores.Count <= 0 || (ScoreboardLeft.Users?.Count < 1 && ScoreboardRight != null && ScoreboardRight.Users.Count < 1))
            {
                return;
            }

            for (var i = 0; i < (OnlineManager.CurrentGame == null ? 4 : mapScores.Count) && i < mapScores.Count; i++)
            {
                ScoreboardUser user;

                // For online scores we want to just give them their score in the processor,
                // since we don't have access to their judgement breakdown.
                if (mapScores[i].IsOnline)
                {
                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              new List <Judgement>(), UserInterface.UnknownAvatar, (ModIdentifier)mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    if (OnlineManager.CurrentGame != null &&
                        OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team && OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue)
                    {
                        user.Scoreboard = ScoreboardRight;
                        user.X          = WindowManager.Width;
                    }
                    else
                    {
                        user.Scoreboard = ScoreboardLeft;
                    }

                    user.SetImage();

                    var processor = user.Processor as ScoreProcessorKeys;
                    processor.Accuracy = (float)mapScores[i].Accuracy;
                    processor.MaxCombo = mapScores[i].MaxCombo;
                    processor.Score    = mapScores[i].TotalScore;

                    user.Score.Text = $"{user.RatingProcessor.CalculateRating(processor.Accuracy):0.00} / {StringHelper.AccuracyToString(processor.Accuracy)}";
                    user.Combo.Text = $"{processor.MaxCombo}x";
                }
                // Allow the user to play against their own local scores.
                else
                {
                    // Decompress score
                    var breakdownHits = GzipHelper.Decompress(mapScores[i].JudgementBreakdown);

                    var judgements = new List <Judgement>();

                    // Get all of the hit stats for the score.
                    foreach (var hit in breakdownHits)
                    {
                        judgements.Add((Judgement)int.Parse(hit.ToString()));
                    }

                    user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}",
                                              judgements, UserInterface.UnknownAvatar, (ModIdentifier)mapScores[i].Mods, mapScores[i])
                    {
                        Parent    = Container,
                        Alignment = Alignment.MidLeft
                    };

                    if (OnlineManager.CurrentGame != null &&
                        OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team && OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue)
                    {
                        user.Scoreboard = ScoreboardRight;
                    }
                    else
                    {
                        user.Scoreboard = ScoreboardLeft;
                    }

                    user.SetImage();

                    // Make sure the user's score is updated with the current user.
                    for (var j = 0; j < Screen.Ruleset.ScoreProcessor.TotalJudgementCount && i < judgements.Count; j++)
                    {
                        var processor = user.Processor as ScoreProcessorKeys;
                        processor?.CalculateScore(judgements[i]);
                    }
                }

                if (OnlineManager.CurrentGame != null && OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team &&
                    OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue)
                {
                    ScoreboardRight.Users.Add(user);
                }
                else
                {
                    ScoreboardLeft.Users.Add(user);
                }
            }

            ScoreboardLeft.SetTargetYPositions();
            ScoreboardRight?.SetTargetYPositions();

            // Re-change the transitioner and pause screen's parent so that they appear on top of the scoreboard
            // again.
            if (ProgressBar != null)
            {
                ProgressBar.Parent = Container;
            }

            Transitioner.Parent = Container;
            PauseScreen.Parent  = Container;

            StopCheckingForScoreboardUsers = true;
            Screen.SetRichPresence();
        }