示例#1
0
    public Dictionary <string, Hex> GetHexInRange(int range, Hex start)
    {
        Dictionary <string, Hex> resut = new Dictionary <string, Hex>();

        for (int i = -range; i <= range; i++)
        {
            for (int j = -range; j <= range; j++)
            {
                for (int k = -range; k <= range; k++)
                {
                    if (i + j + k == 0)
                    {
                        Hex temp = new Hex(i, j, k);
                        Hex z    = start.Add(temp);
                        if (!EqualHex(z, start))
                        {
                            resut.Add(z.ToString(), z);
                        }
                    }
                }
            }
        }
        //Debug.Log(resut.Count + " Ile hexow w zasiegu");
        return(resut);
    }
示例#2
0
        protected Hex SpaceInverted(Hex raw)
        {
            Hex result = new Hex();

            foreach (int value in raw)
            {
                if (value != 35)
                {
                    result.Add(-1);
                }
                else
                {
                    result.Add(value);
                }
            }
            return(result);
        }
示例#3
0
        void AddHexNeighborInfoToNewCell(GameObject newObj)
        {
            HexCoord hc = newObj.GetComponent <HexCoord> ();

            for (int i = 0; i < 6; i++)
            {
                Hex hexDir = Hex.directions [i];
                Hex nbHex  = Hex.Add(hc._hex, hexDir);
                if (_HexToCells.ContainsKey(nbHex))
                {
                    hc._Neighbors [i] = _HexToCells [nbHex].transform;
                }
                else
                {
                    hc._Neighbors [i] = null;
                }
            }
        }
示例#4
0
        protected Hex Trim(Hex raw)
        {
            Hex result = new Hex();

            int counter = 0;
            int pointer = 0;

            foreach (int value in raw)
            {
                if (value != 35)
                {
                    pointer = counter;
                }
                counter++;
            }
            for (int i = 0; i <= pointer; i++)
            {
                result.Add(raw[i]);
            }
            return(result);
        }
示例#5
0
    public void setStartPosition(Directions dirFirst, Directions dirNext)
    {
        Hex center = new Hex(0, 0, 0);
        int radius = mapRadius;

        for (int i = 1; i <= radius; i++)
        {
            center = center.Add(Hex.directionsArray[(int)dirFirst]);
        }
        ;

        PlayerTeamStartPositions[0] = layot.HexToVector3(center);


        Hex next = new Hex(center.q, center.r, center.s);

        for (int i = 1; i <= radius; i++)
        {
            next = next.Add(Hex.directionsArray[(int)dirNext]);
            PlayerTeamStartPositions[i] = layot.HexToVector3(next);
        }
    }
示例#6
0
    private void ShowJumpSpots(Tile selectedTile)
    {
        List <Hex> neighbors       = selectedTile.Hex.Neighbors();
        List <Hex> validDirections = new List <Hex>();

        foreach (Hex neighbor in neighbors)
        {
            if (pieces.ContainsKey(neighbor))
            {
                Hex direction = neighbor.Subtract(selectedTile.Hex);
                validDirections.Add(direction);
            }
        }
        foreach (Hex validDirection in validDirections)
        {
            Hex checker = selectedTile.Hex.Add(validDirection);
            while (pieces.ContainsKey(checker))
            {
                checker = checker.Add(validDirection);
            }
            ShowSpot(checker);
        }
    }
示例#7
0
 static public Hex DiagonalNeighbor(Hex hex, int direction)
 {
     return(Hex.Add(hex, Hex.diagonals[direction]));
 }
示例#8
0
 static public Hex Neighbor(Hex hex, int direction)
 {
     return(Hex.Add(hex, Hex.Direction(direction)));
 }
示例#9
0
 public static Hex Neighbor(this Hex a, int d)
 {
     return(a.Add(Dir(d)));
 }
示例#10
0
 static public void TestHexArithmetic()
 {
     Tests.EqualHex("hex_add", new Hex(4, -10, 6), Hex.Add(new Hex(1, -3, 2), new Hex(3, -7, 4)));
     Tests.EqualHex("hex_subtract", new Hex(-2, 4, -2), Hex.Subtract(new Hex(1, -3, 2), new Hex(3, -7, 4)));
 }