Ejemplo n.º 1
0
    private int GetHits(BooleanTerm boolTerm)
    {
        int  hits    = 0;
        bool foundOs = false;

        for (int i = 0; i < _width; i++)
        {
            for (int j = 0; j < _height; j++)
            {
                KVelement temp = _grid.GetObjFromCoordinate(new Vector2Int(i, j)).GetComponent <KVelement>();
                if (temp)
                {
                    if (!temp.highlighted)
                    {
                        if (temp.Highlight(boolTerm.charges.x, boolTerm.charges.y) == 1)
                        {
                            hits++;
                        }
                        if (temp.Highlight(boolTerm.charges.x, boolTerm.charges.y) == 0)
                        {
                            foundOs = true;
                        }
                    }
                }
            }
        }
        if (!foundOs)
        {
            return(hits);
        }
        else
        {
            return(-1);
        }
    }
Ejemplo n.º 2
0
    public void Highlight(int intToAdd)
    {
        ResetBoard();

        if (intToAdd > 0)
        {
            if ((intToAdd & _currentSelectionPositive) == 0)
            {
                _currentSelectionPositive += intToAdd;
            }
            else
            {
                _currentSelectionPositive -= intToAdd;
            }
        }
        else
        {
            if ((intToAdd * -1 & _currentSelectionNegative) == 0)
            {
                _currentSelectionNegative += intToAdd * -1;
            }
            else
            {
                _currentSelectionNegative -= intToAdd * -1;
            }
        }


        for (int i = 0; i < _width; i++)
        {
            for (int j = 0; j < _height; j++)
            {
                GameObject tempHighlight  = _grid.GetObjFromCoordinate(new Vector2Int(i, j));
                KVelement  currentElement = tempHighlight.GetComponent <KVelement>();
                if (currentElement != null)
                {
                    currentElement.Highlight(_currentSelectionPositive, _currentSelectionNegative);
                }
            }
        }
        SetText();
    }