Exemple #1
0
        internal override void Init(CountersData data, Vector3 position)
        {
            _scoreController = data.ScoreController;
            PlayerDataModel player = data.PlayerData;

            gameplayModsModel = data.ModifiersData;
            gameplayMods      = data.PlayerData.playerData.gameplayModifiers;
            IDifficultyBeatmap beatmap = data.GCSSD.difficultyBeatmap;

            stats = player.playerData.GetPlayerLevelStatsData(
                beatmap.level.levelID, beatmap.difficulty, beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
            int maxRawScore = ScoreModel.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.notesCount);

            _maxPossibleScore = Mathf.RoundToInt(maxRawScore * gameplayModsModel.GetTotalMultiplier(gameplayMods));
            beginningPB       = stats.highScore / (float)_maxPossibleScore;
            highScore         = stats.highScore;

            TextHelper.CreateText(out _PbTrackerText, position);
            _PbTrackerText.fontSize  = settings.TextSize;
            _PbTrackerText.color     = Color.white;
            _PbTrackerText.alignment = TextAlignmentOptions.Center;

            _scoreController.scoreDidChangeEvent += UpdateScore;

            SetPersonalBest(beginningPB);

            if (settings.UnderScore)
            {
                StartCoroutine(WaitForScoreCounter());
            }
        }
Exemple #2
0
        public void ScoreModel_Set_Default_Should_Pass()
        {
            // Arrange

            // Act
            var result = new ScoreModel();

            result.BattleNumber          = 100;
            result.ScoreTotal            = 200;
            result.GameDate              = System.DateTime.MinValue;
            result.AutoBattle            = true;
            result.TurnCount             = 300;
            result.RoundCount            = 400;
            result.MonsterSlainNumber    = 500;
            result.ExperienceGainedTotal = 600;
            result.CharacterAtDeathList  = "characters";
            result.MonstersKilledList    = "monsters";
            result.ItemsDroppedList      = "items";

            // Reset

            // Assert
            Assert.AreEqual(100, result.BattleNumber);
            Assert.AreEqual(200, result.ScoreTotal);
            Assert.AreEqual(System.DateTime.MinValue, result.GameDate);
            Assert.AreEqual(true, result.AutoBattle);
            Assert.AreEqual(300, result.TurnCount);
            Assert.AreEqual(400, result.RoundCount);
            Assert.AreEqual(500, result.MonsterSlainNumber);
            Assert.AreEqual(600, result.ExperienceGainedTotal);
            Assert.AreEqual("characters", result.CharacterAtDeathList);
            Assert.AreEqual("monsters", result.MonstersKilledList);
            Assert.AreEqual("items", result.ItemsDroppedList);
        }
Exemple #3
0
        public async Task ScoreIndexViewModel_CheckIfScoreExists_InValid_Missing_Should_Fail()
        {
            // Arrange

            // Add Scores into the list Z ordered
            var dataTest = new ScoreModel {
                Name = "test"
            };
            // Don't add it to the list await ViewModel.CreateAsync(dataTest);

            await ViewModel.CreateAsync(new ScoreModel { Name = "z" });

            await ViewModel.CreateAsync(new ScoreModel { Name = "m" });

            await ViewModel.CreateAsync(new ScoreModel { Name = "a" });

            // Act
            var result = ViewModel.CheckIfScoreExists(dataTest);

            // Reset
            await ResetDataAsync();

            // Assert
            Assert.AreEqual(null, result);
        }
    private void Awake()
    {
        StartCoroutine(SpawnPerkAfterTime(15));
        mCloneObstacle = GameObject.FindGameObjectWithTag("ClonaObstacol");

        // Se updateaza scorul maxim
        mHighestScore = DatabaseModel.Instance.GetMaxScore();


        // Configuratie initiala
        Time.timeScale = 1f;
        mPlayButton.onClick.AddListener(RestartGame);
        mGameIsPaused   = false;
        mScoreText.text = "Score: " + 0;
        mGameIsOver     = false;
        mGameOverPanel.SetActive(false);
        mPausePanel.SetActive(false);
        // Se calculeaza dimensiunile ecranului
        Vector2 topRightCorner = new Vector2(1, 1);
        Vector2 edgeVector     = Camera.main.ViewportToWorldPoint(topRightCorner); // Contine coordonatele coltului dreapta-sus al ecranului in starea initiala

        mScreenHeight = edgeVector.y * 2;
        mScreenWidth  = edgeVector.x * 2;

        // Se calculeaza marginile impreuna cu alte dimensiuni pentru calcule ulterioare
        mWallBoundsSize     = GameObject.FindGameObjectWithTag("PereteDreaptaBase").GetComponent <BoxCollider2D>().bounds.size; // .x = width , .y = height, .z = depth of the gameobject
        mThirdPercentHeight = 0.33f * mScreenHeight;
        mThirdPercentWidth  = 0.33f * (mScreenWidth - 2 * mWallBoundsSize.x);
        mOffsetFromWalls    = mCloneObstacle.transform.Find("HorizontalColider").GetComponent <BoxCollider2D>().bounds.size.x / 2f + 0.3f; //!!!!!!!
        mScreenLeftMarginX  = (mCamera.transform.position.x - (mScreenWidth - 2 * mWallBoundsSize.x) / 2f);
        mScreenRightMarginX = (mCamera.transform.position.x + (mScreenWidth - 2 * mWallBoundsSize.x) / 2f);
    }
Exemple #5
0
 public override void beginState()
 {
     pausable_object.OnResume();
     ScoreModel.getInstance().StartTimer();
     creator.enableCreator = true;
     this.toolCanvas.GetComponent <Canvas>().enabled = true;
 }
Exemple #6
0
        public override void CounterInit()
        {
            ColorUtility.TryParseHtmlString("#FFA500", out orange);

            modifiersModel = SCGameplayModsModel(ref scoreController);
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;
            int maxRawScore            = ScoreModel.MaxRawScoreForNumberOfNotes(noteCountProcessor.NoteCount);

            maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore,
                                                                                              modifiersModel.GetTotalMultiplier(data.gameplayModifiers));
            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID);
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale));
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            SetPersonalBest((float)highScore / maxPossibleScore);
        }
Exemple #7
0
        public async Task ScoreIndexViewModel_CheckIfScoreExists_Default_Should_Pass()
        {
            // Arrange

            // Add Scores into the list Z ordered
            var dataTest = new ScoreModel {
                Name = "test"
            };
            await ViewModel.CreateAsync(dataTest);

            await ViewModel.CreateAsync(new ScoreModel { Name = "z" });

            await ViewModel.CreateAsync(new ScoreModel { Name = "m" });

            await ViewModel.CreateAsync(new ScoreModel { Name = "a" });

            // Act
            var result = ViewModel.CheckIfScoreExists(dataTest);

            // Reset
            await ResetDataAsync();

            // Assert
            Assert.AreEqual(dataTest.Id, result.Id);
        }
        public async Task <string> SubmitScoreAsync(ScoreModel scoreModel)
        {
            // Increases user score in Redis
            await _redisServer.Database.HashIncrementAsync(scoreModel.user_id, "points", scoreModel.score_worth);

            // Adds/updates user score timestamp to current time in Redis
            await _redisServer.Database.HashSetAsync(scoreModel.user_id, "timestamp", scoreModel.timestamp.ToString());

            // Gets updated user from Redis
            var user = await _redisServer.Database.HashGetAsync(key : scoreModel.user_id, new RedisValue[] { new RedisValue("country").ToString(), new RedisValue("display_name").ToString(), new RedisValue("points").ToString() });

            // Adds/updates user in global leaderboard
            await _redisServer.Database.SortedSetAddAsync(leaderboardkey, member : scoreModel.user_id, score : Convert.ToDouble(user[2]));

            // Adds/updates user in country leaderboard
            await _redisServer.Database.SortedSetAddAsync(key : user[0].ToString(), member : scoreModel.user_id, score : Convert.ToDouble(user[2]));

            //Go Db to update user
            await _userService.UpdateUserAsync(scoreModel.user_id, scoreModel.score_worth, scoreModel.timestamp);


            var returnModel = new UserModel()
            {
                display_name = user[1].ToString(),
                points       = Convert.ToDouble(user[2]),
                country      = user[0].ToString(),
                timestamp    = scoreModel.timestamp.ToString()
            };

            var settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;

            return(JsonConvert.SerializeObject(returnModel, settings));
        }
Exemple #9
0
        private ScoreModel GetScores(DateTime?fixtureDate)
        {
            using (var context = new FcDeHoekContext())
            {
                if (fixtureDate == null)
                {
                    fixtureDate = DateTime.Now.GetFirstDayOfWeek(CultureInfo.CurrentCulture);
                }

                var allGames     = GameQueries.GetAllGamesByIdSeason(context, SeasonQueries.GetSeasonByDate(context, (DateTime)fixtureDate)?.IdSeason ?? SeasonQueries.GetCurrentSeason(context).IdSeason).OrderBy(g => g.MatchDate).ToList();
                var allPlayWeeks = new List <DateTime>();
                foreach (var game in allGames)
                {
                    if (!allPlayWeeks.Contains(game.MatchDate))
                    {
                        allPlayWeeks.Add(game.MatchDate);
                    }
                }

                var model = new ScoreModel
                {
                    AllFixtureDates = allPlayWeeks,
                    Games           = GetGameModels(context, (DateTime)fixtureDate)
                };

                model.FixtureDate = model.Games.FirstOrDefault()?.MatchDay ?? DateTime.Now;

                return(model);
            }
        }
Exemple #10
0
        public ResponseData <ScoreModelPostResponse> Post([FromBody] ScoreModel score)
        {
            ResponseData <ScoreModelPostResponse> resp = new ResponseData <ScoreModelPostResponse>();

            try
            {
                Score sco = AutoMapperFacade.Map <Score>(score);
                SubmitScoreCommandData data = new SubmitScoreCommandData(sco);
                submitScore.Handle(data);
                sco = data.score;
                ScoreModelPostResponse respScore = new ScoreModelPostResponse()
                {
                    ID = sco.ID, IsNewRecord = data.IsNewRecord, Ranking = sco.GetRankingByScore()
                };
                respScore.Player = AutoMapperFacade.Map <UserModelResponse>(data.user);
                resp.Data        = respScore;
                resp.Message     = "Registro efetuado com sucesso!";
                resp.Success     = true;
            }
            catch (Exception)
            {
                resp.Message = "Não foi possível submeter a pontuação!";
            }
            return(resp);
        }
        public void CreateScore(ScoreModel scoreModel)
        {
            var score = _mapper.Map <Score>(scoreModel);

            var topScore = GetTop10Scores().FirstOrDefault();
            var topScorePlayerAchievement = _playerAchievementRepository.Get(score.PlayerId, 3);

            if (score.Result > topScore.Result && topScorePlayerAchievement == null)
            {
                _playerAchievementRepository.Create(score.PlayerId, 3);
            }

            var score3000PlayerAchievement  = _playerAchievementRepository.Get(score.PlayerId, 2);
            var score5000PlayerAchievememnt = _playerAchievementRepository.Get(score.PlayerId, 4);

            if (score.Result >= 3000 && score3000PlayerAchievement == null)
            {
                _playerAchievementRepository.Create(score.PlayerId, 2);
            }

            if (score.Result >= 5000 && score5000PlayerAchievememnt == null)
            {
                _playerAchievementRepository.Create(score.PlayerId, 4);
            }

            _scoreRepository.Create(score);
        }
Exemple #12
0
        public void ScoreModel_Get_Default_Should_Pass()
        {
            // Arrange

            // Act
            var result = new ScoreModel();

            // Reset

            // Assert
            Assert.IsNotNull(result.BattleNumber);
            Assert.IsNotNull(result.ScoreTotal);
            Assert.IsNotNull(result.GameDate);
            Assert.IsNotNull(result.AutoBattle);
            Assert.IsNotNull(result.TurnCount);
            Assert.IsNotNull(result.RoundCount);
            Assert.IsNotNull(result.MonsterSlainNumber);
            Assert.IsNotNull(result.ExperienceGainedTotal);

            Assert.AreEqual(string.Empty, result.CharacterAtDeathList);
            Assert.AreEqual(string.Empty, result.MonstersKilledList);
            Assert.AreEqual(string.Empty, result.ItemsDroppedList);
            Assert.AreEqual(string.Empty, result.GraduateList);

            Assert.AreEqual(0, result.ItemModelDropList.Count());
            Assert.AreEqual(0, result.MonsterModelDeathList.Count());
            Assert.AreEqual(0, result.CharacterModelDeathList.Count());
            Assert.AreEqual(0, result.GraduateModelList.Count());
        }
Exemple #13
0
        public void OnNoteWasFullyCut(CutScoreBuffer acsb)
        {
            int beforeCutScore;
            int afterCutScore;
            int cutDistanceScore;

            NoteCutInfo noteCutInfo = (NoteCutInfo)noteCutInfoField.GetValue(acsb);
            NoteData    noteData    = noteCutMapping[noteCutInfo];

            noteCutMapping.Remove(noteCutInfo);

            SetNoteCutStatus(noteData, noteCutInfo, false);

            // public static ScoreModel.RawScoreWithoutMultiplier(NoteCutInfo, out int beforeCutRawScore, out int afterCutRawScore, out int cutDistanceRawScore)
            ScoreModel.RawScoreWithoutMultiplier(noteCutInfo, out beforeCutScore, out afterCutScore, out cutDistanceScore);

            int multiplier = (int)cutScoreBufferMultiplierField.GetValue(acsb);

            statusManager.gameStatus.initialScore     = beforeCutScore + cutDistanceScore;
            statusManager.gameStatus.finalScore       = beforeCutScore + afterCutScore + cutDistanceScore;
            statusManager.gameStatus.cutDistanceScore = cutDistanceScore;
            statusManager.gameStatus.cutMultiplier    = multiplier;

            statusManager.EmitStatusUpdate(ChangedProperties.PerformanceAndNoteCut, "noteFullyCut");

            acsb.didFinishEvent -= OnNoteWasFullyCut;
        }
Exemple #14
0
        public void ScoreModel_Constructor_New_Item_Should_Copy()
        {
            // Arrange
            var dataNew = new ScoreModel();

            dataNew.Id = "oldID";

            dataNew.BattleNumber          = 100;
            dataNew.ScoreTotal            = 200;
            dataNew.GameDate              = System.DateTime.MinValue;
            dataNew.AutoBattle            = true;
            dataNew.TurnCount             = 300;
            dataNew.RoundCount            = 400;
            dataNew.MonsterSlainNumber    = 500;
            dataNew.ExperienceGainedTotal = 600;
            dataNew.CharacterAtDeathList  = "characters";
            dataNew.MonstersKilledList    = "monsters";
            dataNew.ItemsDroppedList      = "items";

            // Act
            var result = new ScoreModel(dataNew);

            // Reset

            // Assert
            Assert.AreNotEqual("oldID", result.Id);
        }
        public void Cut(NoteData data, NoteCutInfo info, int combo)
        {
            notes++;
            if (!info.allIsOK)
            {
                misses++;
                UpdateText();
                return;
            }
            bool didDone = false;

            info.swingRatingCounter.didFinishEvent += e =>
            {
                if (didDone)
                {
                    return;
                }
                didDone = true;
                ScoreModel.RawScoreWithoutMultiplier(info, out int before, out int after, out int distScore);
                int total = before + after + distScore;
                for (int i = 0; i < scoreRanges.Length; i++)
                {
                    if (scoreRanges[i] < total)
                    {
                        scoreCount[i]++;
                        UpdateText();
                        return;
                    }
                }
                scoreCount[scoreRanges.Length]++;
                UpdateText();
            };
        }
        /// <summary>
        /// Returns the highest rank achieved for a level and a given list of difficulties.
        /// NOTE: this method obtains the rank by performing a calculation on the set score and assumes that no modifiers were used.
        /// </summary>
        /// <param name="level">The level to search through.</param>
        /// <param name="difficulties">A list of BeatmapDifficulties to search through. Use null to search through all difficulties.</param>
        /// <param name="characteristics">A list of characteristics to search through. Each characteristic is represented by its serialized string.
        /// Use null to search through all characteristics.</param>
        /// <param name="playerName">The name of the player on the local leaderboards (optional).</param>
        /// <returns>The highest RankModel.Rank enum found for the selected difficulties, or null if the level has not yet been completed.</returns>
        public RankModel.Rank?GetHighestRankForLevel(BeatmapDetails level, IEnumerable <BeatmapDifficulty> difficulties = null, IEnumerable <string> characteristics = null, string playerName = null)
        {
            if (difficulties == null)
            {
                difficulties = AllDifficulties;
            }
            if (characteristics == null)
            {
                characteristics = AllCharacteristicStrings;
            }

            // get any level duplicates
            List <string> duplicateLevelIDs = GetActualLevelIDs(level.LevelID);

            StringBuilder sb = new StringBuilder();

            RankModel.Rank?highestRank = null;
            foreach (var levID in duplicateLevelIDs)
            {
                foreach (var characteristic in AllCharacteristicStrings)
                {
                    var simplifiedChar = level.DifficultyBeatmapSets.FirstOrDefault(x => x.CharacteristicName == characteristic || (characteristic == "" && x.CharacteristicName == "Standard"));
                    if (simplifiedChar == null)
                    {
                        continue;
                    }

                    foreach (var difficulty in difficulties)
                    {
                        var simplifiedDiff = simplifiedChar.DifficultyBeatmaps.FirstOrDefault(x => x.Difficulty == difficulty);
                        if (simplifiedDiff == null)
                        {
                            continue;
                        }

                        sb.Clear();
                        sb.Append(levID);
                        sb.Append(characteristic);
                        sb.Append(difficulty.ToString());
                        string leaderboardID = sb.ToString();
                        var    scores        = _localLeaderboardsModel.GetScores(leaderboardID, LocalLeaderboardsModel.LeaderboardType.AllTime);

                        int maxRawScore = ScoreModel.MaxRawScoreForNumberOfNotes(simplifiedDiff.NotesCount);
                        if (scores != null)
                        {
                            var validEntries = scores.Where(x => x._score != 0 && (x._playerName == playerName || playerName == null));

                            if (validEntries.Count() > 0)
                            {
                                var validRanks = validEntries.Select(x => RankModel.GetRankForScore(x._score, x._score, maxRawScore, maxRawScore));
                                highestRank = (RankModel.Rank)Math.Max((int)(highestRank ?? RankModel.Rank.E), (int)validRanks.Max());
                            }
                        }
                    }
                }
            }

            return(highestRank);
        }
Exemple #17
0
        public void ScoreModel_Set_Default_Should_Pass()
        {
            // Arrange

            // Act
            var result = new ScoreModel();

            result.BattleNumber          = 100;
            result.ScoreTotal            = 200;
            result.GameDate              = System.DateTime.MinValue;
            result.AutoBattle            = true;
            result.TurnCount             = 300;
            result.RoundCount            = 400;
            result.MonsterSlainNumber    = 500;
            result.ExperienceGainedTotal = 600;
            result.CharacterAtDeathList  = "characters";
            result.MonstersKilledList    = "monsters";
            result.ItemsDroppedList      = "items";

            result.ItemModelDropList = new List <ItemModel> {
                new ItemModel {
                    Name = "Item"
                }
            };
            result.MonsterModelDeathList = new List <PlayerInfoModel> {
                new PlayerInfoModel(new MonsterModel())
            };
            result.CharacterModelDeathList = new List <PlayerInfoModel> {
                new PlayerInfoModel(new CharacterModel())
            };
            result.ItemModelSelectList = new List <ItemModel> {
                new ItemModel {
                    Name = "Item"
                }
            };
            result.GraduateModelList = new List <PlayerInfoModel> {
                new PlayerInfoModel(new CharacterModel())
            };

            // Reset

            // Assert
            Assert.AreEqual(100, result.BattleNumber);
            Assert.AreEqual(200, result.ScoreTotal);
            Assert.AreEqual(System.DateTime.MinValue, result.GameDate);
            Assert.AreEqual(true, result.AutoBattle);
            Assert.AreEqual(300, result.TurnCount);
            Assert.AreEqual(400, result.RoundCount);
            Assert.AreEqual(500, result.MonsterSlainNumber);
            Assert.AreEqual(600, result.ExperienceGainedTotal);
            Assert.AreEqual("characters", result.CharacterAtDeathList);
            Assert.AreEqual("monsters", result.MonstersKilledList);
            Assert.AreEqual("items", result.ItemsDroppedList);

            Assert.AreEqual("Item", result.ItemModelDropList.ElementAt(0).Name);
            Assert.AreEqual("Item", result.ItemModelSelectList.ElementAt(0).Name);
            Assert.AreEqual(PlayerTypeEnum.Monster, result.MonsterModelDeathList.ElementAt(0).PlayerType);
            Assert.AreEqual(PlayerTypeEnum.Character, result.CharacterModelDeathList.ElementAt(0).PlayerType);
        }
Exemple #18
0
 public override void prepareBeginState()
 {
     Initializer.getInstance().InitializeAll();
     pausable_object.OnPause();
     ScoreModel.getInstance().StopTimer();
     this.toolCanvas.GetComponent <Canvas>().enabled = false;
     BgmManager.Instance.Play("bo-ken");
 }
 public ScoreModel Put(ScoreModel entity)
 {
     if (_scoretService.Edit(entity) == ReturnResultEnum.EnumResult.success)
     {
         return(entity);
     }
     return(null);
 }
Exemple #20
0
 private void Load()
 {
     scoreModel = (ScoreModel)FileTool.ReadSaveFile(saveFilePath);
     if (scoreModel == null)
     {
         scoreModel = new ScoreModel();
     }
 }
Exemple #21
0
 public static ScoreModel getInstance()
 {
     if (__instance == null)
     {
         __instance = new ScoreModel();
     }
     return(__instance);
 }
Exemple #22
0
        private Score Map(ScoreModel model)
        {
            var entity = _mapper.Map <ScoreModel, Score>(model);

            entity.ScoreResult = (ScoreResultEntity)model.ScoreResult;
            entity.StudentId   = model.StudentModel.Id;
            return(entity);
        }
Exemple #23
0
 public static ScoreModel GetInstance()
 {
     if (s_ScoreModel == null)
     {
         s_ScoreModel = new ScoreModel();
     }
     return(s_ScoreModel);
 }
Exemple #24
0
        public async Task AddScores(ScoreModel model, string accessToken)
        {
            var baseUrl = AppSettingsProvider.LoyaltyBaseUrl;
            var api     = AppSettingsProvider.AddScores;

            var messageBody = JsonConvert.SerializeObject(model);
            await _httpHandler.AuthPutAsync(accessToken, baseUrl, api, messageBody);
        }
Exemple #25
0
        public JsonResult Update(ScoreModel model)
        {
            model.ModifyBy = long.Parse(Session["UserId"].ToString());

            bool status = scoreService.Update(model.ToModel());

            return(Json(status, JsonRequestBehavior.AllowGet));
        }
Exemple #26
0
        public void Init(ScoreModel scoreModel)
        {
            _rankingModel = new RankingModel(scoreModel);
            _rankingView.Init();


            Bind();
        }
Exemple #27
0
        private void SwingRatingCounter_didFinishEvent(ISaberSwingRatingCounter SaberSwingRatingCounter)
        {
            ScoreModel.RawScoreWithoutMultiplier(noteCutInfo, out int beforeCutRawScore, out int afterCutRawScore, out int cutDistanceRawScore);
            int blockScoreWithoutModifier = beforeCutRawScore + afterCutRawScore + cutDistanceRawScore;

            LiveData.BlockHitScores.Add(blockScoreWithoutModifier);
            //LiveData.Send();
        }
    // Use this for initialization
    void Start()
    {
        ScoreManager sm = InformationManager.instance.getScoreManager();

        for (int i = 0; i < graphs.Count; i++)
        {
            SpriteGraph gg     = graphs[i];
            int         id     = gg.playerId;
            ScoreModel  points = sm.getScoreModel(id);

            if (points != null)
            {
                gg.setPoints(points);
            }
        }

        for (int i = 0; i < journals.Count; i++)
        {
            ShowScore  ss     = journals[i];
            int        id     = ss.playerId;
            ScoreModel points = sm.getScoreModel(id);
            if (points != null)
            {
                ss.setPoints(points);
            }
        }

        List <ScoreModel> sortedScores = BubbleSort.Sort(sm.getScoreModels());

        sortedScores.Reverse();

        int maxTrophys = 3;

        if (sortedScores.Count < maxTrophys)
        {
            maxTrophys = sortedScores.Count;
        }

        for (int index = 0; index < trophyPanels.Count; index++)
        {
            trophyPanels[index].SetActive(false);
        }

        for (int index = 0; index < maxTrophys; index++)
        {
            trophyPanels[index].SetActive(true);
            trophyNames[index].text = InformationManager.instance.getPlayerById(sortedScores[index].getPlayerId()).getName();
            trophyScore[index].text = sortedScores[index].getScore().ToString();
        }

        List <ScoreModel> rankings = ScoreManager.instance.getRanking();

        for (float i = InformationManager.instance.getPlayerSize(); i < PlayerGraph.Length; i++)
        {
            PlayerGraph[(int)i].SetActive(false);
            PlayerJournal[(int)i].SetActive(false);
        }
    }
Exemple #29
0
        public void OnNoteWasCut(NoteData noteData, NoteCutInfo noteCutInfo, int multiplier)
        {
            // Event order: combo, multiplier, scoreController.noteWasCut, (LateUpdate) scoreController.scoreDidChange, afterCut, (LateUpdate) scoreController.scoreDidChange

            var gameStatus = statusManager.gameStatus;

            SetNoteCutStatus(noteData, noteCutInfo, true);

            int beforeCutScore   = 0;
            int afterCutScore    = 0;
            int cutDistanceScore = 0;

            ScoreModel.RawScoreWithoutMultiplier(noteCutInfo, out beforeCutScore, out afterCutScore, out cutDistanceScore);

            gameStatus.initialScore     = beforeCutScore + cutDistanceScore;
            gameStatus.finalScore       = -1;
            gameStatus.cutDistanceScore = cutDistanceScore;
            gameStatus.cutMultiplier    = multiplier;

            if (noteData.noteType == NoteType.Bomb)
            {
                gameStatus.passedBombs++;
                gameStatus.hitBombs++;

                statusManager.EmitStatusUpdate(ChangedProperties.PerformanceAndNoteCut, "bombCut");
            }
            else
            {
                gameStatus.passedNotes++;

                if (noteCutInfo.allIsOK)
                {
                    gameStatus.hitNotes++;

                    statusManager.EmitStatusUpdate(ChangedProperties.PerformanceAndNoteCut, "noteCut");
                }
                else
                {
                    gameStatus.missedNotes++;

                    statusManager.EmitStatusUpdate(ChangedProperties.PerformanceAndNoteCut, "noteMissed");
                }
            }

            List <CutScoreBuffer> list = (List <CutScoreBuffer>)afterCutScoreBuffersField.GetValue(scoreController);

            foreach (CutScoreBuffer acsb in list)
            {
                if (noteCutInfoField.GetValue(acsb) == noteCutInfo)
                {
                    // public CutScoreBuffer#didFinishEvent<CutScoreBuffer>
                    noteCutMapping.Add(noteCutInfo, noteData);

                    acsb.didFinishEvent += OnNoteWasFullyCut;
                    break;
                }
            }
        }
Exemple #30
0
        private void ClassificationButton_Click(object sender, EventArgs e)
        {
            List <Data> Trainingdataset = Utility.LoadDataset(DatasetType.Training);
            TrainModel  train           = null;

            if (comboBox1.SelectedIndex == 0)
            {
                train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.Bayesian);
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.KNearestNeighbour);
            }
            train.Train(Trainingdataset);
            OpenFileDialog f = new OpenFileDialog();

            if (DialogResult.OK == f.ShowDialog())
            {
                ScoreModel     score    = new ScoreModel(train, int.Parse(KNNTextBox.Text));
                List <Vector2> features = Utility.LoadPoints(f.FileName);

                int estimatedClass = score.Classify(features);
                ExpectedClassLabel.Text = estimatedClass.ToString();
                AppModel app = new AppModel(@"C:\Program Files (x86)\Notepad++\notepad++.exe");
                try
                {
                    if (estimatedClass == 0)
                    {
                        app.Close();
                    }
                    else if (estimatedClass == 1)
                    {
                        app.Minimize();
                    }
                    else if (estimatedClass == 2)
                    {
                        app.Open();
                    }
                    else if (estimatedClass == 3)
                    {
                        app.Restore();
                    }
                }
                catch
                {
                    MessageBox.Show("Couldn't take that action, please make sure that the specified program is already opened");
                }
            }

            /*for(int i=0;i<40;)
             * {
             *  Vector2 a = new Vector2();
             *  a.x = double.Parse(inputarr[i++].Text);
             *  a.y = double.Parse(inputarr[i++].Text);
             *  features.Add(a);
             * }*/
        }
 public ScoreController()
 {
     scoreModel = new ScoreModel();
     scoreView = new ScoreView( this );
 }
    void Start()
    {
        Vector2 resolution = new Vector2(Camera.main.pixelWidth, Camera.main.pixelHeight);
        FieldSize = FieldConstants.FieldSize(resolution);

        score = new ScoreModel();
        radmolePool = gameObject.GetComponent<ObjectPool>();
        fieldUIController = GameObject.FindObjectOfType<FieldUIController>() as FieldUIController;

        FieldController.DestroyedMole.AsObservable().Subscribe(_ =>
                {
                    if (gameOver) return;
                    fieldUIController.Score.Value = ++score.Score;
                });
        FieldController.GameOver.AsObservable().Subscribe(OnGameOver);

        TileController.LoadTiles();

        for (int x = (int)-FieldSize.x; x < (int)FieldSize.x + 1; x++)
        {
            for (int y = (int)-FieldSize.y; y < (int)FieldSize.y + 1; y++)
            {
                GameObject tile = GameObject.Instantiate(TilePrefab);
                TileController tileController = tile.GetComponent<TileController>();
                tile.transform.SetParent(TileRoot.transform, false);

                tile.transform.localPosition = new Vector3(x * FieldConstants.TileWidth,
                                                           y * FieldConstants.TileHeight,
                                                           0);
                tileController.Setup();
            }
        }

        StartCoroutine(SpawnMoles());
    }