コード例 #1
0
    public static HexEdgeData CreateRandomEdgeData(int x, int y, HexDiraction diraction)
    {
        var        location         = new Vector2Int(x, y);
        var        myTile           = GridManager.Singleton.GetHex(location);
        Vector2Int neighborLocation = location + HexTile.HexEdgeOffset[diraction];

        var neighborTile = GridManager.Singleton.GetHex(neighborLocation);

        if (neighborTile == null)
        {
            return(new HexEdgeData(myTile.Data, GetRandomEdgeType(), diraction));
        }

        var neighborEdge = neighborTile.Data.HexEdgesData[(int)OppsiteHex[diraction]];

        if (!neighborEdge.IsOpen)
        {
            if (neighborTile.Data.Owner == null)
            {
                return(new HexEdgeData(myTile.Data, GetRandomEdgeType(), diraction, Utils.RandomBool()));
            }
            return(new HexEdgeData(myTile.Data, GetRandomEdgeType(), diraction));
        }

        return(new HexEdgeData(myTile.Data, neighborEdge.HexEdgeType, diraction, true));
    }
コード例 #2
0
 public HexEdgeData(HexTileData myHexTile, HexEdgeType hexEdgeType, HexDiraction hexDiraction, bool isOpen = false)
 {
     MyHexTile    = myHexTile;
     HexEdgeType  = hexEdgeType;
     HexDiraction = hexDiraction;
     IsOpen       = isOpen;
 }
コード例 #3
0
    public static HexTile GetNeighborTile(HexTile hexTile, HexDiraction diraction)
    {
        var neighborLocation = hexTile.Data.GetVector() + HexTile.HexEdgeOffset[diraction];

        return(GridManager.Singleton.GetHex(neighborLocation));
    }