IEnumerator Start()
    {
        getMainMapMap().initialize();
        yield return(StartCoroutine(player_loc._StartLocationService()));

        StartCoroutine(player_loc.RunLocationService());

        locationServicesIsRunning = player_loc.locServiceIsRunning;
        Debug.Log("Player loc from GameManager: " + player_loc.loc);
        getMainMapMap().centerMercator = getMainMapMap().tileCenterMercator(player_loc.loc);
        getMainMapMap().DrawMap();

        mainMap.transform.localScale = Vector3.Scale(
            new Vector3(getMainMapMap().mapRectangle.getWidthMeters(), getMainMapMap().mapRectangle.getHeightMeters(), 1.0f),
            new Vector3(getMainMapMap().realWorldtoUnityWorldScale.x, getMainMapMap().realWorldtoUnityWorldScale.y, 1.0f));

        player.GetComponent <ObjectPosition> ().setPositionOnMap(player_loc.loc);

        GameObject[] objectsOnMap = GameObject.FindGameObjectsWithTag("ObjectOnMap");

        foreach (GameObject obj in objectsOnMap)
        {
            obj.GetComponent <ObjectPosition> ().setPositionOnMap();
        }
    }
    IEnumerator Start()
    {
        if (mainMap == null)
        {
            yield break;
        }

        GetMainMapMap().initialize();
        yield return(StartCoroutine(player_loc._StartLocationService()));

        StartCoroutine(player_loc.RunLocationService());

        locationServicesIsRunning = player_loc.locServiceIsRunning;

        Debug.Log("Player loc from GeoGameManager: " + player_loc.loc);
        GetMainMapMap().centerMercator = GetMainMapMap().tileCenterMercator(player_loc.loc);
        GetMainMapMap().DrawMap();

        mainMap.transform.localScale = Vector3.Scale(
            new Vector3(GetMainMapMap().mapRectangle.getWidthMeters(), GetMainMapMap().mapRectangle.getHeightMeters(), 1.0f),
            new Vector3(GetMainMapMap().realWorldtoUnityWorldScale.x, GetMainMapMap().realWorldtoUnityWorldScale.y, 1.0f));

        player.GetComponent <ObjectPosition> ().SetPositionOnMap(player_loc.loc);

        // Finds the object (Camera) with the transition script and updates it's location
        FindObjectOfType <Transition>().Setup();
    }
    IEnumerator Start()
    {
        getMainMap().initialize();
        foreach (GameObject map in outerMaps)
        {
            getOuterMap(map).initialize();
        }

        yield return(StartCoroutine(player_loc._StartLocationService()));

        StartCoroutine(player_loc.RunLocationService());

        locationServicesIsRunning = player_loc.locServiceIsRunning;
        Debug.Log("Player loc from GameManager: " + player_loc.loc);

        GoogleStaticMap mainMap = getMainMap();

        mainMap.centerMercator = mainMap.tileCenterMercator(player_loc.loc);
        mainMap.DrawMap();

        mainMap.transform.localScale = Vector3.Scale(
            new Vector3(mainMap.mapRectangle.getWidthMeters(), mainMap.mapRectangle.getHeightMeters(), 1),
            new Vector3(mainMap.realWorldtoUnityWorldScale.x, mainMap.realWorldtoUnityWorldScale.y, 1));

        getOuterMap(outerMaps[0]).centerMercator = newCenterMercator(mainMap, NW);
        getOuterMap(outerMaps[1]).centerMercator = newCenterMercator(mainMap, NW, NE);
        getOuterMap(outerMaps[2]).centerMercator = newCenterMercator(mainMap, NE);
        getOuterMap(outerMaps[3]).centerMercator = newCenterMercator(mainMap, NE, SE);
        getOuterMap(outerMaps[4]).centerMercator = newCenterMercator(mainMap, SE);
        getOuterMap(outerMaps[5]).centerMercator = newCenterMercator(mainMap, SW, SE);
        getOuterMap(outerMaps[6]).centerMercator = newCenterMercator(mainMap, SW);
        getOuterMap(outerMaps[7]).centerMercator = newCenterMercator(mainMap, NW, SW);

        foreach (GameObject map in outerMaps)
        {
            getOuterMap(map).DrawMap();
        }

        for (int i = 0; i < outerMaps.Length; i++)
        {
            GameObject      map    = outerMaps[i];
            GoogleStaticMap mapMap = getOuterMap(map);
            map.transform.localScale = Vector3.Scale(
                new Vector3(mapMap.mapRectangle.getWidthMeters(), mapMap.mapRectangle.getHeightMeters(), 1F),
                new Vector3(mapMap.realWorldtoUnityWorldScale.x, mapMap.realWorldtoUnityWorldScale.y, 1F));
            setNewPos(i);
        }

        player.GetComponent <ObjectPosition>().setPositionOnMap(player_loc.loc);

        GameObject[] objectsOnMap = GameObject.FindGameObjectsWithTag("ObjectOnMap");

        foreach (GameObject obj in objectsOnMap)
        {
            obj.GetComponent <ObjectPosition>().setPositionOnMap();
        }
    }
    IEnumerator Start()
    {
        //Init
        getMainMapMap().initialize();
        yield return(StartCoroutine(player_loc._StartLocationService()));

        StartCoroutine(player_loc.RunLocationService());

        locationServicesIsRunning = player_loc.locServiceIsRunning;
        Debug.Log("Player loc from GameManager: " + player_loc.loc);
        getMainMapMap().centerMercator = getMainMapMap().tileCenterMercator(player_loc.loc);
        getMainMapMap().DrawMap();

        mainMap.transform.localScale = Vector3.Scale(
            new Vector3(getMainMapMap().mapRectangle.getWidthMeters(), getMainMapMap().mapRectangle.getHeightMeters(), 1.0f),
            new Vector3(getMainMapMap().realWorldtoUnityWorldScale.x, getMainMapMap().realWorldtoUnityWorldScale.y, 1.0f));

        //Set Position of Player
        Coordinate c = new Coordinate();

        c.Latitude  = GameData.Instance.Me.Position.Latitude;
        c.Longitude = GameData.Instance.Me.Position.Longitude;
        player.GetComponent <ObjectPosition>().start = c;
        player.GetComponent <ObjectPosition>().SetGeoPoint();
        player.GetComponent <ObjectPosition> ().setPositionOnMap(player_loc.loc);

        // Breaking for debugging
        yield break;

        //Set Position of GameObjects
        //GameObject[] objectsOnMap = GameObject.FindGameObjectsWithTag ("ObjectOnMap");

        //      List<Route> routes = MyDataBase.Instance.GetRoutesByStartingLocation(new Vector2(player_loc.loc.lat_d, player_loc.loc.lon_d), 100);

        //      //Need to fix TODO
        //      foreach (GameObject obj in objectsOnMap)
        //      {
        //          obj.SetActive(false);
        //      }
        //      foreach (GameObject obj in objectsOnMap) {
        //          if (routes.Count == 0)
        //          {
        //              break;
        //          }
        //          obj.GetComponent<ObjectPosition>().setLatLon_deg(routes[0].getCoordinates()[0].Latitude, routes[0].getCoordinates()[0].Longitude);
        //          routes.Remove(routes[0]);
        //	obj.GetComponent<ObjectPosition> ().setPositionOnMap ();
        //          obj.SetActive(true);
        //}
    }
Exemple #5
0
 //Start Location Service
 private void StartLocationService()
 {
     player_loc = FindObjectOfType <PlayerLocationService>();
     StartCoroutine(player_loc._StartLocationService());
     StartCoroutine(player_loc.RunLocationService());
 }