Exemplo n.º 1
0
    public void SetRandomCardNums()
    {
        NumGenerator ng = new NumGenerator();

        for (int i = 0; i < bColNums.Length; i++)
        {
            bColNums[i].GetComponentsInChildren<Text>()[0].text = (ng.GenerateUniqueNumberForLetter(BingoLetter.B)).ToString();
            iColNums[i].GetComponentsInChildren<Text>()[0].text = (ng.GenerateUniqueNumberForLetter(BingoLetter.I)).ToString();
            nColNums[i].GetComponentsInChildren<Text>()[0].text = (ng.GenerateUniqueNumberForLetter(BingoLetter.N)).ToString();
            gColNums[i].GetComponentsInChildren<Text>()[0].text = (ng.GenerateUniqueNumberForLetter(BingoLetter.G)).ToString();
            oColNums[i].GetComponentsInChildren<Text>()[0].text = (ng.GenerateUniqueNumberForLetter(BingoLetter.O)).ToString();
        }
    }
Exemplo n.º 2
0
    public void SetBall()
    {
        var randomLetter = GenerateRandomBingoLetter();
        var randomNumber = _numbersGenerator.GenerateUniqueNumberForLetter(randomLetter);
        var newBall      = new BingoBall(randomLetter, randomNumber);

        Ball.GetComponent <BallView>().ApplyBingoBallModel(newBall);

        switch (randomLetter)
        {
        case BingoLetter.B:
            Ball.GetComponent <BallView>().ApplyBallSprite(bBallSprite);
            break;

        case BingoLetter.I:
            Ball.GetComponent <BallView>().ApplyBallSprite(iBallSprite);
            break;

        case BingoLetter.N:
            Ball.GetComponent <BallView>().ApplyBallSprite(nBallSprite);
            break;

        case BingoLetter.G:
            Ball.GetComponent <BallView>().ApplyBallSprite(gBallSprite);
            break;

        case BingoLetter.O:
            Ball.GetComponent <BallView>().ApplyBallSprite(oBallSprite);
            break;

        default:
            break;
        }

        _cardNumGenerator.CheckIsNumInComCard(randomNumber);
        _cardNumGenerator.CheckIsNumInPlayerCard(randomNumber);
        if (_cardNumGenerator.hasResult)
        {
            CancelInvoke();
            //GameOverPanel.SetActive(true);
            WinnerText.text = _cardNumGenerator.winner;

            var balls = GameObject.FindGameObjectsWithTag("Ball");
            foreach (GameObject ball in balls)
            {
                //Destroy(ball);
                ball.GetComponent <BallView>().Disable();
            }
        }
    }