Example #1
0
        public void OnPlayDynamicLight(MoveAnimationEvent e)
        {
            //DynamicLightEventInfo evt = new DynamicLightEventInfo(e);
            DynamicLightEventInfo       evt        = e.EventRef as DynamicLightEventInfo;
            DynamicLightEventProperties properties = evt._dynamicLightProperties;

            PlayDynamicLight(properties);
        }
Example #2
0
        public void PlayDynamicLight(DynamicLightEventProperties properties)
        {
            // TJ: don't play this light if one with the same event name is already playing
            if (properties._eventName.Length > 0 && _activeDynamicLights.Count(pi => pi._name == properties._eventName) > 0)
            {
                return;
            }

            GameObject light = MoveUtils.InstantiateDynamicLight(properties, GetComponent <Animator>(), false);

            if (light != null)
            {
                RegisterLight(light, properties._eventName, properties._interruptable, properties._stopOnExit);
                light.GetComponent <DynamicPointLightInstance>().Play();
            }
        }
Example #3
0
        public void Init(DynamicLightEventProperties properties, Animator animator, float startTime, float stopTime)
        {
            //_properties   = properties;
            _startTime    = startTime;
            _stopTime     = stopTime;
            _dynamicLight = MoveUtils.InstantiateDynamicLight(properties, animator, false, true).GetComponent <DynamicPointLightInstance>();
            _played       = false;
            _stopped      = false;

            if (!Application.isPlaying)
            {
                _dynamicLight.EnableSimMode(true);
            }

            _dynamicLight.Stop();
        }
Example #4
0
        private static GameObject LoadLightWithPool(DynamicLightEventProperties properties)
        {
            GameObject light = null;

            if (GenericPoolSingleton.Instance.lightPool != null)
            {
                string name = string.Empty;
                if (properties._dynamicLight != null)
                {
                    name = properties._dynamicLight.name;
                }
                else
                {
                    name = properties.DynamicLightName;
                }
                light = GenericPoolSingleton.Instance.lightPool.Use(name);
            }
            return(light);
        }
Example #5
0
        public static GameObject InstantiateDynamicLight(DynamicLightEventProperties properties, Animator animator, bool flipped, bool bypassPools = false)
        {
            GameObject light = null;

            if (Application.isPlaying)
            {
                if (!bypassPools)
                {
                    light = LoadLightWithPool(properties);
                }
                else
                {
                    light = LoadLightWithoutPool(properties);
                }
            }
            else
            {
                light = LoadLightWithoutPool(properties);
            }


            if (light != null)
            {
                //DynamicPointLightInstance lightInstance = light.GetComponent<DynamicPointLightInstance>();

                if (animator != null)
                {
                    light.transform.parent        = GetBodyPartTransform(animator, properties._attachment, properties._attachmentPath);
                    light.transform.localPosition = properties._offset;
                }

                if (properties._parent)
                {
                    AttachTransform.Attach(light, light.transform.parent, flipped, false);
                }
            }

            return(light);
        }
Example #6
0
        private static GameObject LoadLightWithoutPool(DynamicLightEventProperties properties)
        {
            GameObject light = (GameObject)GameObject.Instantiate(properties._dynamicLight);

            return(light);
        }