예제 #1
0
        public IEnumerator AnalyzeAndScorePixelMapWithEnumeratorPasses()
        {
            //open images in dir test_images and read expected results from file names
            var images         = new List <Color[]>();
            var expectedScores = new List <int>();

            //read all pngs, convert to color[] and store in images, parse expected results from filename and store in expectedScores
            foreach (var file in Directory.EnumerateFiles("./Assets/Tests/EditMode/test_images", "*.png"))
            {
                var fileInBytes = File.ReadAllBytes(file);
                var texture     = new Texture2D(2, 2);
                texture.LoadImage(fileInBytes);
                images.Add(texture.GetPixels());
                //remove folder paths
                var scoreInt = Path.GetFileName(file);
                expectedScores.Add(Int32.Parse(scoreInt.Replace(".png", "")));
            }

            //check if files are read correctly
            Assert.AreEqual(images.Count, expectedScores.Count, "could not read expected values from file names");
            Assert.AreNotSame(images.Count, 0, "no images found");

            // analyze, calculate score and compare
            for (int i = 0; i < images.Count; i++)
            {
                var analyzedResult = ScoreCalculation.AnalyzePixelMap(images[i]);
                Assert.NotNull(analyzedResult, "ScoreCalculation returned null");
                var score = ScoreCalculation.CalculateScore(analyzedResult);
                Assert.AreEqual(score, expectedScores[i], "score calculation returned unexpected result");
            }

            return(null);
        }
예제 #2
0
        public void AddGame(Game game)
        {
            this.GamesPlayed.Add(game);
            ScoreCalculation scoreCalculation = new ScoreCalculation(game);

            this.AddScore(scoreCalculation.CalculateHomeTeamScore());
            this.AddScore(scoreCalculation.CalculateGuestTeamScore());
        }
예제 #3
0
    public void EndGame(int time, int score, bool won)
    {
        gameObject.SetActive(true);
        EndGameReason.GetComponentInChildren <Text>().text = won ? "You have won by killing all the monsters. Congratulations." : "You tried to kill a monster with red color, you lost.";
        int result = score - time + (won ? 10 : 0);

        ScoreCalculation.GetComponentInChildren <Text>().text = "Score " + result + " pt\ncalculation: score (" + score + " pt) - time (" + time + " pt)" + (won ? "+ win (10 pt)" : "") + " = " + result + " pt";
    }
예제 #4
0
        public void AddGame(Game game)
        {
            this.GamesPlayed++;
            ScoreCalculation scoreCalculation = new ScoreCalculation(game);
            Score            homeScore        = scoreCalculation.CalculateHomeTeamScore();
            Score            guestScore       = scoreCalculation.CalculateGuestTeamScore();

            this.GoalsScored      = this.GoalsScored + homeScore.Goals + guestScore.Goals;
            this.HomeGoalsScored  = this.HomeGoalsScored + homeScore.Goals;
            this.GuestGoalsScored = this.GuestGoalsScored + guestScore.Goals;
            this.HomePoints       = this.HomePoints + homeScore.Points;
            this.GuestPoints      = this.GuestPoints + guestScore.Points;

            switch (homeScore.Result)
            {
            case EScoreResult.Loss:
                this.GuestWins++;
                this.GamesDecidedInNormalTime++;
                break;

            case EScoreResult.OTLoss:
                this.GuestWins++;
                this.GamesDecidedInOverTime++;
                break;

            case EScoreResult.PSLoss:
                this.GuestWins++;
                this.GamesDecidedInPenaltyShots++;
                break;

            case EScoreResult.Win:
                this.HomeWins++;
                this.GamesDecidedInNormalTime++;
                break;

            case EScoreResult.OTWin:
                this.HomeWins++;
                this.GamesDecidedInOverTime++;
                break;

            case EScoreResult.PSWin:
                this.HomeWins++;
                this.GamesDecidedInPenaltyShots++;
                break;
            }

            this.Completion = SeasonStatistics.CalculateRelativeValue(this.GamesPlayed, SeasonStatistics.NumberOfGamesPerSeason, 2) * 100;
            this.GamesDecidedInNormalTimePercent   = SeasonStatistics.CalculateRelativeValue(this.GamesDecidedInNormalTime, this.GamesPlayed, 2) * 100;
            this.GamesDecidedInOverTimePercent     = SeasonStatistics.CalculateRelativeValue(this.GamesDecidedInOverTime, this.GamesPlayed, 2) * 100;
            this.GamesDecidedInPenaltyShotsPercent = SeasonStatistics.CalculateRelativeValue(this.GamesDecidedInPenaltyShots, this.GamesPlayed, 2) * 100;
            this.HomeWinsPercent         = SeasonStatistics.CalculateRelativeValue(this.HomeWins, this.GamesPlayed, 2) * 100;
            this.GuestWinsPercent        = SeasonStatistics.CalculateRelativeValue(this.GuestWins, this.GamesPlayed, 2) * 100;
            this.GoalsScoredPerGame      = SeasonStatistics.CalculateRelativeValue(this.GoalsScored, this.GamesPlayed, 1);
            this.HomePointsPerGame       = SeasonStatistics.CalculateRelativeValue(this.HomePoints, this.GamesPlayed, 1);
            this.GuestPointsPerGame      = SeasonStatistics.CalculateRelativeValue(this.GuestPoints, this.GamesPlayed, 1);
            this.HomeGoalsScoredPerGame  = SeasonStatistics.CalculateRelativeValue(this.HomeGoalsScored, this.GamesPlayed, 1);
            this.GuestGoalsScoredPerGame = SeasonStatistics.CalculateRelativeValue(this.GuestGoalsScored, this.GamesPlayed, 1);
        }
예제 #5
0
 private void Awake()
 {
     camera        = GameObject.FindGameObjectWithTag("MainCamera");
     obstacle      = GameObject.FindGameObjectsWithTag("Obstacle");
     ore           = GameObject.FindGameObjectsWithTag("Ore");
     boosterStar   = GameObject.FindGameObjectsWithTag("BoosterStar");
     boosterPotion = GameObject.FindGameObjectsWithTag("BoosterPotion");
     scoreBoard    = FindObjectOfType <ScoreCalculation> ();
     offset        = camera.transform.position - GameObject.FindGameObjectWithTag("Player").transform.position;
 }
예제 #6
0
    void Update()
    {
        if (this.gameObject.activeSelf)
        {
            transform.localPosition = new Vector3(transform.localPosition.x, GameManager.NoteY, transform.localPosition.z) - (new Vector3(0, 1f, 0) * speed * (float)(TimeComponent.GetCurrentTimePast() - StartTime));
        }

        if (this.transform.position.y < -2.5f)
        {
            this.gameObject.SetActive(false);
            ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Miss, 3);
        }

        if (this.gameObject.activeSelf)
        {
            double diff = System.Math.Abs(TimeComponent.GetPressedKeyTime(Rail) - ArrivalTime);
            if (diff <= ScoreCalculation.DetectionRange.Bad && diff > ScoreCalculation.DetectionRange.Good) //Bad
            {
                this.gameObject.SetActive(false);
                ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Bad, 3);
                AddEffect(ScoreCalculation.Judgement.Bad);

                //GameManager.DebugLog(this.gameObject.name + "番のノーツ: Bad");
            }
            else if (diff <= ScoreCalculation.DetectionRange.Good && diff > ScoreCalculation.DetectionRange.Great) //Good
            {
                audioSource[0].PlayOneShot(NoteGoodSE);
                this.gameObject.SetActive(false);
                ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Good, 3);
                AddEffect(ScoreCalculation.Judgement.Good);
                //GameManager.DebugLog(this.gameObject.name + "番のノーツ: Good");
            }
            else if (diff <= ScoreCalculation.DetectionRange.Great && diff > ScoreCalculation.DetectionRange.Perfect) //Great
            {
                audioSource[0].PlayOneShot(NoteGreatSE);
                audioSource[1].PlayOneShot(NoteSpecialSE);
                this.gameObject.SetActive(false);
                ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Great, 3);
                AddEffect(ScoreCalculation.Judgement.Great);
                //GameManager.DebugLog(this.gameObject.name + "番のノーツ: Great");
            }
            else if (diff <= ScoreCalculation.DetectionRange.Perfect && diff >= 0) //Perfect
            {
                audioSource[0].PlayOneShot(NotePerfectSE);
                audioSource[1].PlayOneShot(NoteSpecialSE);
                this.gameObject.SetActive(false);
                ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Perfect, 3);
                AddEffect(ScoreCalculation.Judgement.Perfect);
                //GameManager.DebugLog(this.gameObject.name + "番のノーツ: Perfect");
            }
        }
    }
예제 #7
0
    public void HighscoreUpdateSimplePasses()
    {
        ScoreCalculation.number = int.MaxValue - 1;

        ScoreCalculation.cs();

        int last_highscore = PlayerPrefs.GetInt("Highscore", 0);

        Assert.AreEqual(ScoreCalculation.number, PlayerPrefs.GetInt("Highscore", 0));

        ScoreCalculation.number = 0;
        PlayerPrefs.SetInt("Highscore", 0);
    }
예제 #8
0
 private void LoadScoreDetails()
 {
     try
     {
         ScoreCalculation.LoadGREscorePoints();
         ScoreCalculation.LoadIELTSscorePoints();
         ScoreCalculation.LoadAgebasedscorePoints();
         ScoreCalculation.LoadgradGPAPoints();
         ScoreCalculation.LoadUndergradGPAPoints();
         ScoreCalculation.LoadWorkExperiencePoints();
     }
     catch
     {
         throw;
     }
 }
예제 #9
0
        private void FacultyViewForm_Load(object sender, EventArgs e)
        {
            try
            {
                dataAccessLayer.ApplicantDetails _applicantDetails = new dataAccessLayer.ApplicantDetails();
                var allApplicants = _applicantDetails.GetApplicantScoreDetails();

                List <ApplicantPoints> _applicantsPoints = new List <ApplicantPoints>();
                ScoreCalculation       _scoreCalculation = new ScoreCalculation();

                var calculatedPointsForAllApplicants = _scoreCalculation.CalculatePoints(allApplicants);


                applicantDetailsdataGridView.DataSource = calculatedPointsForAllApplicants;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error While Loading Applicant Details", ex.Message);
            }
        }
예제 #10
0
    void Update()
    {
        if (this.gameObject.activeSelf)
        {
            //this.transform.localPosition -= new Vector3(0, 1f, 0) * speed * Time.fixedDeltaTime;
            transform.localPosition = new Vector3(transform.localPosition.x, StartPosY, transform.localPosition.z) - (new Vector3(0, 1f, 0) * speed * (float)(TimeComponent.GetCurrentTimePast() - StartTime));

            float y       = transform.localPosition.y;
            bool  pressed = isPressing(GetHitting(y));

            if (y <= DetectionLine)
            {
                //Mask += speed * Time.fixedDeltaTime;
                Mask = (speed * (float)(TimeComponent.GetCurrentTimePast() - ArrivalTime));

                if (!flag && pressed)
                {
                    flag   = true;
                    seFlag = true;
                    audioSource.Play();
                }
            }

            //描画処理
            if (flag)
            {
                setMesh(width, length, Mask);
                CreateMesh();
            }
            if (y + length < -2.5f)
            {
                gameObject.SetActive(false);
            }

            //効果音
            if (seFlag && (y + length < DetectionLine || !pressed))
            {
                audioSource.Stop();
                seFlag = false;
            }
            if (pressed && !seFlag)
            {
                audioSource.Play();
                seFlag = true;
            }

            //判定処理
            scrolledTime = (float)(TimeComponent.GetCurrentTimePast() - ArrivalTime);
            if (scrolledTime >= SPB * count && scrolledTime + ArrivalTime <= FinishTime)
            {
                count++;

                if (pressed)
                {
                    ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Perfect, 1);
                    scoredFlag = false;
                }
                else
                {
                    if (!scoredFlag)
                    {
                        if (flag) //一度押している
                        {
                            ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Bad, 1);
                            scoredFlag = true;
                        }
                        else //一度も押していない
                        {
                            ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.Miss, 1);
                            scoredFlag = true;
                        }
                    }
                    else
                    {
                        ScoreCalculation.SetNoteJudgement(ScoreCalculation.Judgement.None, 1);
                    }
                }
            }
        }
    }
 protected ScoreCalculation(ScoreCalculation successor)
 {
     this._successor = successor;
 }
 public OtherCasesCalc(ScoreCalculation successor) : base(successor)
 {
 }
 public EqualizeCalc(ScoreCalculation successor) : base(successor)
 {
 }
 public MoreThanFourCalc(ScoreCalculation successor, string player1Name, string player2Name) : base(successor)
 {
     _player1Name = player1Name;
     _player2Name = player2Name;
 }