Example #1
0
    void PlayerHit()
    {
        if (underPlayer == 1)
        {
            Game_Manager.Score("Right_Wall");
        }
        if (underPlayer == 2)
        {
            Game_Manager.Score("Left_Wall");
        }

        if (Game_Manager.GetScore(1) == 10 || Game_Manager.GetScore(2) == 10)
        {   // Game is over, dont restart the ball
            PlaySound(3);
            EndGame();
        }
    }
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        if (hitInfo.name == "Pongman")
        {
            string wallName = transform.name;
            Game_Manager.Score(wallName);

            hitInfo.gameObject.SendMessage("SetPlayerControl", 0, SendMessageOptions.RequireReceiver);
            if (Game_Manager.GetScore(1) == 10 || Game_Manager.GetScore(2) == 10)
            {   // Game is over, dont restart the ball
                hitInfo.gameObject.SendMessage("PlaySound", 3, SendMessageOptions.RequireReceiver);
                hitInfo.gameObject.SendMessage("EndGame", 1, SendMessageOptions.RequireReceiver);
            }
            else
            {
                hitInfo.gameObject.SendMessage("RestartBall", 1, SendMessageOptions.RequireReceiver);
            }
        }
    }