Ejemplo n.º 1
0
    static public List <BattleHex> GetAdjacentHexes(BattleHex startingHex, IEvaluateHex checkHex)
    {
        allNeighbours.Clear();
        int initialX = startingHex.horizontalCoordinate - 1;
        int initialY = startingHex.verticalCoordinate - 1;

        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                if (x + y != 0 &&
                    checkHex.EvaluateHex(FieldManager.allHexesArray[initialX + x, initialY + y]))     //exclude inactive hexes
                {
                    allNeighbours.Add(FieldManager.allHexesArray[initialX + x, initialY + y]);
                }
            }
        }
        return(allNeighbours);
    }
Ejemplo n.º 2
0
    static public List <BattleHex> GetAdjacentHexes(BattleHex startingHex, IEvaluateHex checkHex)//Looks for and returns neighbouring hexes
    {
        allNeighbours.Clear();
        //subtract 1 since array's index starts from 1.
        int initialX = startingHex.horizontalCoordinate - 1; //first index for two-dimensional list
        int initialY = startingHex.verticalCoordinate - 1;   //second index for two-dimensional list

        //iterates x and y from -1 to 1 to get adjacent hexes referring to the coordinates of starting hex
        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                if (x + y != 0 && //exclude two hexes that are not adjacent hexes
                    checkHex.EvaluateHex(FieldManager.allHexesArray[initialX + x, initialY + y]))     //exclude inactive hexes
                {
                    allNeighbours.Add(FieldManager.allHexesArray[initialX + x, initialY + y]);
                }
            }
        }
        return(allNeighbours);
    }
Ejemplo n.º 3
0
    static public List <BattleHex> GetAdjacentHexes(BattleHex startingHex, IEvaluateHex checkHex)// Busca y devuelve hexágonos vecinos
    {
        allNeighbours.Clear();
        // resta 1 ya que el índice de la matriz comienza en 1.
        int initialX = startingHex.horizontalCoordinate - 1; // primer índice para lista bidimensional
        int initialY = startingHex.verticalCoordinate - 1;   // segundo índice para lista bidimensional

        // itera xey de -1 a 1 para obtener hexágonos adyacentes que se refieren a las coordenadas del hex inicial
        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                if (x + y != 0 && // excluir dos hexes que no son hexágonos adyacentes
                    checkHex.EvaluateHex(FieldManager.allHexesArray[initialX + x, initialY + y]))     // excluir hexágonos inactivos
                {
                    allNeighbours.Add(FieldManager.allHexesArray[initialX + x, initialY + y]);
                }
            }
        }
        return(allNeighbours);
    }
Ejemplo n.º 4
0
    static public List <HexBattale> GetAdjacentHexes(HexBattale startingHex, IEvaluateHex chcekHex)
    {
        allNeighbours.Clear();


        int initialX = startingHex.horizonalCoordinate - 1;
        int initialY = startingHex.verticalCoordinate - 1;

        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                if (x + y != 0 && chcekHex.EvaluateHex(FieldMenager.allHexesArray[initialX + x, initialY + y]) &&
                    FieldMenager.allHexesArray[initialX + x, initialY + y].battaleState
                    == HexState.active)
                {
                    allNeighbours.Add(FieldMenager.allHexesArray[initialX + x, initialY + y]);
                }
            }
        }
        return(allNeighbours);
    }