Example #1
0
 /// <summary>
 /// Move the sprite renderers.
 /// </summary>
 /// <param name="parallaxManager">The parallax.</param>
 /// <param name="camera">The main camera.</param>
 /// <param name="time">Time.deltaTime multiplied by the global parallax scroll speed.</param>
 public void Update(ParallaxManager parallaxManager, Camera camera, float time)
 {
     foreach (Renderer spriteRenderer in spriteRenderers.ToArray())
     {
         spriteRenderer.transform.Translate(time * -speedRatio, 0.0f, 0.0f);
     }
 }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     if (m_parallaxManager == null)
     {
         m_parallaxManager = GameObject.FindGameObjectWithTag("ParallaxManager").GetComponent <ParallaxManager>();
     }
     this.transform.position += m_directionMouvement * m_parallaxManager.getGroundSpeedf();
 }
 void OnEnable()
 {
     this.parallaxManager = target as ParallaxManager;
     this.parallaxManagerSerializedObject = new SerializedObject(this.parallaxManager);
     this.backgroundSizeProp = this.parallaxManagerSerializedObject.FindProperty("backgroundSize");
     this.layersProp         = this.parallaxManagerSerializedObject.FindProperty("layers");
     this.layersSize         = this.layersProp.arraySize;
 }
    // Update is called once per frame
    void Update()
    {
        if (m_parallaxManager == null) {
            m_parallaxManager = GameObject.FindGameObjectWithTag("ParallaxManager").GetComponent<ParallaxManager>();

        }
        this.transform.position += m_directionMouvement * m_parallaxManager.getGroundSpeedf ();
    }
Example #5
0
    private void Start()
    {
        instance = this;
        if (!SystemInfo.supportsGyroscope)
        {
            enabled = false;
        }

        Input.gyro.enabled = true;
        offset             = Input.gyro.gravity;
    }
Example #6
0
 private void Start()
 {
     if (this.useCustomParallax)
     {
         ParallaxManager.ParallaxCustomLayer pcl = default(ParallaxManager.ParallaxCustomLayer);
         pcl.layer  = base.gameObject;
         pcl.speedX = 1f;
         ParallaxManager parallaxManager = UnityEngine.Object.FindObjectOfType(typeof(ParallaxManager)) as ParallaxManager;
         parallaxManager.RegisterParallaxLayer(pcl);
     }
     for (int i = 0; i < this.m_maxClouds; i++)
     {
         this.SpawnCloud();
     }
 }
Example #7
0
    private const int NUM_LAYERS = 2;       // Number of layers to instantiate.

    /** Set up the ParallaxManager's functionality.
     * Set the Singleton design pattern, make the layers list, and instantiate all of the
     * parallax layers.
     */
    private void Awake()
    {
        if (instance == null)           // Set up the Singleton design pattern.
        {
            instance = this;
        }
        layers = new List <ParallaxLayer>();
        Vector3 layerPos = Vector3.zero;

        for (int i = 0; i < NUM_LAYERS; i++)
        {
            ParallaxLayer pl  = Instantiate(bg, layerPos, Quaternion.identity);
            ParallaxLayer plA = Instantiate(back, layerPos, Quaternion.identity);
            ParallaxLayer plB = Instantiate(front, layerPos, Quaternion.identity);
            layers.Add(pl);
            layers.Add(plA);
            layers.Add(plB);
            layerPos = new Vector3(layerPos.x + back.GetComponent <SpriteRenderer>().bounds.size.x, 0, 0);
        }
    }
Example #8
0
    void Update()
    {
        if (_runner == null)
        {
            _runner = transform.FindChild("Platform/Runner").gameObject;
        }
        int range = Random.Range(1, 10);

        for (int i = 0; i < itemPrefabs.Length; i++)
        {
            if (_lastSpawnTime[i] + frequency[i] < Time.time)
            {
                Debug.Log(range);
                if (range % 2 == 0 || _randomchance[i] == 1)
                {
                    GameObject item = GameObject.Instantiate(itemPrefabs[i]) as GameObject;
                    item.transform.SetParent(platform, false);
                    Vector3 _runnerPostion = _runner.transform.localPosition;
                    item.transform.localPosition = new Vector3(_runner.transform.localPosition.x + _size * 2, item.transform.localPosition.y, item.transform.localPosition.z);
                    item.name = itemPrefabs[i].name;
                    ParallaxManager _parallax = item.AddComponent <ParallaxManager>();

                    if (item.name.Contains("Lamp"))
                    {
                        _parallax.parallaxSpeed      = 0.65f;
                        item.transform.localScale    = new Vector3(2, 2, 1);
                        item.transform.localPosition = new Vector3(_runner.transform.localPosition.x + _size * 2, 2, item.transform.localPosition.z);
                        world.GetComponent <World>().LampPostList.Add(item.GetComponent <LampPost>());
                    }
                    else
                    {
                        _parallax.parallaxSpeed = 0.65f;
                    }

                    _lastSpawnTime[i] = Time.time;
                }
            }
        }
    }
Example #9
0
 private void Awake()
 {
     _renderer        = GetComponent <SpriteRenderer>();
     _parallaxManager = ParallaxManager.Instance;
     Transform        = transform;
 }
Example #10
0
 // Use this for initialization
 void Awake()
 {
     player   = transform;
     instance = this;
 }
 void Start()
 {
     parallaxManager = GameObject.Find(Strings.PARALLAXMANAGER).GetComponent<ParallaxManager>();
     cloudManager = GameObject.Find(Strings.CLOUDMANAGER).GetComponent<CloudManager>();
     ScreenSetup.CalculateSettings();
     StartCoroutine(Init());
 }
 void Start()
 {
     parallax = ParallaxManager.instance;
     self     = transform;
     startPos = self.position;
 }
Example #13
0
 // Use this for initialization
 void Awake()
 {
     speed           = ParallaxManager.ParallaxLayerToMoveSpeed(parallaxLayer);
     initialPosition = new Vector2(transform.position.x, transform.position.y);
 }