Exemplo n.º 1
0
        public void SetupAdiacentTiles(List <GOTile> tiles)
        {
            Vector2 tileModifier = Vector2.zero;

            for (int i = 0; i < 4; i++)
            {
                switch (i)
                {
                case 0:                 //Top
                    tileModifier = new Vector2(0, -1);
                    break;

                case 1:                 //Left
                    tileModifier = new Vector2(-1, 0);
                    break;

                case 2:                 //Bottom
                    tileModifier = new Vector2(0, 1);
                    break;

                case 3:                 //Right
                    tileModifier = new Vector2(1, 0);
                    break;

                default:
                    break;
                }

                GOTileObj goTile = null;
                foreach (GOTile tile in tiles)
                {
                    if (tile.goTile.tileCoordinates == this.tileCoordinates + tileModifier)
                    {
                        goTile = tile.goTile;
                    }
                }

                switch (i)
                {
                case 0:                 //Top
                    topTile = goTile;
                    break;

                case 1:                 //Left
                    leftTile = goTile;
                    break;

                case 2:                 //Bottom
                    bottomTile = goTile;
                    break;

                case 3:                 //Right
                    rightTile = goTile;
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public IEnumerator DestroyTiles(List <Vector2> list)
        {
            try {
                List <string> tileListNames = new List <string> ();
                foreach (Vector2 v in list)
                {
                    string s = GOTileObj.TileNamePrototype(v, zoomLevel);
                    tileListNames.Add(s);
                }

                List <GOTile> toDestroy = new List <GOTile> ();
                foreach (GOTile tile in tiles)
                {
                    if (tile != null && !tileListNames.Contains(tile.name) && tile.goTile.status == GOTileObj.GOTileStatus.Done)
                    {
                        Debug.Log(tile.goTile.status.ToString());
                        toDestroy.Add(tile);
                    }
                }
                for (int i = 0; i < toDestroy.Count; i++)
                {
                    GOTile tile = toDestroy [i];
                    tiles.Remove(tile);
                    GameObject.Destroy(tile.gameObject, i);
                }
            } catch (Exception ex) {
                Debug.LogWarning(ex);
            }
            yield return(null);
        }
Exemplo n.º 3
0
        public static List <Vector3> CoordsToVerts(IList geometry, bool withNoise, GOTileObj goTile)
        {
            var convertedGeometry = new List <Vector3>();

            for (int i = 0; i < geometry.Count; i++)
            {
                if (geometry.GetType() == typeof(List <LatLng>))                   //Mapbox
                {
                    LatLng      c      = (LatLng)geometry [i];
                    Coordinates coords = new Coordinates(c.Lat, c.Lng, 0);
                    Vector3     p      = goTile.coordinatesToVector(coords);

                    if (withNoise && i != 0 && i != geometry.Count - 1)
                    {
                        float noise = GOFeatureMeshBuilder.Noise();
                        p.x += noise;
                        p.z += noise;
                    }

                    convertedGeometry.Add(p);
                }
                else                     //Mapzen
                {
                    IList       c      = (IList)geometry[i];
                    Coordinates coords = new Coordinates((double)c[1], (double)c[0], 0);
                    convertedGeometry.Add(goTile.coordinatesToVector(coords));
                }
            }
            return(convertedGeometry);
        }
Exemplo n.º 4
0
        static Vector3 TrasformVectorReferences(GOTileObj parent, GOTileObj local, Vector3 point)
        {
//			point = local.position + local.rotation * Vector3.Scale (Vector3.one, point);
//			point = Vector3.Scale(Vector3.one , Quaternion.Inverse (parent.rotation) * (point - parent.position));

            //Simplified version
            point = local.position + point - parent.position;
            return(point);
        }
Exemplo n.º 5
0
        public GOTileData(string url, GOTileObj tileObj, GODataType type, Vector2?tileCoords = null)
        {
            this.url      = url;
            this.goTile   = tileObj;
            this.useCache = tileObj.useCache;
            this.filename = string.Format("[{0}][{1}]{2}", tileObj.mapType.ToString(), type.ToString(), tileObj.name);
            if (tileCoords != null)
            {
                this.filename = string.Format("[{0}][{1}]{2} - {3}", tileObj.mapType.ToString(), type.ToString(), tileObj.name, tileCoords);
            }

            this.type = type;
        }
Exemplo n.º 6
0
        GOTile createSmartTileObject(Vector2 tileCoords, int Zoom)
        {
            GOTileObj  goTile  = new GOTileObj(tileCoords, zoomLevel, mapType, useElevation, elevationMultiplier, new Vector2(terrainResolution, terrainResolution), useCache, addGoFeatureComponents, locationManager.worldScale, useSatelliteBackground, satellite4X, combineFeatures, navmeshSettings);
            GameObject tileObj = new GameObject(goTile.name);

            tileObj.transform.parent = gameObject.transform;
            GOTile tile;

            if (mapType == GOMapType.Mapbox)
            {
                tile          = tileObj.AddComponent <GOMapboxTile>();
                goTile.apiKey = mapbox_accessToken;
            }
            else if (mapType == GOMapType.Mapzen_Legacy)
            {
                tile          = tileObj.AddComponent <GOMapzenProtoTile>();
                goTile.apiKey = mapzen_legacy_api_key;
            }
            else if (mapType == GOMapType.OSM)
            {
                tile          = tileObj.AddComponent <GOOSMTile>();
                goTile.apiKey = osm_api_key;
            }
            else if (mapType == GOMapType.Esri)
            {
                tile = tileObj.AddComponent <GOEsriTIle> ();
            }
            else
            {
                tile = tileObj.AddComponent <GOTile> ();
            }

            goTile.position = goTile.tileCenter.convertCoordinateToVector();
//			goTile.verticesInWorld = goTile.vertsInWorld (zoomLevel);
            tile.gameObject.transform.position = goTile.position;
            tile.map = this;

            tile.goTile = goTile;
            tiles.Add(tile);

            return(tile);
        }
Exemplo n.º 7
0
        GOTile createSmartTileObject(Vector2 tileCoords, int Zoom)
        {
            GOTileObj  goTile  = new GOTileObj(tileCoords, locationManager.zoomLevel, (GoMap.GOMap.GOMapType)mapType, useElevation, 1, new Vector2(50, 50), useCache, false, locationManager.worldScale, useSatelliteBackground, satellite4X, false, navmeshSettings);
            GameObject tileObj = new GameObject(goTile.name);

            tileObj.transform.parent = gameObject.transform;
            GOTile tile;

            if (mapType == GOMapType.Mapbox)
            {
                tile          = tileObj.AddComponent <GOMapboxTile>();
                goTile.apiKey = mapbox_accessToken;
            }
            else if (mapType == GOMapType.Mapzen_Legacy)
            {
                tile          = tileObj.AddComponent <GOMapzenProtoTile>();
                goTile.apiKey = mapzen_legacy_api_key;
            }
            else if (mapType == GOMapType.OSM)
            {
                tile          = tileObj.AddComponent <GOOSMTile>();
                goTile.apiKey = osm_api_key;
            }
            else if (mapType == GOMapType.Esri)
            {
                tile = tileObj.AddComponent <GOEsriTIle>();
            }
            else
            {
                tile = tileObj.AddComponent <GOTile>();
            }

            goTile.position = goTile.tileCenter.convertCoordinateToVector();
            tile.gameObject.transform.position = goTile.position;

            tile.goTile = goTile;

            return(tile);
        }
Exemplo n.º 8
0
        public GOFeature(GOFeature f)
        {
            name          = f.name;
            featureIndex  = f.featureIndex;
            goFeatureType = f.goFeatureType;
            properties    = f.properties;
            attributes    = f.attributes;
            layer         = f.layer;
            goTile        = f.goTile;

            //After editing the feature in tile subclasses.

            //		public string kind;
            kind             = f.kind;
            renderingOptions = f.renderingOptions;
            detail           = f.detail;
            sort             = f.sort;
            y            = f.y;
            height       = f.height;
            featureIndex = f.featureIndex;
            layerIndex   = f.layerIndex;
            featureCount = f.featureCount;
        }
Exemplo n.º 9
0
        bool isSmartTileAlreadyCreated(Vector2 tileCoords, int Zoom)
        {
            string name = GOTileObj.TileNamePrototype(tileCoords, zoomLevel);

            return(transform.Find(name));
        }