Ejemplo n.º 1
0
        protected virtual void RepositionCell(int x, int y)
        {
            Vector3 pos = GetPositionForCell(x, y);

            BaseHexCell c = _gridCells[x, y];

            c.transform.localPosition = new Vector3(pos.x, pos.y, 0f);
            c.name = "Tile(" + x + "," + y + ")";
        }
Ejemplo n.º 2
0
 public void IterateHex_Simple(ProcessCell processCell)
 {
     for (int y = yCount - 1; y >= 0; y--)
     {
         for (int x = xCount - 1; x >= 0; x--)
         {
             BaseHexCell cell = GetCellSafe(x, y);
             processCell(cell);
         }
     }
 }
Ejemplo n.º 3
0
        internal void PostCreate()
        {
            Neighbors = new BaseHexCell[6];

            BaseHexCell n  = this._hexTerrain.GetCell(X, Y - 1);
            BaseHexCell ne = this._hexTerrain.GetCell(X + 1, GetNE_Y);
            BaseHexCell se = this._hexTerrain.GetCell(X + 1, GetSE_Y);
            BaseHexCell s  = this._hexTerrain.GetCell(X, Y + 1);
            BaseHexCell sw = this._hexTerrain.GetCell(X - 1, GetSW_Y);
            BaseHexCell nw = this._hexTerrain.GetCell(X - 1, GetNW_Y);

            Neighbors[0] = n;
            Neighbors[1] = ne;
            Neighbors[2] = se;
            Neighbors[3] = s;
            Neighbors[4] = sw;
            Neighbors[5] = nw;
        }
Ejemplo n.º 4
0
        protected override void RepositionCell(int x, int y)
        {
            Vector3 pos = GetPositionForCell(x, y);

            BaseHexCell c = _gridCells[x, y];

            c.transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
            c.name = "Tile(" + x + "," + y + ")";

            if (x * 3 + 1 < (yCount - y))
            {
                c.gameObject.SetActive(false);
            }

            if ((xCount - x) * 3 < y)
            {
                c.gameObject.SetActive(false);
            }
        }
Ejemplo n.º 5
0
        protected void CreateCellSprite(int x, int y)
        {
            BaseHexCell cell = GetCellSafe(x, y);

            cell.DrawSprites();
        }
Ejemplo n.º 6
0
        protected void PostCreateCell(int x, int y)
        {
            BaseHexCell c = _gridCells[x, y];

            c.PostCreate();
        }
Ejemplo n.º 7
0
 public void Init(BaseHexCell owner, TerrainLayer t)
 {
     _owner        = owner;
     _terrainLayer = t;
 }
Ejemplo n.º 8
0
 internal void Init(BaseHexCell isoHexCell, HeightMap heightMap)
 {
     _owner     = isoHexCell;
     _heightMap = heightMap;
 }
Ejemplo n.º 9
0
        protected override void RepositionCell(int x, int y)
        {
            BaseHexCell c = _gridCells[x, y];

            c.name = "Tile(" + x + "," + y + ")";
            int heightLevel = this.HeightMap.GetHeight(x, y);

            const float Z_OFFSET = 50f;

            float yPos = -ySize * y;
            float xPos = xSize * x;
            float zPos = -y + Z_OFFSET;

            int yLayer = y % 3;
            int xLayer = x % 3;

            //if (xLayer < 2)
            //{
            //    x++;
            //}

            if (x % 3 == 0 && y % 3 == 0)
            {
                c.gameObject.SetActive(false);
            }

            //if (y % 3 == 0)
            //{
            //    int xShiftNum = (x - 3 - 2) / 3 + 1;
            //    x += xShiftNum;
            //}

            //if ( y % 3 == 0)
            //{
            //    int xShiftNum = (x - 3 - 2) / 3 + 1;
            //    x += xShiftNum;
            //}

            if (x % 3 == 1)
            {
                yPos += horizontal_1YOffset;
                zPos -= 0.1f;
            }
            else
            if (x % 3 == 2)
            {
                yPos += horizontal_2YOffset;
                zPos += 0.1f;
            }

            if (x >= 2)
            {
                int xShiftNum = (x - 2) / 3 + 1;
                xPos -= horizontal_2XShift * xShiftNum;
            }

            if (x >= 3)
            {
                int xShiftNum = (x - 3) / 3 + 1;
                xPos -= horizontal_3XOffset * xShiftNum;
            }

            if (x >= 6)
            {
                int xShiftNum = (x - 6) / 6 + 1;
                xPos -= horizontal_6XOffset * xShiftNum;
            }

            if (y % 3 == 1)
            {
                int yShiftCount = 1;
                yShiftCount  = y;
                yShiftCount %= 3;

                xPos += vertical1_XOffset * yShiftCount;
                yPos += vertical1_YOffset;
            }

            if (y % 3 == 2)
            {
                int yShiftCount = 1;
                yShiftCount  = y;
                yShiftCount %= 3;

                xPos += vertical2_XOffset * yShiftCount;
                yPos += vertical2_YOffset;
            }

            if (y > 2)
            {
                yPos += group2_YOffset;
            }

            yPos += heightLevel * HeightMap.heightOffsetPerLevel;

            c.transform.localPosition = new Vector3(xPos, yPos, zPos);
        }