Ejemplo n.º 1
0
        public Vector3 CellToWorldPositionOfCenter(Vector2 cell)
        {
            Shmipl.FrmWrk.Library.Coords coord = Vector2ToCoords(cell);
            float normCellX;
            float normCellY;

            if (cellMode == CellMode.HexCell)
            {
                if (hexModeOrientation == HexModeOrientation.Horizontal)
                {
                    normCellX = ((float)coord.x) + 1.0f /* + 1f/6f*/;
                    normCellY = (float)coord.y + 0.5f + (coord.x % 2 == 0 ? 0 : 0.5f);
                }
                else
                {
                    normCellX = (float)coord.x + 0.5f + (coord.y % 2 == 0 ? 0 : 0.5f);
                    normCellY = ((float)coord.y) + 1.0f; /*+ 1f/6f*/;
                }
            }
            else
            {
                normCellX = coord.x + 0.5f;
                normCellY = coord.y + 0.5f;
            }

            Vector2 norm_cell = new Vector2(normCellX, normCellY);
            Vector2 cell_pos  = Vector2.Scale(norm_cell, cell_size);

            Vector3 root_pos = new Vector3(transform.position.x - transform.localScale.x / 2f, 0f, transform.position.z - transform.localScale.y / 2f);
            Vector3 pos      = /*transform.root.position*/ root_pos + new Vector3(cell_pos.x, 0f, cell_pos.y);

            return(pos);
        }
Ejemplo n.º 2
0
 public static Vector2 CoordsToVector2(Shmipl.FrmWrk.Library.Coords cell)
 {
     return(new Vector2(cell.x, cell.y));
 }