Ejemplo n.º 1
0
 private void SetupGame()
 {
     _controller.OnHitReg = HitRegHandler;
     AddGraphic <Image>(new Image(@"..\..\Backgrounds\bg.png"));
     scoreEntity = new ScoreEntity(Game.Instance.Width - 250, 50);
     Add(scoreEntity);
     countsEntity = new CountsEntity(Game.Instance.HalfWidth, 20);
     Add(countsEntity);
     MissSound = new Sound(@"..\..\FX\Miss.wav")
     {
         Volume = FX_VOLUME
     };
     BadSound = new Sound(@"..\..\FX\Bad.wav")
     {
         Volume = FX_VOLUME
     };
     OKSound = new Sound(@"..\..\FX\OK.wav")
     {
         Volume = FX_VOLUME
     };
     GoodSound = new Sound(@"..\..\FX\Good.wav")
     {
         Volume = FX_VOLUME
     };
     GreatSound = new Sound(@"..\..\FX\Great.wav")
     {
         Volume = FX_VOLUME
     };
     PerfectSound = new Sound(@"..\..\FX\Perfect.wav")
     {
         Volume = FX_VOLUME
     };
     soundCache = new Sound[SOUND_LIMIT];
     i          = 0;
 }
Ejemplo n.º 2
0
 public void UpdateScore(ScoreEntity updatedScore)
 {
     if (updatedScore.Id.Equals(Guid.Empty))
     {
         throw new ObjectNotFoundException("The Score Requested Does Not Exist.");
     }
 }
Ejemplo n.º 3
0
 public IActionResult SubmitScore([FromBody] Score score)
 {
     try
     {
         // The score should be submit by levelม it should unique by player and level
         if (_scoreRepository.IsScoreAlreadySubmitted(score.Player, score.Level))
         {
             var newScore = new ScoreEntity()
             {
                 Player = score.Player,
                 Level  = score.Level,
                 Time   = score.Time,
                 Step   = score.Step
             };
             var currentScore = _scoreRepository.GetScore(score.Player);
             if (newScore.Score > currentScore.Score)
             {
                 _scoreRepository.UpdateScore(score.Player, score.Level, score.Time, score.Step);
             }
         }
         else
         {
             _scoreRepository.AddNewScore(score.Player, score.Level, score.Time, score.Step);
         }
         return(Ok(score));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Ejemplo n.º 4
0
        public void UpdateScore(Score score)
        {
            ScoreEntity se = data.ScoreEntities.First(x => x.IdUser == score.IdUser && x.IdCategory == score.IdCategory);

            se.Total   = score.Total;
            se.Correct = score.Correct;
        }
Ejemplo n.º 5
0
        protected void ValidateNewScore(ScoreEntity newScore)
        {
            if (newScore.PointsPossible < 0)
            {
                throw new BadInfoException("Minimum Value for Points Possible is Zero.");
            }

            if (newScore.PointsEarned < 0)
            {
                throw new BadInfoException("Minimum Value for Points Earned is Zero.");
            }

            if (string.IsNullOrEmpty(newScore.Name))
            {
                throw new MissingInfoException("All Scores Must Have a Unique Name.");
            }

            var existingScore = Repo
                                .GetAll()
                                .FirstOrDefault(s => s.EvaluationId.Equals(newScore.EvaluationId) && s.Name.Equals(newScore.Name));

            if (existingScore != null)
            {
                throw new ObjectAlreadyExistsException("There is already a Score for that Evaluation with that Name.");
            }
        }
Ejemplo n.º 6
0
        public void Save(ScoreViewModel vm)
        {
            var entity = new ScoreEntity(0);

            vm.Bind(entity);
            ScoreService.Save(entity);
        }
Ejemplo n.º 7
0
 private void RegisterToDbUpdateWhenPropertyChanged(ScoreEntity score)
 {
     score.PropertyChanged += async(s, e) =>
     {
         _scoreRepository.ScoreDbSet.Update(score);
         await _scoreRepository.SaveChangesAsync();
     };
 }
Ejemplo n.º 8
0
        private void CalculateGrade(ScoreEntity scoreToCalculate)
        {
            var wizard = new ScoreWizard();

            var result = wizard.GetSingleScoreResult(scoreToCalculate.PointsEarned, scoreToCalculate.PointsPossible);

            scoreToCalculate.PointsGrade = result.GradeRaw;
        }
Ejemplo n.º 9
0
    private async Task <ScoreEntity> WriteScore(CloudTable cloudTable, ScoreEntity score)
    {
        TableOperation insertOrMerge = TableOperation.InsertOrMerge(score);

        TableResult result = await scoresTable.ExecuteAsync(insertOrMerge);

        ScoreEntity insertedRanking = result.Result as ScoreEntity;

        return(insertedRanking);
    }
        /// <summary>
        /// Crear un nuevo objeto ScoreEntity.
        /// </summary>
        /// <param name="idUser">Valor inicial de IdUser.</param>
        /// <param name="idCategory">Valor inicial de IdCategory.</param>
        /// <param name="correct">Valor inicial de Correct.</param>
        /// <param name="total">Valor inicial de Total.</param>
        public static ScoreEntity CreateScoreEntity(int idUser, int idCategory, int correct, int total)
        {
            ScoreEntity scoreEntity = new ScoreEntity();

            scoreEntity.IdUser     = idUser;
            scoreEntity.IdCategory = idCategory;
            scoreEntity.Correct    = correct;
            scoreEntity.Total      = total;
            return(scoreEntity);
        }
Ejemplo n.º 11
0
        public void SaveScore(ScoreEntity scoreEntity, int nth)
        {
            if (nth < 0 || _rankingKeys.Length - 1 < nth)
            {
                Debug.LogWarning("SaveScore index is invalid.");
                return;
            }
            var json = JsonUtility.ToJson(scoreEntity);

            PlayerPrefs.SetString(_rankingKeys[nth], json);
        }
Ejemplo n.º 12
0
 public Guid CreateScore(ScoreEntity domainModel)
 {
     if (string.IsNullOrEmpty(domainModel.Name))
     {
         throw new MissingInfoException();
     }
     else
     {
         return(Guid.NewGuid());
     }
 }
Ejemplo n.º 13
0
        //score

        public void AddScore(Score score)
        {
            ScoreEntity se = new ScoreEntity();

            se.IdUser     = score.IdUser;
            se.IdCategory = score.IdCategory;
            se.Correct    = score.Correct;
            se.Total      = score.Total;

            data.AddToScoreEntities(se);
        }
Ejemplo n.º 14
0
        public static ScoreEntity[] GetScoreEntities(uint num)
        {
            var scoreEntities = new ScoreEntity[num];

            foreach (var nth in Enumerable.Range(0, (int)num))
            {
                scoreEntities[nth] = ScoreRepository.GetScoreEntity(nth);
            }

            return(scoreEntities);
        }
Ejemplo n.º 15
0
        public async Task SaveAsPngAsync(ScoreEntity score, Bitmap bitmap)
        {
            await Task.Run(() =>
            {
                CreateDirectoryIfNotExists();

                var fileName = $"{score.記録日時.ToString("yyyyMMdd_HHmmss")}.png";
                var fullpath = Path.Combine(_directory.FullName, fileName);

                bitmap.Save(fullpath, ImageFormat.Png);
            });
        }
Ejemplo n.º 16
0
        public Score GetScore(int idUser, int idCategory)
        {
            ScoreEntity se = data.ScoreEntities.First(x => x.IdUser == idUser && x.IdCategory == idCategory);

            return(new Score()
            {
                IdCategory = idCategory,
                IdUser = idUser,
                Total = se.Total,
                Correct = se.Correct
            });
        }
Ejemplo n.º 17
0
 public ScoreDomainModel(ScoreEntity scoreEntity)
 {
     Id             = scoreEntity.Id;
     Name           = scoreEntity.Name;
     EvaluationId   = scoreEntity.EvaluationId;
     Date           = scoreEntity.Date;
     PointsPossible = scoreEntity.PointsPossible;
     PointsEarned   = scoreEntity.PointsEarned;
     PointsGrade    = scoreEntity.PointsGrade;
     LastModified   = scoreEntity.LastModified;
     CreatedOn      = scoreEntity.CreatedOn;
 }
Ejemplo n.º 18
0
        public async Task SaveAsLatestScoreAsync(string format, ScoreEntity score)
        {
            CreateDirectoryIfNotExists();

            var fullpath = GetLatestScoreFilePath();

            using (var sw = new StreamWriter(fullpath, false, Encoding.UTF8))
            {
                var text = ScoreTextFormatter.ToString(format, score);

                await sw.WriteLineAsync(text);
            }
        }
Ejemplo n.º 19
0
 public void AddNewScore(string player, int level, int time, int step)
 {
     using (var dbContext = new EnigmaDataContext())
     {
         ScoreEntity score = new ScoreEntity();
         score.Player = player;
         score.Level  = level;
         score.Time   = time;
         score.Step   = step;
         dbContext.Scores.Add(score);
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 20
0
 public void UpdateScore(string player, int level, int time, int step)
 {
     using (var dbContext = new EnigmaDataContext())
     {
         ScoreEntity score = dbContext.Scores.SingleOrDefault(c => c.Player.ToLower() == player.ToLower() && c.Level == level);
         if (score != null)
         {
             score.Level = level;
             score.Time  = time;
             score.Step  = step;
             dbContext.SaveChanges();
         }
     }
 }
Ejemplo n.º 21
0
        public Guid CreateScore(ScoreEntity newScore)
        {
            var existingScore = GetExistingRecord(newScore.EvaluationId, newScore.Name);

            if (existingScore != null)
            {
                throw new ObjectAlreadyExistsException("There is already a Score for that Evaluation with that Name.");
            }

            ValidateNewScore(newScore);

            newScore.Id = Guid.NewGuid();

            return(Repo.Create(newScore));
        }
Ejemplo n.º 22
0
        public void InsertTest1()
        {
            var newData = new ScoreEntity()
            {
                GameId = 4, Score = 2000, RegistDate = DateTime.Now.AddDays(3)
            };

            TestData.ScoreTestData.Add(newData);

            var result = _serv.Insert(newData);

            var check = _serv.Select(newData).First().ToString();

            Assert.True(result && check.Equals(newData.ToString()));
        }
Ejemplo n.º 23
0
    private void UpdateLocalTable(ScoreEntity current)
    {
        //TODO make this more efficient
        int oldIndex = rankings.IndexOf(new ScoreEntity(SystemInfo.deviceUniqueIdentifier, SystemInfo.deviceName));

        if (oldIndex >= 0)
        {
            rankings.RemoveAt(oldIndex);
        }

        rankings.Add(current);
        SortRankings();

        PlayerRanking      = rankings.IndexOf(current) + 1;
        TotalRankingsCount = rankings.Count;
    }
Ejemplo n.º 24
0
        public void UpdateScore(ScoreEntity updatedScore)
        {
            var existingScore = Repo.GetById(updatedScore.Id);

            if (existingScore != null)
            {
                existingScore.PointsEarned   = updatedScore.PointsEarned;
                existingScore.PointsPossible = updatedScore.PointsPossible;
                existingScore.PointsGrade    = updatedScore.PointsGrade;
                existingScore.Date           = updatedScore.Date;
                existingScore.Name           = updatedScore.Name;
                existingScore.LastModified   = DateTime.Now;

                Repo.Update(existingScore);
            }
            else
            {
                throw new ObjectNotFoundException("There is no Score with that ID.");
            }
        }
Ejemplo n.º 25
0
    public async void AttemptWriteScore(Inventory inventory)
    {
        Score currentScore = inventory.ToScore();

        ScoreEntity scoreEntity = new ScoreEntity(SystemInfo.deviceUniqueIdentifier, SystemInfo.deviceName);

        scoreEntity.FromScore(currentScore);

        if (currentScore > maxScore)
        {
            Task <ScoreEntity> write = WriteScore(scoresTable, scoreEntity);

            UpdateLocalTable(scoreEntity);
            if (machineToNameMap.ContainsKey(SystemInfo.deviceName))
            {
                OnScoreIncrease?.Invoke();
            }

            await write;
        }
    }
Ejemplo n.º 26
0
        public void UpdateScore_ValidObject_UpdatesScore()
        {
            var evalGuid      = Guid.NewGuid();
            var testList      = ScoreFactory.Create_ListOfScoreEntity(evalGuid);
            var testRepo      = new MockRepository <ScoreEntity>(testList);
            var testClass     = InteractorFactory.Create_ScoreInteractor(testRepo);
            var scoreToUpdate = testRepo.GetAll().First();

            var updatedScore = new ScoreEntity {
                Id = scoreToUpdate.Id, PointsPossible = 5, PointsEarned = 4, PointsGrade = .8
            };

            testClass.UpdateScore(updatedScore);

            var result = testClass.GetScore(scoreToUpdate.Id);

            result.LastModified.ShouldNotBeSameAs(scoreToUpdate.LastModified);
            result.PointsEarned.ShouldBe(4);
            result.PointsPossible.ShouldBe(5);
            result.PointsGrade.ShouldBe(.8);
        }
Ejemplo n.º 27
0
        void IInitializable.Initialize()
        {
            ScoreEntity
            .Current
            .Subscribe(GameScoreRenderable.RenderScore);
            GameStateEntity
            .RemainingTime
            .Where(x => x < 0.0f)
            .First()
            .Subscribe(_ => StopGame());
            GameStateEntity.WillStartSubject.Subscribe(_ => StartGame());
            GameStateEntity.WillStopSubject.Subscribe(_ => StopGame());
            GameStateEntity.WillPauseSubject.Subscribe(_ => PauseGame());
            GameStateEntity.WillResumeSubject.Subscribe(_ => ResumeGame());
            GameStateEntity.WillFinishSubject.Subscribe(_ => FinishGame());
            GameStateEntity.AttackSubject.WhenDid().Subscribe(_ => ScoreEntity.Increment());

            Observable
            .Timer(TimeSpan.FromSeconds(1.0))
            .AsUnitObservable()
            .Subscribe(GameStateEntity.WillStartSubject.OnNext);
        }
Ejemplo n.º 28
0
 public static string ToString(string format, ScoreEntity score)
 {
     return(format
            .Replace(WarResultFormat, score.結果)
            .Replace(WarSideFormat, score.攻守)
            .Replace(OffenseCountryFormat, score.攻撃側国名)
            .Replace(DeffenseFormat, score.防衛側国名)
            .Replace(MapFormat, score.Map名)
            .Replace(WorkFormat, score.職業)
            .Replace(WarTimeFormat, score.戦争継続時間.ToString("mm\\:ss"))
            .Replace(BattleScoreFormat, score.戦闘)
            .Replace(RegionScoreFormat, score.領域)
            .Replace(SupportScoreFormat, score.支援)
            .Replace(PCDFormat, score.PC与ダメージ)
            .Replace(PCDKilloFormat, ToKillo(score.PC与ダメージ))
            .Replace(KillDamageBonusFormat, score.キルダメージボーナス)
            .Replace(SummonReleaseBonusFormat, score.召喚解除ボーナス)
            .Replace(BDFormat, score.建築与ダメージ)
            .Replace(BDKilloFormat, ToKillo(score.建築与ダメージ))
            .Replace(RegionDestroyBonusFormat, score.領域破壊ボーナス)
            .Replace(RegionDamageBonusFormat, score.領域ダメージボーナス)
            .Replace(ContributionScoreFormat, score.貢献度)
            .Replace(CrystalInvestmentBonusFormat, score.クリスタル運用ボーナス)
            .Replace(SummonBonusFormat, score.召喚行動ボーナス)
            .Replace(KillCountFormat, score.キル数)
            .Replace(DeadCountFormat, score.デッド数)
            .Replace(BuildCountFormat, score.建築数)
            .Replace(BuildDestroyCountFormat, score.建築物破壊数)
            .Replace(CrystalMiningFormat, score.クリスタル採掘量)
            .Replace(Skill1Format, score.スキル1)
            .Replace(Skill2Format, score.スキル2)
            .Replace(Skill3Format, score.スキル3)
            .Replace(Skill4Format, score.スキル4)
            .Replace(Skill5Format, score.スキル5)
            .Replace(Skill6Format, score.スキル6)
            .Replace(Skill7Format, score.スキル7)
            .Replace(Skill8Format, score.スキル8));
 }
 /// <summary>
 /// No hay ningún comentario para ScoreEntities en el esquema.
 /// </summary>
 public void AddToScoreEntities(ScoreEntity scoreEntity)
 {
     base.AddObject("ScoreEntities", scoreEntity);
 }
Ejemplo n.º 30
0
        public ScoreEntity Analyze(Bitmap screenBitmap)
        {
            /*
             * 解析のフロー
             * 1. 画像から戦績結果ウィンドウが表示されているはずの領域を切り抜く
             *      → スコア画面は解像度に依存せず、一定の大きさで、なおかつ画面中央に表示される。
             *         そのため、画像の中心座標から一定の範囲を切り抜いて以降で用いる。
             *
             * 2. FEZ画面かどうかをチェックする
             *      → 切り抜いた画像の特定の座標が想定される色かどうかチェックする。
             *         この後に行うOCRは処理が重いため、戦績結果ウィンドウではない画像をこの時点で弾く。
             *         (もし偶然このチェックが通ってしまった場合はOCRの結果から判断する)
             *
             * 3. OCR実行
             *      → スコア表示部分はフォントが異なるため、それぞれのフォント向けの解析処理クラスを用いて解析を実施する。
             *         解析処理クラスのアルゴリズムについては /doc/OCR_Algorithm.md を参照のこと。
             */

            // 1. 画像から戦績結果ウィンドウが表示されているはずの領域を切り抜く
            using (var bitmap = ClipResult(screenBitmap))
            {
                // 2. FEZ画面かどうかをチェック
                if (!IsFezResultWindow(bitmap))
                {
                    return(null);
                }

                ScoreEntity ret = null;

                // 3. OCR実行
                try
                {
                    var score = new ScoreEntity();

                    // マップ名 (画像は切り抜く前の画像)
                    score.Map名 = Scan(_mapNameOcr, screenBitmap, ScoreRectTable[nameof(ScoreEntity.Map名)]) ?? "不明";

                    // 時間
                    score.記録日時 = DateTime.Now;

                    // 戦争結果
                    score.結果 = ScanWarResult(bitmap);

                    // 攻守
                    score.攻守 = ScanWarSide(bitmap);

                    // 国名
                    score.攻撃側国名 = ScanCountry(OffenseCountryPoint, bitmap);
                    score.防衛側国名 = ScanCountry(DefenseCountryPoint, bitmap);

                    // 戦争経過時間
                    score.戦争継続時間 = Scan(_warTimeOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.戦争継続時間)]);

                    // 合計スコア
                    //   総力戦の間はこれらの値が取得できないため、こららの値で読み取りが失敗してもそのまま解析を継続する
                    score.戦闘 = ScanCatchOcrFailedExeption(_totalOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.戦闘)]);
                    score.領域 = ScanCatchOcrFailedExeption(_totalOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.領域)]);
                    score.支援 = ScanCatchOcrFailedExeption(_totalOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.支援)]);

                    // 詳細スコア
                    score.PC与ダメージ     = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.PC与ダメージ)]);
                    score.キルダメージボーナス  = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.キルダメージボーナス)]);
                    score.召喚解除ボーナス    = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.召喚解除ボーナス)]);
                    score.建築与ダメージ     = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.建築与ダメージ)]);
                    score.領域破壊ボーナス    = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.領域破壊ボーナス)]);
                    score.領域ダメージボーナス  = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.領域ダメージボーナス)]);
                    score.貢献度         = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.貢献度)]);
                    score.クリスタル運用ボーナス = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.クリスタル運用ボーナス)]);
                    score.召喚行動ボーナス    = Scan(_detailOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.召喚行動ボーナス)]);

                    // キル数など
                    score.キル数      = Scan(_killOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.キル数)]);
                    score.デッド数     = Scan(_killOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.デッド数)]);
                    score.建築数      = Scan(_killOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.建築数)]);
                    score.建築物破壊数   = Scan(_killOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.建築物破壊数)]);
                    score.クリスタル採掘量 = Scan(_killOcr, bitmap, ScoreRectTable[nameof(ScoreEntity.クリスタル採掘量)]);

                    // スキル (画像は切り抜く前の画像)
                    score.スキル1 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル1)]) ?? "不明";
                    score.スキル2 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル2)]) ?? "不明";
                    score.スキル3 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル3)]) ?? "不明";
                    score.スキル4 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル4)]) ?? "不明";
                    score.スキル5 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル5)]) ?? "不明";
                    score.スキル6 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル6)]) ?? "不明";
                    score.スキル7 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル7)]) ?? "不明";
                    score.スキル8 = ScanSkill(screenBitmap, SkillRectTable[nameof(ScoreEntity.スキル8)]) ?? "不明";

                    // 職業
                    score.職業 = ScanWork(
                        score.スキル1, score.スキル2, score.スキル3, score.スキル4,
                        score.スキル5, score.スキル6, score.スキル7, score.スキル8);

                    ret = score;
                }
                catch (OcrFailedException)
                { }
                catch
                {
                    throw;
                }

                return(ret);
            }
        }
Ejemplo n.º 31
0
        public static ScoreEntity TranslateAsScoreEntity(Score score)
        {
            var scoreEntity = new ScoreEntity(score.ScoreNum);

            return(scoreEntity);
        }
 /// <summary>
 /// Crear un nuevo objeto ScoreEntity.
 /// </summary>
 /// <param name="idUser">Valor inicial de IdUser.</param>
 /// <param name="idCategory">Valor inicial de IdCategory.</param>
 /// <param name="correct">Valor inicial de Correct.</param>
 /// <param name="total">Valor inicial de Total.</param>
 public static ScoreEntity CreateScoreEntity(int idUser, int idCategory, int correct, int total)
 {
     ScoreEntity scoreEntity = new ScoreEntity();
     scoreEntity.IdUser = idUser;
     scoreEntity.IdCategory = idCategory;
     scoreEntity.Correct = correct;
     scoreEntity.Total = total;
     return scoreEntity;
 }