예제 #1
0
        public static void InitializeMaps()
        {
            playerIconObj = RegisterDynamicObjectWithUI("PlayerIcon", -1, Vector3.zero, Vector3.forward, "Player", "PlayerIcon", "PlayerIcon", null, null);
            playerIconObj.SetWorldPositionGetter(
                () => {
                return(GameManager.playerExists ? GameManager.playerActor.GetPosition() : Vector3.zero);
                // Transform t = UIManager.GetMainCamera().transform;
                // return t == null ? Vector3.zero : t.position;
            }
                );
            playerIconObj.SetWorldForwardGetter(
                () => {
                return(GameManager.playerExists ? GameManager.playerActor.GetForward() : Vector3.forward);

                // Transform t = UIManager.GetMainCamera().transform;
                // return t == null ? Vector3.forward : t.forward;
            }
                );

            playerIconObj.ShowMapType(UIMapsObject.ShowType.MainMap, true);
            playerIconObj.ShowMapType(UIMapsObject.ShowType.MiniMap, true);



            string[] directions = new string[] { "N", "S", "E", "W" };

            float distanceValue = 99999;

            Vector3[] dirs = new Vector3[] {
                Vector3.forward *distanceValue,
                -Vector3.forward *distanceValue,
                      Vector3.right *distanceValue,
                -Vector3.right *distanceValue
            };

            for (int i = 0; i < 4; i++)
            {
                Vector3 d = dirs[i];

                UIMapsObject regObj = RegisterDynamicObjectWithUI(
                    "Direction " + directions[i], -(i + 2), Vector3.zero, d,
                    null, "DirectionIcon", null, "DirectionIcon", null
                    );

                regObj.SetWorldPositionGetter(
                    () => {
                    return((GameManager.playerExists ? GameManager.playerActor.GetPosition() : Vector3.zero) + d);

                    // Transform t = UIManager.GetMainCamera().transform;
                    // if (t == null) return d;
                    // return t.position + d;
                }
                    );
                regObj.SetMarkerInitializer((m) => (m.mainGraphic as UIText).SetText(directions[i]));

                regObj.ShowMapType(UIMapsObject.ShowType.Compass, true);
                regObj.ShowMapType(UIMapsObject.ShowType.MiniMap, true);
            }
        }
예제 #2
0
        public void RegisterWithUI()
        {
            registeredUIObj = UIMaps.RegisterStaticObjectWithUI(registerKey, transform.position, transform.forward, message, miniMapIconName, mainMapIconName, compassIconName, worldViewIconName, true);

            registeredUIObj.ShowMapType(UIMapsObject.ShowType.MainMap, true);

            // if we're registered with ui throug this script, it means we've loaded locally
            // so add to the mini map / compass
            registeredUIObj.ShowMapType(UIMapsObject.ShowType.MiniMap, true);
            registeredUIObj.ShowMapType(UIMapsObject.ShowType.Compass, true);
        }
예제 #3
0
 public void ShowType(UIMapsObject.ShowType showType, bool show)
 {
     if (show)
     {
         if (registeredUIObj == null)
         {
             RegisterWithUI();
         }
         registeredUIObj.ShowMapType(showType, true);
     }
     else
     {
         if (registeredUIObj != null)
         {
             registeredUIObj.ShowMapType(showType, false);
         }
     }
 }
예제 #4
0
        void OnDisable()
        {
            if (deregisterOnDisable)
            {
                DeregisterWithUI();
            }

            // we unloaded the object from the scene, but if it's still registered, remove from local minimap / compass
            // if it's not waypointed....

            if (registeredUIObj != null)
            {
                registeredUIObj.loadedLocally = false;

                if (!registeredUIObj.isWaypoint)
                {
                    registeredUIObj.ShowMapType(UIMapsObject.ShowType.MiniMap, false);
                    registeredUIObj.ShowMapType(UIMapsObject.ShowType.Compass, false);
                }
            }
        }
예제 #5
0
        void AddWaypoint(float zOffset)
        {
            if (defaultWaypointRegisteredObj == null && currentWaypointRegisterObj == null)
            {
                // if (currentWaypointMarker != null) {

                // TODO: Get ground Y
                if (selectedMarker == null || UIMaps.RegisteredObjectIsPlayer(selectedMarker.uIRegisteredObject))
                {
                    Vector3 worldPos = Vector3.zero;
                    Vector2 wPos     = (move);// + Vector2.one * zOffset);// * mapSize;
                    Debug.LogError(wPos);


                    worldPos.x = mapCenter.x + wPos.x * mapRadius * 2;
                    worldPos.z = mapCenter.y + wPos.y * mapRadius * 2;
                    Debug.LogError(worldPos);

                    // register the default empty icon
                    defaultWaypointRegisteredObj = UIMaps.RegisterDynamicObjectWithUI(
                        "MapWaypoint", GetInstanceID(), worldPos, Vector3.forward, "Waypoint", null, null, null, null
                        );

                    defaultWaypointRegisteredObj.SetAsWaypoint(true);

                    defaultWaypointRegisteredObj.ShowMapType(UIMapsObject.ShowType.MainMap, true);
                    defaultWaypointRegisteredObj.ShowMapType(UIMapsObject.ShowType.MiniMap, true);
                    defaultWaypointRegisteredObj.ShowMapType(UIMapsObject.ShowType.Compass, true);
                    defaultWaypointRegisteredObj.ShowMapType(UIMapsObject.ShowType.ScreenMap, true);
                }
                else
                {
                    // Debug.Log("making waypoing already thtere");
                    currentWaypointRegisterObj = selectedMarker.uIRegisteredObject;

                    // worldPos = selectedMarker.GetMarkerPosition();
                    currentWaypointRegisterObj.SetAsWaypoint(true);

                    // alraedy showing map...
                    // currentWaypointMarker.uIRegisteredObject.ShowMainMap(true);

                    currentWaypointRegisterObj.ShowMapType(UIMapsObject.ShowType.MiniMap, true);
                    currentWaypointRegisterObj.ShowMapType(UIMapsObject.ShowType.Compass, true);
                    currentWaypointRegisterObj.ShowMapType(UIMapsObject.ShowType.ScreenMap, true);

                    // currentWaypointMarker = AddMapMarker ("MapWaypoint", GetInstanceID(), waypointIcon, () => worldPos, "Waypoint");
                }
            }
            else
            {
                if (currentWaypointRegisterObj != null)
                {
                    currentWaypointRegisterObj.SetAsWaypoint(false);

                    currentWaypointRegisterObj.ShowMapType(UIMapsObject.ShowType.ScreenMap, false);

                    if (!currentWaypointRegisterObj.loadedLocally)
                    {
                        currentWaypointRegisterObj.ShowMapType(UIMapsObject.ShowType.MiniMap, false);
                        currentWaypointRegisterObj.ShowMapType(UIMapsObject.ShowType.Compass, false);
                    }
                    currentWaypointRegisterObj = null;
                }
                // else {
                // }
                if (defaultWaypointRegisteredObj != null)
                {
                    defaultWaypointRegisteredObj = UIMaps.DeregisterDynamicObjectWithUI(GetInstanceID());
                }

                // currentWaypointMarker = null;
                // defaultWaypointRegisteredObj = null;



                // RemoveMapMarker(GetInstanceID());
                // currentWaypointMarker = null;
            }
        }