public void AICondition()
    {
        cv.ResetValues();

        GameObject[] go;

        if (AIPiece == 0)
        {
            go = GameObject.FindGameObjectsWithTag("XPiece");
        }
        else
        {
            go = GameObject.FindGameObjectsWithTag("OPiece");
        }

        foreach (GameObject s in go)
        {
            int ID = s.GetComponent <Slots>().ID;
            int v  = ((ID - 1) % 15);
            cv.VerifyVertical(ID);
            cv.VerifyHorizontal(ID, v);
            cv.VerifyDiagonals(ID, v);

            if (cv.Vertical == 5 || cv.Horizontal == 5 || cv.DiagonalL == 5 || cv.DiagonalR == 5)
            {
                GameFinish(1);
            }
            else
            {
                cv.ResetValues();
            }
        }
        if (GameStart)              // if don't win
        {
            SwitchTurn();
        }

        VerifyTableFull();
    }
Beispiel #2
0
    private void FillPossibilities(bool player, int ammount, List <PotentialPieces> PotentialPieces)
    {
        GameObject[] sl;
        if (player)
        {
            if (GameController.gc.PlayerPiece == 0)
            {
                sl = GameObject.FindGameObjectsWithTag("XPiece");
            }
            else
            {
                sl = GameObject.FindGameObjectsWithTag("OPiece");
            }
        }
        else
        {
            if (GameController.gc.PlayerPiece == 0)
            {
                sl = GameObject.FindGameObjectsWithTag("OPiece");
            }
            else
            {
                sl = GameObject.FindGameObjectsWithTag("XPiece");
            }
        }

        // Verify All AI Pieces and Possibilities
        foreach (GameObject go in sl)
        {
            cv.ResetValues();

            PotentialPieces pp = new PotentialPieces();
            int             ID = go.GetComponent <Slots>().ID;
            int             v  = ((ID - 1) % 15);
            cv.VerifyVertical(ID);
            if (cv.Vertical == ammount)
            {
                pp.ID        = ID;
                pp.Ammount   = cv.Vertical;
                pp.Direction = "vertical";
                PotentialPieces.Add(pp);
            }
            cv.VerifyHorizontal(ID, v);
            if (cv.Horizontal == ammount)
            {
                pp.ID        = ID;
                pp.Ammount   = cv.Horizontal;
                pp.Direction = "horizontal";
                PotentialPieces.Add(pp);
            }
            cv.VerifyDiagonals(ID, v);
            if (cv.DiagonalL == ammount)
            {
                pp.ID        = ID;
                pp.Ammount   = cv.DiagonalL;
                pp.Direction = "diagonalL";
                PotentialPieces.Add(pp);
            }
            if (cv.DiagonalR == ammount)
            {
                pp.ID        = ID;
                pp.Ammount   = cv.DiagonalR;
                pp.Direction = "diagonalR";
                PotentialPieces.Add(pp);
            }
        }
    }