Ejemplo n.º 1
0
    public Coroutine Deactivate()
    {
        activeElementIndex = -1;
        activated          = false;

        if (SiteManager.activeSiteElementSet == this)
        {
            SiteManager.activeSiteElementSet = null;
        }


        if (activeElement)
        {
            return(activeElement.Deactivate());
        }


        return(null);
    }
Ejemplo n.º 2
0
    // Creates a nice screensaver/scene scroller while idling.
    public IEnumerator IdleScroll()
    {
        // Get all currently loaded site elements.
        List <SiteElement> loadedElements = allLoadedSiteElements;

        // If no sites have been loaded yet, we need to load at least one.
        if (loadedElements.Count <= 0)
        {
            Debug.LogWarning("No data already loaded. Attempting to load very first data set");

            // Loading the first site element.
            yield return(allSiteElements[0].Load());

            loadedElements = allLoadedSiteElements;

            // If we STILL couldn't load an element, quit the application... this means the screensaver failed, and if it failed, we risk burn-in.
            if (loadedElements.Count <= 0)
            {
                Debug.LogError("Could not go to screensaver mode because no data was found! Exiting application in 1 minute to prevent burn-in.");
                yield return(new WaitForSeconds(60.0f));

                Application.Quit();
            }
        }

        // All loaded site elements.
        loadedElements = allLoadedSiteElements;

        // Variable to keep track of our element index.
        int currentElementIndex = 0;

        // While we're supposed to idle.
        while (ShouldIdle())
        {
            // Get a new element.
            SiteElement currentElement = loadedElements[currentElementIndex];

            // Activate the specified element.
            yield return(currentElement.Activate());

            // Initialize an elapsed time.
            float elapsedTime = 0.0f;

            // Save the initial player rotation.
            Quaternion originalPlayerRotation = Player.instance.transform.rotation;

            // While the idle time is less than idle duration we want, and the system should still be idling.
            // If there is only one loaded element, don't try to switch between elements (prevents jumping around)
            while ((elapsedTime < GameManager.instance.secondsPerIdleScene || loadedElements.Count == 1) && ShouldIdle())
            {
                // // If this is a panorama, just rotate the camera around and look at the whole 360 photo.
                // if (currentElement is Panorama)
                // {
                //     // Speed of rotation.
                //     float camRotationSpeed = 0.05f;

                //     // Actually rotate the player.
                //     Player.instance.transform.Rotate(Vector3.up, camRotationSpeed);

                // }

                // // If this element is a model.
                // else if (currentElement is Model)
                // {
                //     // TODO: Add functionality for idling with models.
                // }
                currentElement.idleAnimation.Tick();

                // Wait a frame, then increase the elapsed time and loop again.
                yield return(null);

                elapsedTime += Time.deltaTime;
            }

            // Reset the player's rotation.
            Player.instance.transform.rotation = originalPlayerRotation;

            // Deactivate the last activated element.
            yield return(currentElement.Deactivate());

            // Increment the current element we're loading.
            currentElementIndex++;

            // Wrap back to start if needed.
            if (currentElementIndex >= loadedElements.Count)
            {
                currentElementIndex = 0;
            }

            // Wait a frame, then loop again.
            yield return(null);
        }
    }