Beispiel #1
0
        /// <summary>
        /// Constructor for a new record.
        /// </summary>
        public Record(IPlayableMap map, IUser user, IScoreProcessor scoreProcessor, int playTime)
        {
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            InitializeAsNew();

            UserId    = user.Id;
            Username  = user.Username;
            AvatarUrl = user.OnlineUser?.AvatarImage ?? "";

            MapHash  = map.Detail.Hash;
            GameMode = map.PlayableMode;
            Rank     = scoreProcessor.Ranking.Value;
            Score    = scoreProcessor.Score.Value;
            MaxCombo = scoreProcessor.HighestCombo.Value;
            Accuracy = (float)scoreProcessor.Accuracy.Value;
            Time     = playTime;
            Date     = DateTime.Now;

            IsClear = scoreProcessor.IsFinished && !scoreProcessor.IsFailed;

            ExtractJudgements(scoreProcessor.Judgements);
        }
 public ScoreController(IControllerFactory controllerFactory,
                        IScoreProcessor scoreProcessor,
                        ILinesCleaner board)
     : base(controllerFactory)
 {
     _linesCleaner   = board;
     _scoreProcessor = scoreProcessor;
 }
Beispiel #3
0
        public FileProcessor(
            IFileCommander fileCommander,
            IScoreProcessor scoreProcessor,
            IStudentInfoProcessor studentInfoProcessor)

        {
            this.studentInfoProcessor = studentInfoProcessor;
            this.fileCommander        = fileCommander;
            this.scoreProcessor       = scoreProcessor;
        }
Beispiel #4
0
        /// <summary>
        /// Records the specified play record under the current player.
        /// </summary>
        public Task <IRecord> RecordScore(IScoreProcessor scoreProcessor, int playTime, TaskListener <IRecord> listener = null)
        {
            return(Task.Run <IRecord>(async() =>
            {
                try
                {
                    if (scoreProcessor == null || scoreProcessor.JudgeCount <= 0)
                    {
                        listener?.SetFinished();
                        return null;
                    }

                    // Retrieve user and user stats.
                    var currentMap = currentParameter.Map;
                    var user = UserManager.CurrentUser.Value;
                    var userStats = user.GetStatistics(currentMap.PlayableMode);

                    // Record the play result to records database and user statistics.
                    Record newRecord = new Record(currentMap, user, scoreProcessor, playTime);
                    lastRecord = newRecord;
                    // Retrieve old records for the map and user.
                    var records = await RecordStore.GetTopRecords(currentMap, user, limit: null, listener: listener?.CreateSubListener <List <IRecord> >());

                    // Save as cleared play.
                    if (scoreProcessor.IsFinished)
                    {
                        RecordStore.SaveRecord(newRecord);

                        var bestRecord = records == null || records.Count == 0 ? null : records[0];
                        userStats.RecordPlay(newRecord, bestRecord);
                    }
                    // Save as failed play.
                    else
                    {
                        userStats.RecordIncompletePlay(newRecord);
                    }
                    listener?.SetFinished(newRecord);
                    return newRecord;
                }
                catch (Exception e)
                {
                    Logger.LogError($"Error while recording score: {e.Message}\n{e.StackTrace}");
                    listener?.SetFinished();
                    return null;
                }
            }));
        }
        private void Init(IGameSession gameSession)
        {
            gameSession.OnSoftInit += () =>
            {
                scoreProcessor = gameSession.ScoreProcessor;
                scoreProcessor.Health.BindAndTrigger(OnHealthChange);
                SetFailingForce(false);
            };
            gameSession.OnSoftDispose += () =>
            {
                ProgressBar.Value = 0f;
            };

            ProgressBar = CreateChild <UguiProgressBar>("progress", 0);
            {
                fgSprite       = ProgressBar.Foreground;
                fgSprite.Color = ColorPreset.PrimaryFocus.Base;

                thumbSprite            = ProgressBar.Thumb;
                thumbSprite.Active     = true;
                thumbSprite.SpriteName = "glow-128";
                thumbSprite.Color      = ColorPreset.PrimaryFocus.Alpha(0f);
                thumbSprite.Size       = new Vector2(36f, 88f);

                pinEffectSprite = thumbSprite.CreateChild <UguiSprite>("effect");
                {
                    pinEffectSprite.Color      = ColorPreset.PrimaryFocus.Alpha(0f);
                    pinEffectSprite.SpriteName = "glow-128";
                    pinEffectSprite.Size       = thumbSprite.Size * 6.5f;

                    pinEffectSprite.AddEffect(new AdditiveShaderEffect());
                }
            }
            Indicator = CreateChild <UguiSprite>("indicator", 1);
            {
                Indicator.Color = ColorPreset.PrimaryFocus.Base;
            }

            changeAni = new Anime();
            changeAni.AnimateFloat((progress) => ProgressBar.Value = progress)
            .AddTime(0f, () => ProgressBar.Value)
            .AddTime(0.2f, () => curHealth)
            .Build();
            changeAni.AnimateColor((tint) => fgSprite.Tint = tint)
            .AddTime(0f, () => barTintFromColor)
            .AddTime(0.35f, () => barTintToColor)
            .Build();

            pinAni = new Anime();
            // Thumb sprite fade and scale
            pinAni.AnimateFloat((alpha) => thumbSprite.Alpha = alpha)
            .AddTime(0f, 0f)
            .AddTime(0.05f, 1f, EaseType.QuadEaseIn)
            .AddTime(0.25f, 0f)
            .Build();
            pinAni.AnimateVector3((scale) => thumbSprite.Scale = scale)
            .AddTime(0f, new Vector3(1.1f, 1.1f), EaseType.QuadEaseIn)
            .AddTime(0.25f, Vector3.one)
            .Build();
            // Pin effect fade and scale
            pinAni.AnimateFloat((alpha) => pinEffectSprite.Alpha = alpha)
            .AddTime(0f, 1f, EaseType.QuadEaseOut)
            .AddTime(0.25f, 0f)
            .Build();
            pinAni.AnimateVector3((scale) => pinEffectSprite.Scale = scale)
            .AddTime(0f, Vector3.zero, EaseType.CubicEaseOut)
            .AddTime(0.25f, Vector3.one)
            .Build();
        }