Ejemplo n.º 1
0
        //-----------------------------------------------------------------------
        //Get and return elements to the object pools
        private void GetElement(string elementType)
        {
            EnvironmentElement element     = m_PoolsDictionary[elementType].GetObject().GetComponent <EnvironmentElement>();
            Vector3            startingPos = m_ElementsStartingPointsDictionary[elementType][element.name];

            if (element != null)
            {
                if (elementType != CLOUD)
                {
                    element.Activate(m_ElementsSpeed, startingPos);
                }
                else
                {
                    element.Activate(m_ElementsSpeed, startingPos);
                }

                m_ActiveElementsDictionary[elementType].Add(element);
                float posBeforeActivateNewElement = (m_BottomRightScreenCornerX * 2) - startingPos.x - GetRandomValue();
                m_DistanceBeforeGenerateNewElement[elementType] = posBeforeActivateNewElement;
            }
        }
Ejemplo n.º 2
0
        //-----------------------------------------------------------------------
        //Sun rays effect functions
        private IEnumerator ActivateSunRay(float time)
        {
            yield return(new WaitForSeconds(time));

            EnvironmentElement ray = m_SunRayPool.GetObject().GetComponent <EnvironmentElement>();

            if (ray != null)
            {
                ray.Activate(m_SunRaySpeed, m_TopRightScreenCorner);
                m_ActiveRay       = ray;
                m_RayLimit        = ray.gameObject.transform.Find("Limit").gameObject;
                m_IsSunRayPlaying = true;
            }
        }
Ejemplo n.º 3
0
        IEnumerator InitialiseBackground()
        {
            while (backgroundSpeed == 0)
            {
                yield return(new WaitForEndOfFrame());
            }

            foreach (var key in m_ElementsKeys)
            {
                EnvironmentElement element = m_PoolsDictionary[key].GetObject().GetComponent <EnvironmentElement>();
                if (element != null)
                {
                    Vector3 startingPos = element.transform.position;
                    startingPos.x = Random.Range(-m_BottomRightScreenCornerX, m_BottomRightScreenCornerX);
                    element.Activate(backgroundSpeed, startingPos);
                    m_ActiveElementsDictionary[key].Add(element);
                    float posBeforeActivateNewElement = (m_BottomRightScreenCornerX * 2) - m_ElementsStartingPointsDictionary[key][element.name].x + GetRandomValue();
                    m_DistanceBeforeGenerateNewElement.Add(key, posBeforeActivateNewElement);
                }
            }
        }
Ejemplo n.º 4
0
 public void SetupBackground()
 {
     foreach (var key in m_ElementsKeys)
     {
         EnvironmentElement element = m_PoolsDictionary[key].GetObject().GetComponent <EnvironmentElement>();
         float posBeforeActivateNewElement;
         if (element != null)
         {
             Vector3 startingPos = element.transform.position;
             startingPos.x = Random.Range(-m_BottomRightScreenCornerX, m_BottomRightScreenCornerX);
             element.Activate(m_ElementsSpeed, startingPos);
             m_ActiveElementsDictionary[key].Add(element);
             posBeforeActivateNewElement = (m_BottomRightScreenCornerX * 2) - m_ElementsStartingPointsDictionary[key][element.name].x + GetRandomValue();
             if (m_DistanceBeforeGenerateNewElement.ContainsKey(key) == false)
             {
                 m_DistanceBeforeGenerateNewElement.Add(key, posBeforeActivateNewElement);
             }
             else
             {
                 m_DistanceBeforeGenerateNewElement[key] = posBeforeActivateNewElement;
             }
         }
     }
 }