Ejemplo n.º 1
0
    /**
     * Returns Adjacent hex with matching "HexColor"
     */
    private void SelectAdjacentHexColor(Vector2 vec2, HexColor color)
    {
        int maxX = hexList.GetLength(0);
        int maxY = hexList.GetLength(1);

        List <Vector2> m_AdjacentHex = m_AdjacentHexOddRow;

        if (vec2.y % 2 == 0)
        {
            m_AdjacentHex = m_AdjacentHexEvenRow;
        }

        foreach (Vector2 vec in m_AdjacentHex)
        {
            Vector2 adjHexVec = vec + vec2;
            if (!m_selectedHex.Contains(adjHexVec))
            {
                if (adjHexVec.x < maxX && adjHexVec.x >= 0 && adjHexVec.y < maxY && adjHexVec.y >= 0)
                {
                    GameObject   hex       = hexList[(int)adjHexVec.x, (int)adjHexVec.y];
                    HexObjScript hexScript = hex.GetComponent <HexObjScript>();
                    if (hexScript.GetHexColor() == color)
                    {
                        m_selectedHex.Add(new Vector2(adjHexVec.x, adjHexVec.y));
                        SelectAdjacentHexColor(adjHexVec, color);
                        hexScript.MouseOverColor();
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
 public void HandleOnEnter(HexObjScript hexScript)
 {
     m_selectedHex = new List <Vector2>
     {
         hexScript.GetCoords()
     };
     hexScript.MouseOverColor();
     SelectAdjacentHexColor(hexScript.GetCoords(), hexScript.GetHexColor());
 }