Пример #1
0
        public void Set(int level, LevelProgressDto progress)
        {
            var current = Get(level);

            if (current != null)
            {
                if (current.Stars < progress.Stars)
                {
                    current.Stars            = progress.Stars;
                    current.Seconds          = progress.Seconds;
                    current.ObjectsCollected = progress.ObjectsCollected;
                }
            }
            else
            {
                Progress.Add(progress);
            }
        }
Пример #2
0
        public override void Execute()
        {
            Retain();

            var levelProgress = new LevelProgressDto
            {
                Level            = gameModel.Level,
                Stars            = gameModel.Stars.Value,
                ObjectsCollected = gameModel.ObjectsCollected.Value,
                Seconds          = gameModel.Seconds.Value
            };


            var current = progress.Get(gameModel.Level);

            if (current != null)
            {
                if (current.Stars < levelProgress.Stars)
                {
                    current.Stars            = levelProgress.Stars;
                    current.Seconds          = levelProgress.Seconds;
                    current.ObjectsCollected = levelProgress.ObjectsCollected;
                }
            }
            else
            {
                Retain();

                progress.Progress.Add(levelProgress);

                var contract = new LevelProgressRequest
                {
                    LevelProgress = levelProgress
                };

                connection.SetProgress(gameModel.Level, contract).Subscribe(OnSuccess, OnError);
            }
        }