public void TestMinimalScoreInTop5()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddScore("", 20);
            scoreBoard.AddScore("", 10);
            scoreBoard.AddScore("", 50);
            Assert.AreEqual(10, scoreBoard.MinimalScoreInTop5(), "Not correct minimal score");
        }
예제 #2
0
    public void TestToStringWithTwoScores()
    {
        ScoreBoard scoreBoard = new ScoreBoard();

        scoreBoard.AddScore("Pesho", 2);
        scoreBoard.AddScore("Pesho", 0);
        var result = scoreBoard.ToString();

        Assert.AreEqual("1. Pesho ---> 0 mistake(s)!\n" +
                        "2. Pesho ---> 2 mistake(s)!\n", result);
    }
예제 #3
0
    public void TestCheckScoreIsHighscoreWithLessThanFiveRecordsAndCheckWorse()
    {
        ScoreBoard scoreBoard = new ScoreBoard();

        scoreBoard.AddScore("Pesho", 2);
        scoreBoard.AddScore("Pesho", 0);
        scoreBoard.AddScore("Ivan", 5);
        bool isHighscore = scoreBoard.CheckScoreIsHighscore(6);

        Assert.IsTrue(isHighscore);
    }
        public void TestAddScores()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddScore("", 20);
            scoreBoard.AddScore("", 10);
            scoreBoard.AddScore("", 50);
            int result = scoreBoard.Count();

            Assert.AreEqual(3, result, "Not correct minimal score");
        }
예제 #5
0
    public void TestCheckScoreIsHighscoreWithMoreThanFiveRecordsAndCheckWorse()
    {
        ScoreBoard scoreBoard = new ScoreBoard();

        scoreBoard.AddScore("Pesho", 2);
        scoreBoard.AddScore("Pesho", 0);
        scoreBoard.AddScore("Asya", 1);
        scoreBoard.AddScore("Gergana", 0);
        scoreBoard.AddScore("Ivan", 5);
        bool isHighscore = scoreBoard.CheckScoreIsHighscore(6);

        Assert.IsFalse(isHighscore);
    }
예제 #6
0
    public void TestCheckScoreIsHighscoreWithAllPerfectScores()
    {
        ScoreBoard scoreBoard = new ScoreBoard();

        scoreBoard.AddScore("Pesho", 0);
        scoreBoard.AddScore("Pesho", 0);
        scoreBoard.AddScore("Asya", 0);
        scoreBoard.AddScore("Gergana", 0);
        scoreBoard.AddScore("Ivan", 0);
        bool isHighscore = scoreBoard.CheckScoreIsHighscore(0);

        Assert.IsTrue(isHighscore);
    }
예제 #7
0
    public void TestResetMethod()
    {
        ScoreBoard scoreBoard = new ScoreBoard();

        scoreBoard.AddScore("Pesho", 2);
        scoreBoard.AddScore("Pesho", 0);
        scoreBoard.AddScore("Asya", 1);
        scoreBoard.AddScore("Gergana", 0);
        scoreBoard.AddScore("Ivan", 5);
        scoreBoard.Reset();
        bool result = scoreBoard.IsEmpty;

        Assert.AreEqual(result, true);
    }
예제 #8
0
    public void CheckScoreHasMadeScoreBoardNotEnoughScores()
    {
        //Arrange
        GameEngine gameEngine       = new GameEngine();
        ScoreBoard customScoreBoard = new ScoreBoard();

        customScoreBoard.AddScore("pesho", 50);
        customScoreBoard.AddScore("pesho", 50);
        customScoreBoard.AddScore("pesho", 50);
        customScoreBoard.AddScore("pesho", 50);
        customScoreBoard.AddScore("pesho", 50);
        customScoreBoard.AddScore("pesho", 50);
        customScoreBoard.AddScore("pesho", 50);
        customScoreBoard.AddScore("pesho", 50);

        Type type       = typeof(GameEngine);
        var  fieldValue = type.GetField("scoreBoard", BindingFlags.Instance | BindingFlags.NonPublic);

        //var mockedScoreBoard = Mock.Create<IScoreBoard>();
        //Telerik.JustMock.Mock.Arrange(() => mockedScoreBoard.CheckScoreIsHighscore(5)).Returns(false);

        fieldValue.SetValue(gameEngine, customScoreBoard);

        //Act
        string actual   = gameEngine.CheckScoreHasMadeScoreBoard(88);
        string expected = "You won with 88 mistake(s) but you score did not enter in the scoreboard\n" +
                          "1. pesho ---> 50 mistake(s)!\n" +
                          "2. pesho ---> 50 mistake(s)!\n" +
                          "3. pesho ---> 50 mistake(s)!\n" +
                          "4. pesho ---> 50 mistake(s)!\n" +
                          "5. pesho ---> 50 mistake(s)!\n";

        Assert.AreEqual(expected, actual);
    }
예제 #9
0
    public void TestToStringWithFiveScores()
    {
        ScoreBoard scoreBoard = new ScoreBoard();

        scoreBoard.AddScore("Pesho", 2);
        scoreBoard.AddScore("Pesho", 0);
        scoreBoard.AddScore("Asya", 1);
        scoreBoard.AddScore("Gergana", 0);
        scoreBoard.AddScore("Ivan", 5);
        var result = scoreBoard.ToString();

        Assert.AreEqual("1. Gergana ---> 0 mistake(s)!\n" +
                        "2. Pesho ---> 0 mistake(s)!\n" +
                        "3. Asya ---> 1 mistake(s)!\n" +
                        "4. Pesho ---> 2 mistake(s)!\n" +
                        "5. Ivan ---> 5 mistake(s)!\n", result);
    }
예제 #10
0
 private void explode()
 {
     scoreBoardScript.AddScore(score);
     isAlive   = false;
     explosion = Instantiate(explosion, transform.position, transform.rotation);
     explosion.transform.parent = spawnParent;
     Destroy(gameObject);
 }
예제 #11
0
 public void OnTriggerEnter(Collider other)
 {
     if (pointSound != null)
     {
         pointSound.SetActive(true);
     }
     scoreBoardScript.AddScore(score);
     StartCoroutine(SelfDestruct());
 }
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         ScoreBoard scoreBoard = FindObjectOfType <ScoreBoard>();
         scoreBoard.AddScore(scoreToAdd);
         Destroy(gameObject);
     }
 }
예제 #13
0
 void Update()
 {
     // 非アクティブなノートは、activeNoteListから排除する。
     for (int i = 0; i < activeNoteList.Count; i++)
     {
         if (!activeNoteList[i].GetActive())
         {
             scoreBoard.AddScore(Judgement.LATE);
             activeNoteList.Remove(activeNoteList[i]);
         }
     }
     // ノートを出現する
     if (noteIndex < timingArray.Length)
     {
         if (AudioManager.Instance.GetTime() > (timingArray[noteIndex] - fallTime))
         {
             NoteAdd(noteIndex++);
         }
     }
 }
예제 #14
0
        public void Test_ScoreBoard_AddScore()
        {
            var scoreBoard = new ScoreBoard();

            scoreBoard.AddScore("test", 10);

            var actual   = scoreBoard.TopScores.First();
            var expected = new KeyValuePair <string, int>("test", 10);

            Assert.AreEqual <KeyValuePair <string, int> >(expected, actual);
        }
예제 #15
0
 private void PickupCoin()//Limits the score by detecting only one trigger
 {
     coinTouch += 1;
     if (coinTouch == 1)
     {
         GameObject fx = Instantiate(coinSound, transform.position, Quaternion.identity);
         fx.transform.parent = parent;
         scoreBoard.AddScore(score);
         Destroy(gameObject);
     }
 }
예제 #16
0
 private void OnParticleCollision(GameObject other)
 {
     GetComponent <AudioSource>().PlayOneShot(hitFX);
     EnemyHitpoints--;
     hitParticle.Play();
     if (EnemyHitpoints < 1)
     {
         _scoreBoard.AddScore();
         EnemyDeath();
     }
 }
예제 #17
0
    public void ReturnBtn()
    {
        GameObject Spawner    = GameObject.Find("Spawner");
        ScoreBoard scoreboard = Spawner.GetComponent <ScoreBoard>();

        if (InputField.text == "")
        {
            emptyNickTxt.SetActive(true);
        }
        else
        {
            scoreboard.AddScore(InputField.text, System.Convert.ToInt32(endscore.text));
            SceneManager.LoadScene("gui");
        }
    }
예제 #18
0
        public void AddScore_ShouldAddScoreToScoreBoard()
        {
            var category = YahtzeeCategory.Pair;
            var points   = 8;

            _sut.AddScore(category, points);

            var actualPoints = _sut.GetScoreForCategory(category);

            Assert.AreEqual(points, actualPoints);
        }
예제 #19
0
    private void Die()
    {
        rb.useGravity = true;
        rb.AddForce(Vector3.down * 200f);
        rb.AddTorque(new Vector3(0, 2000f, 0));

        //rb.AddForce(new Vector3(1000f, 1000f, 1000f));

        // Add Points;
        scoreBoard.AddScore(scoreForDestroy);

        // Explosion will be destroyed by itself when particle finished
        explodeGO = Instantiate(explosion, transform.position, Quaternion.identity);
        explodeGO.transform.parent = this.transform;
        // xplosionParent indicates where instantation should be done

        /*if (xplosionParent) {
         *  explodeGO.transform.parent = xplosionParent;
         * }*/
        Invoke("DestroyMe", 3f);
    }
예제 #20
0
    public void TestAddScoreWithSevenScoresLastAreWorse()
    {
        ScoreBoard scoreBoard = new ScoreBoard();

        scoreBoard.AddScore("Pesho", 100);
        scoreBoard.AddScore("Pesho", 50);
        scoreBoard.AddScore("Asya", 150);
        scoreBoard.AddScore("Gergana", 20);
        scoreBoard.AddScore("Ivan", 300);
        scoreBoard.AddScore("Petkan", 4);
        scoreBoard.AddScore("Stoyan", 11111);

        string actual   = scoreBoard.ToString();
        string expected = "1. Petkan ---> 4 mistake(s)!\n" +
                          "2. Gergana ---> 20 mistake(s)!\n" +
                          "3. Pesho ---> 50 mistake(s)!\n" +
                          "4. Pesho ---> 100 mistake(s)!\n" +
                          "5. Asya ---> 150 mistake(s)!\n";

        Assert.AreEqual(expected, actual);
    }
예제 #21
0
파일: Game.cs 프로젝트: yoellevy/StarWars
        protected void FixedUpdate()
        {
            var spaceships = space.Spaceships;

            // First all alive spaceships select their next action.
            foreach (var spaceship in spaceships)
            {
                if (spaceship.IsAlive)
                {
                    spaceship.SelectAction();
                }
            }
            // Then all spaceships do their turn.
            foreach (var spaceship in spaceships)
            {
                spaceship.DoTurn();
            }

            var shots = space.Shots;

            foreach (var shot in shots)
            {
                if (shot.IsAlive)
                {
                    shot.DoTurn();
                }
            }

            deadShips.Clear();
            deadShots.Clear();
            // Check for collisions.
            // Spaceship to spaceship.
            for (int i = 0; i < spaceships.Count - 1; i++)
            {
                var ship = spaceships[i];
                if (!ship.IsAlive)
                {
                    continue;
                }
                for (int j = i + 1; j < spaceships.Count; j++)
                {
                    var other = spaceships[j];
                    if (!other.IsAlive)
                    {
                        continue;
                    }
                    if (ship.obj.CheckCollision(other.obj))
                    {
                        DebugUtils.Log(ship.Name + " collided with ship " + other.Name);
                        if (ship.IsShieldUp != other.IsShieldUp)
                        {
                            // The ship without the shield is dead.
                            var killer = ship.IsShieldUp ? ship : other;
                            var dead   = ship.IsShieldUp ? other : ship;
                            scoreBoard.AddScore(killer.Name, SCORE_FOR_BASHING);
                            SpaceshipKilled(dead);
                            AudioManager.PlayClip(shieldBurnShipSound);
                            if (ship == dead)
                            {
                                break;
                            }
                        }
                        else
                        {
                            SpaceshipKilled(other);
                            SpaceshipKilled(ship);
                            AudioManager.PlayClip(collisionSound);
                            break;
                        }
                    }
                }
            }
            // Shot to spaceship.
            foreach (var ship in spaceships)
            {
                if (!ship.IsAlive)
                {
                    continue;
                }
                foreach (var shot in shots)
                {
                    if (!shot.IsAlive)
                    {
                        continue;
                    }
                    if (shot.obj.CheckCollision(ship.obj))
                    {
                        DebugUtils.Log(ship.Name + " collided with shot " + shot.Name);
                        if (!ship.IsShieldUp)
                        {
                            scoreBoard.AddScore(shot.Shooter.Name, SCORE_FOR_SHOOTING);
                            SpaceshipKilled(ship);
                            AudioManager.PlayClip(killSound);
                        }
                        else
                        {
                            AudioManager.PlayClip(shieldBurnShotSound);
                        }
                        shot.BeDead();
                        break;
                    }
                }
            }

            // Clear dead ships.
            foreach (var spaceship in spaceships)
            {
                if (!spaceship.IsAlive)
                {
                    deadShips.Add(spaceship);
                }
            }
            foreach (var spaceship in deadShips)
            {
                space.RemoveSpaceship(spaceship);
            }

            // Clear dead shots.
            foreach (var shot in shots)
            {
                if (!shot.IsAlive)
                {
                    deadShots.Add(shot);
                }
            }
            foreach (var shot in deadShots)
            {
                space.RemoveShot(shot);
            }
        }