void Start()
    {
        _factory  = FindObjectOfType <DirectionsFactory>();
        _dropdown = GetComponent <Dropdown>();
        if (_dropdown != null)
        {
            _dropdown.onValueChanged.AddListener((index) =>
            {
                switch (index)
                {
                case 0:
                    _factory.ChangeRoutingProfile(RoutingProfile.Driving);
                    break;

                case 1:
                    _factory.ChangeRoutingProfile(RoutingProfile.Walking);
                    break;

                case 2:
                    _factory.ChangeRoutingProfile(RoutingProfile.Cycling);
                    break;
                }
            });
        }
    }
        private void OnMouseUp()
        {
            _camera.moveFlag = true;
            GameObject g;

            if (_waypointType != null)
            {
                g = GameObject.FindGameObjectWithTag(_waypointType);
                DirectionsFactory theDirect = GameObject.Find("Directions(Clone)").GetComponent <DirectionsFactory>();
                if (!theDirect.scheduleOrNot)
                {
                    Vector2d v = theDirect.TransferName(g.transform);
                    if (_waypointType == "pinpoint1")
                    {
                        string stemp = v.x + "," + v.y;
                        searchApi = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + stemp + "&rankby=distance&type=establishment&key=AIzaSyCCaNjplKt-tq3Nvxq0Hb28Etu7KZUaqE0";
                        var    startcontent = JObject.Parse(client.GetStringAsync(searchApi).Result);
                        string t            = startcontent["results"][0]["name"].ToString();
                        startPoint.text = t;
                    }
                    if (_waypointType == "pinpoint2")
                    {
                        string stemp = v.x + "," + v.y;
                        searchApi = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + stemp + "&rankby=distance&type=establishment&key=AIzaSyCCaNjplKt-tq3Nvxq0Hb28Etu7KZUaqE0";
                        var    startcontent = JObject.Parse(client.GetStringAsync(searchApi).Result);
                        string t            = startcontent["results"][0]["name"].ToString();
                        endPoint.text = t;
                    }
                }
            }
        }
Exemplo n.º 3
0
    void Start()
    {
        OnToggleValueChanged(true);
        _directionsFactory = FindObjectOfType <DirectionsFactory>();
        distChecker        = FindObjectOfType <DistanceChecker>();

        CenterCamera(playerTransform.position.x, playerTransform.position.z);
    }
 public void route2()
 {
     if (instance)
     {
         DirectionsFactory theDirect = instance.GetComponent <DirectionsFactory>();
         theDirect.routeNum = 1;
         theDirect.Refresh();
     }
 }
Exemplo n.º 5
0
    public void StartQuest(Quest quest)
    {
        DirectionsFactory df = GameObject.Find("Directions").GetComponent <DirectionsFactory>();

        df.endPos = new Vector2d(quest.Stop_co.Lat, quest.Stop_co.Lon);
        df.Query();
        DrawRadiationZones();
        GameObject.Find("QuestPanel").GetComponent <RectTransform>().localPosition = new Vector3(-800, 100, 0);
        controller.SetActiveQuest(quest);
        Debug.Log(quest.Stop_co.Lat);
        Debug.Log("Quest Started");
    }
    private void DrawDirection(String type)
    {
        string startBuilding = StartPoint.text;
        string endBuilding   = EndPoint.text;

        if (instance == null)
        {
            DirectionsFactory theDirect = _direction.GetComponent <DirectionsFactory>();
            theDirect.scheduleOrNot = false;
            List <Transform> thelist1 = theDirect._waypoints.ToList();
            while (thelist1.Count > 2)
            {
                thelist1.RemoveAt(thelist1.Count - 1);
            }
            theDirect._waypoints = thelist1.ToArray();
            if (type != "Search")
            {
                theDirect._routeType = type;
            }
            List <Vector2d> theList = theDirect._waypointsGeo.ToList();
            theList.Clear();
            if (!startBuilding.ToString().Equals("user"))
            {
                string stemp = startBuilding.Replace(" ", "%20");
                searchApi = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=" + stemp + "&inputtype=textquery&fields=geometry&key=AIzaSyCCaNjplKt-tq3Nvxq0Hb28Etu7KZUaqE0";

                var startcontent = JObject.Parse(client.GetStringAsync(searchApi).Result);

                double lat = Double.Parse(startcontent["candidates"][0]["geometry"]["location"]["lat"].ToString());
                double lng = Double.Parse(startcontent["candidates"][0]["geometry"]["location"]["lng"].ToString());


                theDirect.userOrNot = false;
                theList.Add(new Vector2d(lat, lng));
            }
            else
            {
                theList.Add(new Vector2d(0, 0));
                Vector3 temp = _user.transform.position;
                theDirect._userPosition = temp;
                theDirect.userOrNot     = true;
            }
            string etemp = endBuilding.Replace(" ", "%20");
            searchApi = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=" + etemp + "&inputtype=textquery&fields=geometry&key=AIzaSyCCaNjplKt-tq3Nvxq0Hb28Etu7KZUaqE0";
            var endcontent = JObject.Parse(client.GetStringAsync(searchApi).Result);

            double elat = Double.Parse(endcontent["candidates"][0]["geometry"]["location"]["lat"].ToString());
            double elng = Double.Parse(endcontent["candidates"][0]["geometry"]["location"]["lng"].ToString());
            theList.Add(new Vector2d(elat, elng));
            theDirect._waypointsGeo = theList.ToArray();
            instance = Instantiate(_direction, new Vector3(0, 0, 0), Quaternion.identity);
        }
        else
        {
            DirectionsFactory theDirect = instance.GetComponent <DirectionsFactory>();
            if (theDirect._routeType != type)
            {
                instance = null;
                GameObject.Find("Directions(Clone)").Destroy();
                GameObject.Find("direction waypoint  entity").Destroy();
                GameObject[] g = GameObject.FindGameObjectsWithTag("waypointc");
                foreach (GameObject gg in g)
                {
                    Destroy(gg);
                }
                DrawDirection(type);
            }
        }
    }
 private void DrawDirectionBySchedule(String type)
 {
     if (instance == null)
     {
         DirectionsFactory theDirect = _direction.GetComponent <DirectionsFactory>();
         theDirect.scheduleOrNot = true;
         if (type != "Schedule")
         {
             theDirect._routeType = type;
         }
         List <Vector2d> theList = theDirect._waypointsGeo.ToList();
         theList.Clear();
         int index = 0;
         theDirect.userOrNot = false;
         List <Transform> thelist1 = theDirect._waypoints.ToList();
         while (thelist1.Count > 2)
         {
             thelist1.RemoveAt(thelist1.Count - 1);
         }
         foreach (string item in classSchedule)
         {
             string stemp = (item).Replace(" ", "%20");
             searchApi = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=" + stemp + "&inputtype=textquery&fields=geometry&key=AIzaSyCCaNjplKt-tq3Nvxq0Hb28Etu7KZUaqE0";
             var    startcontent = JObject.Parse(client.GetStringAsync(searchApi).Result);
             double lat          = Double.Parse(startcontent["candidates"][0]["geometry"]["location"]["lat"].ToString());
             double lng          = Double.Parse(startcontent["candidates"][0]["geometry"]["location"]["lng"].ToString());
             if (index == 0)
             {
                 theList.Add(new Vector2d(lat, lng));
                 if (classSchedule.Count() == 1)
                 {
                     theList.Add(new Vector2d(lat, lng));
                 }
             }
             else if (index == 1)
             {
                 theList.Add(new Vector2d(lat, lng));
             }
             else
             {
                 thelist1.Add(Instantiate(wayPoint, new Vector2(0, 0), Quaternion.identity).transform);
                 theList.Add(new Vector2d(lat, lng));
             }
             index++;
         }
         theDirect._waypoints    = thelist1.ToArray();
         theDirect._waypointsGeo = theList.ToArray();
         instance = Instantiate(_direction, new Vector3(0, 0, 0), Quaternion.identity);
     }
     else
     {
         DirectionsFactory theDirect = instance.GetComponent <DirectionsFactory>();
         if (theDirect._routeType != type)
         {
             instance = null;
             GameObject.Find("Directions(Clone)").Destroy();
             GameObject.Find("direction waypoint  entity").Destroy();
             GameObject[] g = GameObject.FindGameObjectsWithTag("waypointc");
             foreach (GameObject gg in g)
             {
                 Destroy(gg);
             }
             DrawDirectionBySchedule(type);
         }
     }
 }
Exemplo n.º 8
0
 public void Start()
 {
     directions   = FindObjectOfType <DirectionsFactory>();
     userPosition = GameObject.Find("User Icon Master");
 }