Esempio n. 1
0
    void BlockDestroy()
    {
        var model = transform.Find("Model").gameObject;

        ps.Play();
        model.SetActive(false);
        GameManagerScript.AddScore(score);
        Destroy(gameObject, ps.startLifetime);
    }
Esempio n. 2
0
 /* Esta funcion se "Activa" cuando se detecta una colision con otro GameObject que tambien tiene RigidBody2D
  * (Collision2D collision) es el objeto que colociono con el coche en este caso
  */
 private void OnCollisionEnter2D(Collision2D collision)
 {
     /* Se evalua si el objeto que coliciono tiene como "Tag" el valor "Ball"
      * entonces haz que la funcion llamada "AddScore", escrita en el Script GameManagerScript se active
      * Caso contrario no hacer nada
      */
     if (collision.gameObject.tag == "Ball")
     {
         GMscript.AddScore();
         collision.gameObject.GetComponent <BallScript>().PlaySound();
     }
 }
Esempio n. 3
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "Coin")
     {
         gameManager.AddScore();
         Destroy(collider.gameObject);
     }
     else if (collider.tag == "Spike")
     {
         CameraShaker.Instance.ShakeOnce(2f, 3f, .1f, .5f);
         GameOver();
     }
 }
Esempio n. 4
0
    //Retreive currently chained balls
    public void RetrieveBalls()
    {
        int score     = 100;
        int lastScore = score;

        BallScript  lastBall   = chainedBalls[chainedBalls.Count - 1];
        IEnumerator enumerator = chainedBalls.GetEnumerator();

        while (enumerator.MoveNext())
        {
            BallScript ballScript = enumerator.Current as BallScript;
            if (ballScript != null)
            {
                if (chainedBalls.Count >= minChainForBomb)
                {
                    if (ballScript != lastBall)
                    {
                        ballScript.RetrievedAndShowScore(score);
                    }
                    else
                    {
                        ballScript.RecycleToBomb();
                        ballScript.ShowScore(score);
                    }
                }
                else
                {
                    ballScript.RetrievedAndShowScore(score);
                }
                gameManager.AddScore(score);
                score    += lastScore;
                lastScore = score - lastScore;
            }
        }
        gameManager.ResetHintCountdown();
        gameManager.AddCombo();
        Restart();
    }
Esempio n. 5
0
    /*
     * compute for the winner
     * */
    public int getWinner()
    {
        int player1C = 0, player2C = 0;
        int player1T1 = 0, player1T2 = 0;
        int player2T1 = 0, player2T2 = 0;

        //count all 3x3 diamond first
        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < cols; j++)
            {
                if (hasThreeThreeDiamond(1, i, j))
                {
                    player1T1++;
                }
                if (hasThreeThreeDiamond(2, i, j))
                {
                    player2T1++;
                }
            }
        }

        UIManagerScript.Instance.numPlayer1Triangle1 = player1T1;
        //UIManagerScript.Instance.numPlayer1Triangle2 = player1T2;
        UIManagerScript.Instance.numPlayer2Triangle1 = player2T1;
        //UIManagerScript.Instance.numPlayer2Triangle2 = player2T2;

        player1C = player1T1 * GameManagerScript.Instance.score2x3Triangle + player1T2 * GameManagerScript.Instance.score2x2Triangle;
        player2C = player2T1 * GameManagerScript.Instance.score2x3Triangle + player2T2 * GameManagerScript.Instance.score2x2Triangle;
        UIManagerScript.Instance.player1Count = player1C;
        UIManagerScript.Instance.player2Count = player2C;

        if (player1C > player2C)
        {
            GameManagerScript.AddScore(GameManagerScript.PLAYER_RED);
        }
        else if (player1C < player2C)
        {
            GameManagerScript.AddScore(GameManagerScript.PLAYER_BLUE);
        }

        GameManagerScript.AddGame();

        return((player1C > player2C) ? 1 : (player1C < player2C) ? 2 : 0);
    }
Esempio n. 6
0
 private void OnTriggerEnter2D(Collider2D hit)
 {
     if (hit.gameObject.tag == "StageWall")
     {
         rb2d.velocity = Vector2.zero;
         canRun        = false;
     }
     if (hit.gameObject.tag == "Enemy00")
     {
         Enemy00Script enemy = hit.GetComponent <Enemy00Script>();
         TakeDamage(enemy.damageDealt);
         enemy.GetDamaged(playerDamage);
     }
     if (hit.gameObject.tag == "Item")
     {
         ItemScript item = hit.GetComponent <ItemScript>();
         gameManagerScript.AddScore(item.value);
         item.GetDestroyed();
     }
 }
Esempio n. 7
0
 void OnTriggerEnter(Collider c)
 {
     GameManagerScript.AddScore(scoreBase);
     Destroy(gameObject);
 }