private void MapLoadFinished(MapLoadedArgs args)
        {
            if (this.printDebugOutput)
            {
                Debug.Log($"GoogleMapsManager MapLoaded Complete");
            }

            this.isMapServiceLoaded = true;
            this.mapsService.Events.MapEvents.Loaded.RemoveListener(this.MapLoadFinished);
        }
示例#2
0
        void OnMapLoaded(MapLoadedArgs args)
        {
            // Everything was loaded
            // Adjust the scale of our road lattice nodes
            SphereCollider[] nodes = RoadLatticeDebugObject.GetComponentsInChildren <SphereCollider>();

            foreach (SphereCollider sc in nodes)
            {
                sc.transform.localScale = new Vector3(4f, 4f, 4f);
            }
        }
示例#3
0
        /// <summary>
        /// Once the map is loaded, setup main character and AI agents.
        /// Start activating the search.
        /// </summary>
        private void OnMapLoaded(MapLoadedArgs args)
        {
            if (CharactersContainer != null && BaseMapLoader != null)
            {
                GameObject avatarGO = GetRandomCharacter(AvatarPrefab);
                RoadLatticeCharacterController cc = avatarGO.GetComponent <RoadLatticeCharacterController>();

                if (cc != null)
                {
                    cc.BaseMapLoader = BaseMapLoader;
                    cc.ShowPath      = true;
                }

                // Start following our Avatar on the map
                if (SmoothFollowCamera != null)
                {
                    SmoothFollowCamera.target = avatarGO.transform;
                    SmoothFollowCamera.transform.LookAt(SmoothFollowCamera.target);
                }

                // Add random npc characters on map (red)
                for (int i = 0; i < NumberOfOpponents; i++)
                {
                    GameObject npcGO            = GetRandomCharacter(NPCPrefab);
                    RoadLatticeAIController aic = npcGO.GetComponent <RoadLatticeAIController>();

                    if (aic != null)
                    {
                        aic.BaseMapLoader = BaseMapLoader;
                        aic.Target        = avatarGO;
                        aic.enabled       = true;
                        NPCs.Add(aic);

                        if (cc != null)
                        {
                            // Move distant NPCs closer to the avatar so that they don't take too long to reach
                            // their target.
                            Vector3 diff            = aic.transform.position - cc.transform.position;
                            Vector3 desiredPosition = Vector3.MoveTowards(cc.transform.position,
                                                                          aic.transform.position, Mathf.Min(diff.magnitude, MaxAIStartDistanceFromAvatar));

                            RoadLatticeNode node =
                                BaseMapLoader.MapsService.RoadLattice.SnapToNode(desiredPosition);
                            aic.transform.position = new Vector3(node.Location.x, 0, node.Location.y);
                        }
                    }
                }
            }

            ActiveAllNPCs(IsAISearchActive);
            ShowAIPaths(IsDebugPathOn);
        }
示例#4
0
        /// <summary>
        /// OnMapLoaded is called each time the map region is updated - either loaded or unloaded.
        /// When this happens, some of the <see cref="GameObject"/>s related to map features might have
        /// been removed from the scene.
        /// Therefore we need to perform some clean up on all collections that might have references to
        /// these objects.
        /// </summary>
        public void OnMapLoaded(MapLoadedArgs args)
        {
            // Adjust the content of our dictionary with all GameObjects actually in the scene.
            List <string> toRemove = PlaceIdToGameObjectDict.Where(pair => pair.Value == null)
                                     .Select(pair => pair.Key)
                                     .ToList();

            if (toRemove.Count > 0)
            {
                foreach (string placeId in toRemove)
                {
                    PlaceIdToGameObjectDict.Remove(placeId);
                }
            }
        }
    /// <summary>
    /// Example of OnLoaded event listener.
    /// </summary>
    /// <remarks>
    /// The communication between the game and the MapsSDK is done through APIs and event listeners.
    /// </remarks>
    public void OnLoaded(MapLoadedArgs args)
    {
        // The Map is loaded - you can start/resume gameplay from that point.
        // The new geometry is added under the GameObject that has MapsService as a component.

        //_ShowAndroidToastMessage("Map loaded about to spawn cube");
        StartCoroutine(GetLocation());

        // Apply a post-creation listener that adds the squashing MonoBehaviour
        // to each building.
        mapsService.Events.ExtrudedStructureEvents.DidCreate.AddListener(
            e => { AddSquasher(e.GameObject); });

        // Apply a post-creation listener that adds the squashing MonoBehaviour
        // to each building.
        mapsService.Events.ModeledStructureEvents.DidCreate.AddListener(
            e => { AddSquasher(e.GameObject); });
    }
        /// <summary>
        /// Example of OnLoaded event listener.
        /// </summary>
        /// <remarks>
        /// The communication between the game and the MapsSDK is done through APIs and event listeners.
        /// </remarks>
        public void OnLoaded(MapLoadedArgs args)
        {
            isLoaded = true;
            // The Map is loaded - you can start/resume gameplay from that point.
            // The new geometry is added under the GameObject that has MapsService as a component.
            Debug.Log(transform);
            List <Transform> ExtrudedBuildings = new List <Transform>();
            GameObject       scrollView        = GameObject.Find("Building Scroll View/Viewport/Content");

            foreach (Transform child in transform)
            {
                Debug.Log(child);
                if (child.GetComponent <Google.Maps.Unity.ExtrudedStructureComponent>() != null)
                {
                    child.transform.localScale = new Vector3(2, 2, 2);
                    ExtrudedBuildings.Add(child);
                }
            }

            int count = 0;

            scrollView.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ExtrudedBuildings.Count * 21);
            foreach (Transform building in ExtrudedBuildings)
            {
                count++;
                GameObject addedChild = (GameObject)Instantiate(togglePrefab, scrollView.transform);
                addedChild.GetComponent <Transform>().position = new Vector3(110, count * 20, 0);

                Text text = addedChild.GetComponentInChildren <Text>();
                text.text = building.GetComponent <Google.Maps.Unity.ExtrudedStructureComponent>().GetMapFeature().MapFeatureMetadata.Name;

                Toggle toggle = addedChild.GetComponent <Toggle>();
                toggle.onValueChanged.AddListener((bool toggled) =>
                {
                    building.GetComponent <MeshRenderer>().enabled = !building.GetComponent <MeshRenderer>().enabled;
                });
            }
        }
示例#7
0
 /// <summary>
 /// Example of OnLoaded event listener.
 /// </summary>
 /// <remarks>
 /// The communication between the game and the MapsSDK is done through APIs and event listeners.
 /// </remarks>
 public void OnLoaded(MapLoadedArgs args)
 {
     // The Map is loaded - you can start/resume gameplay from that point.
     // The new geometry is added under the GameObject that has MapsService as a component.
     loaded = true;
 }
示例#8
0
 private static void OnMapLoadedCallback(MapLoadedArgs arguments)
 {
     Instance.Hide();
 }
示例#9
0
 /// <summary>
 /// On loading completed, hide the progress bar.
 /// </summary>
 void OnMapLoadComplete(MapLoadedArgs args)
 {
     HideProgressBar();
 }
示例#10
0
 void OnMapLoaded(MapLoadedArgs args)
 {
     Loaded = true;
 }