コード例 #1
0
    /// <summary>
    /// Return offset coordinates of the neigboring tile in the specified direction.
    /// </summary>
    /// <param name="hex">Hex base.</param>
    /// <param name="dir">Specified direction.</param>
    /// <param name="pairs">Coordinate pairs.</param>
    /// <returns></returns>
    public static OffsetCoordinates GetNeighborFromDir(Hex hex, CubeDirections dir, OffsetCoordinates pairs)
    {
        CubeCoordinates cubePairs = OffsetToCube(hex, pairs.col, pairs.row);

        switch (dir)
        {
        case CubeDirections.Left:
            return(CubeToOffset(hex, cubePairs.x - 1, cubePairs.y + 1, cubePairs.z));

        case CubeDirections.Right:
            return(CubeToOffset(hex, cubePairs.x + 1, cubePairs.y - 1, cubePairs.z));

        case CubeDirections.TopLeft:
            return(CubeToOffset(hex, cubePairs.x, cubePairs.y + 1, cubePairs.z - 1));

        case CubeDirections.BottomRight:
            return(CubeToOffset(hex, cubePairs.x, cubePairs.y - 1, cubePairs.z + 1));

        case CubeDirections.TopRight:
            return(CubeToOffset(hex, cubePairs.x + 1, cubePairs.y, cubePairs.z - 1));

        case CubeDirections.BottomLeft:
            return(CubeToOffset(hex, cubePairs.x - 1, cubePairs.y, cubePairs.z + 1));

        default:
            Debug.LogError("Some unknown CubeDirections enum received.");
            return(new OffsetCoordinates(-1, -1));
        }
    }
コード例 #2
0
    private Sticker LoadSticker(Cubelet parent, CubeDirections dir, StickerColors color)
    {
        Sticker sticker = Instantiate(prefabSticker, parent.transform).AddComponent<Sticker>();

        Vector3 vDir = DirectionsOrdered[(int)dir];
        
        sticker.transform.localPosition = vDir * 0.5f;
        sticker.transform.forward = vDir;

        sticker.GetComponentInChildren<MeshRenderer>().material.color = StickersColorsOrdered[(int)color];
        sticker.MyColor = color;

        return sticker;
    }
コード例 #3
0
    protected override void OnCreateManager()
    {
        entityManager  = World.Active.GetOrCreateManager <EntityManager>();
        util           = new Util();
        cubeDirections = new CubeDirections();
        sectorSize     = TerrainSettings.sectorSize;

        EntityArchetypeQuery sectorQuery = new EntityArchetypeQuery
        {
            None = new ComponentType[] { typeof(NotInDrawRangeSectorTag), typeof(OuterDrawRangeSectorTag) },
            All  = new ComponentType[] { typeof(Sector), typeof(DrawMeshTag), typeof(AdjacentSectors), typeof(NeighboursAreReady) }
        };

        meshGroup = GetComponentGroup(sectorQuery);
    }
コード例 #4
0
    protected override void OnCreateManager()
    {
        entityManager  = World.Active.GetOrCreateManager <EntityManager>();
        terrainSystem  = World.Active.GetOrCreateManager <TerrainSystem>();
        sectorSize     = TerrainSettings.sectorSize;
        cubeDirections = new CubeDirections();

        EntityArchetypeQuery adjSectorsQuery = new EntityArchetypeQuery
        {
            Any  = new ComponentType[] { typeof(InnerDrawRangeSectorTag), typeof(OuterDrawRangeSectorTag) },
            None = new ComponentType[] { typeof(NotInDrawRangeSectorTag), typeof(GetSectorTopography), typeof(GenerateSectorGeology) },
            All  = new ComponentType[] { typeof(Sector), typeof(GetAdjacentSectors) }
        };

        adjSectorsGroup = GetComponentGroup(adjSectorsQuery);
    }
コード例 #5
0
    public static OffsetPairs GetNeighborFromDir(Hex hex, CubeDirections dir, OffsetPairs pairs)
    {
        CubePairs cubePairs = OffsetToCube(hex, pairs.col, pairs.row);

        switch (dir)
        {
        case CubeDirections.Left:
            if (hex.orientation == HexagonOrientation.PointyTopped)
            {
                return(CubeToOffset(hex, cubePairs.x - 1, cubePairs.y + 1, cubePairs.z));
            }
            break;

        case CubeDirections.Right:
            if (hex.orientation == HexagonOrientation.PointyTopped)
            {
                return(CubeToOffset(hex, cubePairs.x + 1, cubePairs.y - 1, cubePairs.z));
            }
            break;

        case CubeDirections.Top:
            if (hex.orientation == HexagonOrientation.FlatTopped)
            {
                return(CubeToOffset(hex, cubePairs.x, cubePairs.y + 1, cubePairs.z - 1));
            }
            break;

        case CubeDirections.Bottom:
            if (hex.orientation == HexagonOrientation.FlatTopped)
            {
                return(CubeToOffset(hex, cubePairs.x, cubePairs.y - 1, cubePairs.z + 1));
            }
            break;

        case CubeDirections.TopLeft:
            if (hex.orientation == HexagonOrientation.PointyTopped)
            {
                return(CubeToOffset(hex, cubePairs.x, cubePairs.y + 1, cubePairs.z - 1));
            }
            else if (hex.orientation == HexagonOrientation.FlatTopped)
            {
                return(CubeToOffset(hex, cubePairs.x - 1, cubePairs.y + 1, cubePairs.z));
            }
            break;

        case CubeDirections.BottomRight:
            if (hex.orientation == HexagonOrientation.PointyTopped)
            {
                return(CubeToOffset(hex, cubePairs.x, cubePairs.y - 1, cubePairs.z + 1));
            }
            else if (hex.orientation == HexagonOrientation.FlatTopped)
            {
                return(CubeToOffset(hex, cubePairs.x + 1, cubePairs.y - 1, cubePairs.z));
            }
            break;

        case CubeDirections.TopRight:
            return(CubeToOffset(hex, cubePairs.x + 1, cubePairs.y, cubePairs.z - 1));

        case CubeDirections.BottomLeft:
            return(CubeToOffset(hex, cubePairs.x - 1, cubePairs.y, cubePairs.z + 1));

        default:
            Debug.LogError("Some unknown CubeDirections enum received.");
            return(new OffsetPairs(-1, -1));
        }

        return(new OffsetPairs(-1, -1));
    }