Ejemplo n.º 1
0
        // initialise the screen display objects.
        public void Init(GameObject LocationManager, GameObject TrackingSystem, string layer)
        {
            // some warning handling to ensure the user has the correct display type that they are expecting.
            if (DisplayIcon == null)
            {
                Debug.LogWarning("Display Icon has not been assigned on Location: " + this.name + ". This is not essential but may not be desired.");
            }

            if (Display_1_Text == null)
            {
                Debug.LogWarning("Display 1 Text has not been assigned on Location: " + this.name + ". This is not essential but may not be desired.");
            }

            if (Display_2_Text == null)
            {
                Debug.LogWarning("Display 2 Text has not been assigned on Location: " + this.name + ". This is not essential but may not be desired.");
            }

            if (Minimap_Display_Icon == null)
            {
                Debug.LogWarning("Minimap Display Icon has not been assigned on Location: " + this.name + ". This is not essential but may not be desired.");
            }

            // get the location tracking system for this waypoint setup.
            LocationTrackingSystem thisTrackingSystem = TrackingSystem.GetComponent <LocationTrackingSystem>();

            // create the onscreen display object.
            if (thisTrackingSystem.OnScreenDisplayPrefab != null)
            {
                thisOnScreenDisplay = Instantiate(thisTrackingSystem.OnScreenDisplayPrefab, TrackingSystem.transform.position, Quaternion.identity) as GameObject;
                thisOnScreenDisplay.transform.parent = LocationManager.transform;
                thisOnScreenDisplay.name            += " - " + this.name;
                thisOnScreenDisplay.GetComponent <OnScreenDisplay>().Init(this, thisTrackingSystem);
                SetLayerOnAll(thisOnScreenDisplay, LayerMask.NameToLayer(layer));
            }

            // create the offscreen display object.
            if (thisTrackingSystem.OffScreenDisplayPrefab != null)
            {
                thisOffScreenDisplay = Instantiate(thisTrackingSystem.OffScreenDisplayPrefab, TrackingSystem.transform.position, Quaternion.identity) as GameObject;
                thisOffScreenDisplay.transform.parent = LocationManager.transform;
                thisOffScreenDisplay.name            += " - " + this.name;
                thisOffScreenDisplay.GetComponent <OffScreenDisplay>().Init(this, thisTrackingSystem);
                SetLayerOnAll(thisOffScreenDisplay, LayerMask.NameToLayer(layer));
            }

            // add the display objects to their requred lists for tracking.
            thisOnScreenDisplayList.Add(thisOnScreenDisplay);
            thisOffScreenDisplayList.Add(thisOffScreenDisplay);
        }
Ejemplo n.º 2
0
        // initialise the setup for this location display object.
        public virtual void Init(Location location, LocationTrackingSystem thisTrackingSystem)
        {
            // get a local copy of the location object.
            thisLocation = location;

            // get a local copy of the objects transform.
            thisTransform = this.transform;

            // get a copy of this objects initial scale size.
            InitialScale = this.transform.localScale;

            // get a local copy of this locations tracking system camera.
            thisLocationsCamera = thisTrackingSystem.SystemCamera;

            // get the display option information from the location.
            UpdateDisplayInfo();
        }
Ejemplo n.º 3
0
        // Initializationof the Location Manager.
        public void Init(LocationTrackingSystem LocationSystem)
        {
            // flag to detect if any errors have occured.
            bool ErrorExists = false;

            // add this location tracking system to our list if we don't already have it.
            if (LocationSystems.Contains(LocationSystem) == false)
            {
                LocationSystems.Add(LocationSystem);
            }

            // check layers have been set
            if (DisplayLayerNames.Count <= 0)
            {
                // layers are required to display the locations for specific cameras, even for single player mode a layer is required.
                // please add the layer name to this object in the inspector and also to the Unity Layers settings.
                Debug.LogException(new UnityException("LOCATION MANAGER: No Layers have been found please assign some layers to: " + this.name));
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#endif
                ErrorExists = true;
            }
            else
            {
                // loop over each layer that has been set and ensure it exists.
                for (int i = 0; i < DisplayLayerNames.Count; i++)
                {
                    // if layer int is returned as -1 it is not found.
                    if (LayerMask.NameToLayer(DisplayLayerNames[i]) < 0)
                    {
                        // please add the layer name to the Unity Layers settings.
                        // if this layer is unneeded then simply remove it from this object in the inspector.
                        Debug.LogException(new UnityException("LOCATION MANAGER: Layer:  '" + DisplayLayerNames[i] + "' not found please add to layer settings."));
#if UNITY_EDITOR
                        UnityEditor.EditorApplication.isPlaying = false;
#endif
                        ErrorExists = true;
                    }
                }

                // check we have not activated more systems than we have display layers.
                if (LocationSystems.Count > DisplayLayerNames.Count)
                {
                    // not enough layers have been defined to support this many location systems.
                    // Please define more layer names both on this object and in the layers settings.

                    /*Debug.LogException(new UnityException("LOCATION MANAGER: Not enough layers have been defined to support this many Location systems: " + LocationSystems.Count + "."));
                     #if UNITY_EDITOR
                     * UnityEditor.EditorApplication.isPlaying = false;
                     #endif
                     * ErrorExists = true;*/
                }

                // if no errors exist then continue the location manager setup
                if (ErrorExists == false)
                {
                    // increment the layer assignment number each time.
                    LayerAssignment++;

                    // turn off visibility for all other location markers using a layer mask
                    for (int i = 0; i < DisplayLayerNames.Count; i++)
                    {
                        LocationSystem.SystemCamera.cullingMask &= ~(1 << LayerMask.NameToLayer(DisplayLayerNames[i]));
                    }

                    // turn on visibility for only this players layer
                    LocationSystem.SystemCamera.cullingMask |= 1 << LayerMask.NameToLayer(DisplayLayerNames[LayerAssignment - 1]);

                    // get each of the scenes locations and check they are active.
                    Location[] Locations = GameObject.FindObjectsOfType <Location>() as Location[];

                    if (LocationSystem.Display_Minimap)
                    {
                        // get the minimap display if it is required.
                        Minimap = LocationSystem.Minimap_GameObject.GetComponent <MinimapDisplay>();

                        // assign the camera to this minimap.
                        Minimap.Tracking_Camera = LocationSystem.SystemCamera;

                        // get the later string and set it for this minimap.
                        Minimap.Minimap_Layer = DisplayLayerNames[LayerAssignment - 1];
                    }

                    int ActiveLocations = 0;
                    for (int i = 0; i < Locations.Length; i++)
                    {
                        if (Locations[i].enabled)
                        {
                            // initialise the location and set its system owner + layer ID
                            Locations[i].Init(this.gameObject, LocationSystem.gameObject, DisplayLayerNames[LayerAssignment - 1]);

                            if (LocationSystem.Display_Minimap)
                            {
                                // set this location in the minimap display if it is required.
                                Minimap.Tracked_Locations.Add(Locations[i].GetComponent <Location>());
                            }

                            ActiveLocations++;
                        }
                    }

                    // store the number of locations we currently have in the scene.
                    NumberOfActiveLocations = ActiveLocations;

                    // ensure this object is positioned at (0,0,0) at all times
                    this.transform.position = Vector3.zero;
                }
            }
        }