Exemplo n.º 1
0
        protected virtual void OnEnable()
        {
            cachedObject = GetComponent <SgtFloatingObject>();

            cachedObject.OnSpawn    += Generate;
            cachedObject.OnDistance += SetDistance;
        }
Exemplo n.º 2
0
        public void SetDistance(double distance)
        {
            if (cachedObjectSet == false)
            {
                cachedObject    = GetComponent <SgtFloatingObject>();
                cachedObjectSet = true;
            }

            // Assume these exist to speed things up
            //if (Steps != null)
            {
                for (var i = Steps.Count - 1; i >= 0; i--)
                {
                    var step = Steps[i];

                    if (distance >= step.DistanceMin && distance < step.DistanceMax)
                    {
                        if (step.Scale != cachedObject.Scale)
                        {
                            ApplyScale(step.Scale);
                        }

                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void ApplyScale(long newScale)
        {
            var floatingCamera = default(SgtFloatingCamera);

            if (SgtFloatingCamera.TryGetCamera(newScale, ref floatingCamera) == true)
            {
                ApplyLayer(transform, floatingCamera.gameObject.layer);

                if (cachedObjectSet == false)
                {
                    cachedObject    = GetComponent <SgtFloatingObject>();
                    cachedObjectSet = true;
                }

                cachedObject.UpdatePosition(floatingCamera);

                cachedObject.Scale = newScale;

                //cachedObject.UpdateScale();
            }

            if (cachedObjectSet == false)
            {
                cachedObject    = GetComponent <SgtFloatingObject>();
                cachedObjectSet = true;
            }
        }
Exemplo n.º 4
0
        protected override void OnEnable()
        {
            base.OnEnable();

            Camera.onPreCull += PreCull;
            SgtFloatingCamera.OnPositionChanged += FloatingCameraPositionChanged;

            cachedObject = GetComponent <SgtFloatingObject>();
        }
Exemplo n.º 5
0
        protected virtual void OnEnable()
        {
            if (UseFloatingObject == true)
            {
                cachedFloatingObject = GetComponent <SgtFloatingObject>();

                cachedFloatingObject.OnSpawn += SpawnSeed;
            }
        }
Exemplo n.º 6
0
        protected virtual void OnDisable()
        {
            cachedObject.OnDistance -= UpdateDistance;

            if (instance != null)
            {
                SgtHelper.Destroy(instance.gameObject);

                instance = null;
            }
        }
Exemplo n.º 7
0
        protected virtual void OnEnable()
        {
            if (UseFloatingObject == true)
            {
                cachedFloatingObject = GetComponent <SgtFloatingObject>();

                cachedFloatingObject.OnSpawn += SpawnSeed;
            }
            else
            {
                Generate();
            }

            cachedTransform = GetComponent <Transform>();
        }
Exemplo n.º 8
0
        private void UpdateDistance(double distance)
        {
#if UNITY_EDITOR
            if (Application.isPlaying == false && EnableInEditor == false)
            {
                return;
            }
#endif
            if (distance >= DistanceMin && distance < DistanceMax)
            {
                if (instance == null)
                {
                    // Store old values and override
                    var oldPoint = Prefab.Point;

                    Prefab.Point = cachedObject.Point;

                    // Spawn
                    instance = Instantiate(Prefab, SgtFloatingRoot.Root);

                    // Revert values
                    Prefab.Point = oldPoint;

                    instance.UpdatePosition();

                    // Invoke spawn
                    if (instance.OnSpawn != null)
                    {
                        instance.OnSpawn.Invoke(cachedObject.Seed);
                    }
                }

                if (instance.OnDistance != null)
                {
                    instance.OnDistance.Invoke(distance);
                }
            }
            else
            {
                if (instance != null)
                {
                    SgtHelper.Destroy(instance.gameObject);

                    instance = null;
                }
            }
        }
Exemplo n.º 9
0
        protected virtual void OnEnable()
        {
            cachedFloatingObject = GetComponent <SgtFloatingObject>();

            cachedFloatingObject.OnDistance += HandleDistance;
        }