Exemplo n.º 1
0
        void Update()
        {
            //Has loaded next context and still has props from previous background
            //Wait until all props have been unloaded.
            if (HasPropsFromPreviousBackground() && hasNextContextLoaded)
            {
                return;
            }
            else if (!HasPropsFromPreviousBackground() && hasNextContextLoaded)
            {
                SwapPropsToCurrentContext();
            }

            if (currentBackgroundContext == lastBackground)
            {
                return;
            }

            //Randomize props for this context
            if (!HasPropsFromPreviousBackground() && !hasNextContextLoaded)
            {
                currentContextProps = BackgroundService.SetPropsForBackgroundContext(propsPool, currentBackgroundContext, maxPropsAmount, backgroundDisplay);

                for (int i = 0; i < currentContextProps.Count; i++)
                {
                    currentContextProps[i].SetActive(true);
                }
            }

            backgroundTickTime += Time.deltaTime;

            if (backgroundTickTime >= timeToChangeBackground)
            {
                currentBackgroundContext = BackgroundService.GetNextContext(currentBackgroundContext, lastBackground.GetHashCode(), ref maxPropsAmount);
                LoadNextBackground();
            }
        }