Exemplo n.º 1
0
    public override void OnPointerClickDown()
    {
        int score = (objC.getTimeAlive());

        scoreC.AddPoint(score);
        objC.resetTimer();
    }
Exemplo n.º 2
0
 public void AddPoint()
 {
     scoreController.AddPoint();
 }
Exemplo n.º 3
0
    private void OnCollisionEnter(Collision collision)
    {
        MapController mc = collision.gameObject.GetComponent <MapController>();

        // Doing point, is a goal of this game
        // And Adding point to score
        // With particular sound
        if (collision.gameObject.name == "West")
        {
            soundC.RunPointSound();
            endOfGame = scoreC.AddPoint(2);
            if (!endOfGame)
            {
                ResetBall(2);
            }
            else
            {
                EndOfGame();
            }
        }
        // Same as before
        else if (collision.gameObject.name == "East")
        {
            soundC.RunPointSound();
            endOfGame = scoreC.AddPoint(1);
            if (!endOfGame)
            {
                ResetBall(1);
            }
            else
            {
                EndOfGame();
            }
        }
        // But, if we hit north or south wall, we need a different soud !
        else
        {
            soundC.RunWallSound();
        }

        // Paddle stuff
        if (collision.gameObject.name.StartsWith("Paddle"))
        {
            // We need a lot of objects
            PaddleController pc      = collision.gameObject.GetComponent <PaddleController>();
            Transform        cube    = pc.transform.Find("Cube");
            Transform        center  = cube.Find("Center");
            Transform        positif = cube.Find("Positif");
            Transform        negatif = cube.Find("Negatif");

            // Natural and correct direction after rebound
            Vector3   contactPoint             = collision.contacts[0].point;
            Transform maxRange                 = (Vector3.Dot(positif.position, contactPoint - center.position) > 0) ? positif : negatif;
            float     MaxDist                  = Mathf.Abs(maxRange.position.z - center.position.z);
            float     distBetweenCenterContact = Mathf.Abs(contactPoint.z - center.position.z);

            if (MaxDist != 0)
            {
                rb.velocity = Vector3.Lerp(center.forward, maxRange.forward, distBetweenCenterContact / MaxDist).normalized *Speed;
            }

            // Some sounds
            soundC.RunPaddleSound();

            // Decrease PaddleSpeed
            pc.DecreesePaddleSpeed();
            // And increese BallSpeed \../
            IncreeseBallSpeed();
        }
        return;
    }
Exemplo n.º 4
0
    public void AddPoint_AddOnePointToScore()
    {
        scoreController.AddPoint();

        Assert.AreEqual(1, scoreController.GetPoints());
    }