Exemplo n.º 1
0
    void GenerateBaseHexes()
    {
        int layerCount = iStats.layerStats.Count;

        for (int layerIndex = 0; layerIndex < layerCount; layerIndex++)
        {
            Vector2 point = HexHelp.GetCenter(rings);
            tiles[layerIndex, (int)point.y, (int)point.x] = HexType.Earth;
            for (int ring = 1; ring < rings; ring++)
            {
                point = HexHelp.MoveInDirection(point, HexDir.Up);
                for (int direction = 0; direction < 6; direction++)
                {
                    for (int distance = 0; distance < ring; distance++)
                    {
                        bool inThreshold = iStats.layerStats[layerIndex].GetAt((int)point.x, (int)point.y) > iStats.layerStats[layerIndex].threshold;
                        bool hasBelow    = HexHelp.CheckBelow((int)point.x, (int)point.y, layerIndex, tiles);
                        if ((layerIndex == 0 || hasBelow) && inThreshold)
                        {
                            tiles[layerIndex, (int)point.y, (int)point.x] = HexType.Earth;
                        }
                        point = HexHelp.MoveInDirection(point, (HexDir)direction);
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public void DeleteFramesAndDoors(GameObject ceiling, int cityLayer, int layerPos, int yIndex, int xIndex, HexType[,,] tiles)
    {
        Vector2 point = new Vector2(xIndex, yIndex + 1);

        for (int direction = 0; direction < 6; direction++)
        {
            bool fromStairs = (cityLayer > 0) && HexHelp.CheckForStairs((int)point.x, (int)point.y, layerPos, tiles);
            if (Random.value <= openDoorChance || fromStairs)
            {
                GameObject.DestroyImmediate(ceiling.transform.Find(doorFrameNames[direction]).GetChild(0).gameObject);
            }


            //Delete frames if neighboring
            if (HexHelp.CheckDirRaw((int)point.x, (int)point.y, layerPos, tiles) && !HexHelp.CheckForStairs((int)point.x, (int)point.y, layerPos, tiles))
            {
                GameObject.Destroy(ceiling.transform.Find(doorFrameNames[direction]).gameObject);
            }

            point = HexHelp.MoveInDirection(point, (HexDir)direction);
        }
    }