private void Update() { float num = base.transform.position.x - this.m_oldPosition.x; float num2 = base.transform.position.y - this.m_oldPosition.y; this.m_offset.x = this.m_offset.x + num; if (num != 0f) { this.SetHorizontalPosition(this.m_backgroundLayerForeground, -0.4f); this.SetHorizontalPosition(this.m_backgroundLayerFurther, 0.7f); this.SetHorizontalPosition(this.m_backgroundLayerFar, 0.6f); this.SetHorizontalPosition(this.m_backgroundLayerNear, 0.4f); this.SetHorizontalPosition(this.m_backgroundLayerSky, 0.8f); this.SetHorizontalPosition(this.m_backgroundLayerFixedFollowCamera, 1f); for (int i = 0; i < this.m_miscellanousLayer.Count; i++) { ParallaxCustomLayer parallaxCustomLayer = this.m_miscellanousLayer[i]; Vector3 position = parallaxCustomLayer.layer.transform.position; position.x = parallaxCustomLayer.layer.GetComponent <BaseTransform>().position.x + this.m_offset.x * parallaxCustomLayer.speedX; parallaxCustomLayer.layer.transform.position = position; } } if (num2 != 0f) { for (int j = 0; j < this.m_backgroundLayerForeground.Length; j++) { GameObject gameObject = this.m_backgroundLayerForeground[j]; Vector3 vector = gameObject.transform.position; if (vector.y <= this.m_fgLimitY) { vector -= Vector3.up * num2 * 0.2f; } else { vector.y = this.m_fgLimitY; } gameObject.transform.position = vector; } } this.m_oldPosition = base.transform.position; }
public void RegisterParallaxLayer(ParallaxCustomLayer pcl) { this.m_miscellanousLayer.Add(pcl); pcl.layer.AddComponent <BaseTransform>(); }