Ejemplo 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);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
 public void RemoveIfNoBottom(int layerPos, HexType[,,] tiles)
 {
     for (int yIndex = 0; yIndex < tiles.GetLength(1); yIndex += 1)
     {
         for (int xIndex = 0; xIndex < tiles.GetLength(2); xIndex += 1)
         {
             if (!HexHelp.CheckBelow(xIndex, yIndex, layerPos, tiles))
             {
                 if (tiles[layerPos, yIndex, xIndex] == HexType.StoneFoundation)
                 {
                     tiles[layerPos, yIndex, xIndex] = HexType.None;
                 }
                 else if (tiles[layerPos, yIndex, xIndex] == HexType.StoneConnectTemp)
                 {
                     if (SurroundedHorzOrVert(xIndex, yIndex, layerPos, tiles))
                     {
                         tiles[layerPos, yIndex, xIndex] = HexType.StoneFoundation;                            //TODO Fix this
                     }
                     else
                     {
                         tiles[layerPos, yIndex, xIndex] = HexType.None;
                     }
                 }
             }
             else if (tiles[layerPos, yIndex, xIndex] == HexType.StoneConnectTemp)
             {
                 tiles[layerPos, yIndex, xIndex] = HexType.StoneFoundation;
             }
         }
     }
 }
Ejemplo n.º 3
0
    void AddSingleStair(int xIndex, int yIndex, int layerPos, HexType[,,] tiles)
    {
        if (tiles[layerPos, yIndex, xIndex] != HexType.None || layerPos % 2 == 1)
        {
            bool left     = HexHelp.CheckDirRaw(xIndex - 1, yIndex, layerPos, tiles);
            bool right    = HexHelp.CheckDirRaw(xIndex + 1, yIndex, layerPos, tiles);
            bool top      = HexHelp.CheckDirRaw(xIndex, yIndex + 1, layerPos, tiles);
            bool bottom   = HexHelp.CheckDirRaw(xIndex, yIndex - 1, layerPos, tiles);
            int  adjacent = 0;
            if (left)
            {
                adjacent++;
            }
            if (right)
            {
                adjacent++;
            }
            if (bottom)
            {
                adjacent++;
            }
            if (top)
            {
                adjacent++;
            }

            bool hasBelow = HexHelp.CheckBelow(xIndex, yIndex, layerPos, tiles);
            bool hasAbove = HexHelp.CheckAbove(xIndex, yIndex, layerPos, tiles);

            if (hasBelow && !hasAbove && adjacent == 1 && Random.value <= stairChance)
            {
                //
                if (top && HexHelp.CheckDirRaw(xIndex, yIndex - 1, layerPos - 1, tiles))
                {
                    tiles[layerPos, yIndex, xIndex] = HexType.Stairs0;
                }

                else if (left && HexHelp.CheckDirRaw(xIndex + 1, yIndex, layerPos - 1, tiles))
                {
                    tiles[layerPos, yIndex, xIndex] = HexType.Stairs90;
                }

                else if (bottom && HexHelp.CheckDirRaw(xIndex, yIndex + 1, layerPos - 1, tiles))
                {
                    tiles[layerPos, yIndex, xIndex] = HexType.Stairs180;
                }

                else if (right && HexHelp.CheckDirRaw(xIndex - 1, yIndex, layerPos - 1, tiles))
                {
                    tiles[layerPos, yIndex, xIndex] = HexType.Stairs270;
                }
            }
        }
    }
Ejemplo n.º 4
0
 public void GenerateHuts(int layerPos, HexType[,,] tiles)
 {
     for (int yIndex = 0; yIndex < tiles.GetLength(1); yIndex += 2)
     {
         for (int xIndex = 0; xIndex < tiles.GetLength(2); xIndex += 2)
         {
             tiles[layerPos, yIndex, xIndex] = HexType.None;
             if (Random.value <= baseHutGenChance && HexHelp.CheckBelow(xIndex, yIndex, layerPos, tiles))
             {
                 tiles[layerPos, yIndex, xIndex] = HexType.StoneFoundation;
             }
         }
     }
 }
Ejemplo n.º 5
0
 public void GenerateConnections(int layerPos, HexType[,,] tiles)
 {
     for (int yIndex = 0; yIndex < tiles.GetLength(1); yIndex += 1)
     {
         for (int xIndex = (yIndex + 1) % 2; xIndex < tiles.GetLength(2); xIndex += 2)
         {
             tiles[layerPos, yIndex, xIndex] = HexType.None;
             bool canConnect = SurroundedHorzOrVert(xIndex, yIndex, layerPos, tiles);
             bool hasBelow   = HexHelp.CheckBelow(xIndex, yIndex, layerPos, tiles);
             if (canConnect && (hasBelow || !connectionRequiresLower) && Random.value <= connectionChance)
             {
                 if (connectionRequiresLower)
                 {
                     tiles[layerPos, yIndex, xIndex] = HexType.StoneFoundation;
                 }
                 else
                 {
                     tiles[layerPos, yIndex, xIndex] = HexType.StoneConnectTemp;
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
    void DrawBaseHexes()
    {
        int numLayers = iStats.layerStats.Count;

        //numLayers = Mathf.Min (iStats.layerStats.Count, 3);
        for (int layer = 0; layer < numLayers; layer++)
        {
            for (int y = 0; y < size; y++)
            {
                for (int x = 0; x < size; x++)
                {
                    HexType thisType = tiles[layer, y, x];
                    if (thisType == HexType.Earth)
                    {
                        bool emptyBelow = !HexHelp.CheckBelow(x, y, layer, tiles);
                        bool emptyAbove = !HexHelp.CheckAbove(x, y, layer, tiles);
                        int  prefabNum  = (int)HexDraw.middle;
                        if (emptyBelow && emptyAbove)
                        {
                            prefabNum = (int)HexDraw.both;
                        }
                        else if (emptyBelow && !emptyAbove)
                        {
                            prefabNum = (int)HexDraw.bottom;
                        }
                        else if (emptyAbove && !emptyBelow)
                        {
                            prefabNum = (int)HexDraw.top;
                        }

                        float height = 2 * layer + baseHeightStats.GetAt(x, y) - baseHeightStats.GetAvgHeight();
                        GenerateSingleHex(x, y, height, prefabNum);
                    }
                }
            }
        }
    }