예제 #1
0
        private void UpdateValue()
        {
            Type type = refValue.GetType();

            if (type == typeof(CatVector3))
            {
                // delta
                CatVector3 _fromValue = (CatVector3)fromValue;
                CatVector3 _toValue   = (CatVector3)toValue;
                CatVector3 delta      = _toValue - _fromValue;
                // set value
                CatVector3 value   = (CatVector3)refValue;
                float      percent = (float)curTick / totalTick;
                value.SetValue(_fromValue.GetValue() + delta.GetValue() * GetCurveValue(percent));
            }
            else if (type == typeof(CatVector2))
            {
                //delta
                CatVector2 _fromValue = (CatVector2)fromValue;
                CatVector2 _toValue   = (CatVector2)toValue;
                CatVector2 delta      = _toValue - _fromValue;
                // set value
                CatVector2 value   = (CatVector2)refValue;
                float      percent = (float)curTick / totalTick;
                value.SetValue(_fromValue.GetValue() + delta.GetValue() * GetCurveValue(percent));
            }
            else if (type == typeof(CatFloat))
            {
                // delta
                float _fromValue = ((CatFloat)fromValue);
                float _toValue   = ((CatFloat)toValue);
                float delta      = _toValue - _fromValue;
                // set value
                CatFloat value = (CatFloat)refValue;
                value.SetValue(_fromValue + delta * GetCurveValue((float)curTick / totalTick));
            }
            else if (type == typeof(CatInteger))
            {
                // delta
                int _fromValue = ((CatInteger)fromValue);
                int _toValue   = ((CatInteger)toValue);
                int delta      = _toValue - _fromValue;
                // set value
                CatInteger value = (CatInteger)refValue;
                value.SetValue(_fromValue + (int)(delta * GetCurveValue((float)curTick / totalTick)));
            }
        }
예제 #2
0
        public override void Update(int timeLastFrame)
        {
            base.Update(timeLastFrame);

            GameObject emitterGameObject =
                Mgr <Scene> .Singleton._gameObjectList.
                GetOneGameObjectByName(m_emitterGameObjectName);

            if (emitterGameObject == null)
            {
                return;
            }
            ParticleEmitter emitter = emitterGameObject.GetComponent(
                typeof(ParticleEmitter).ToString()) as ParticleEmitter;

            if (emitter == null)
            {
                return;
            }

            m_accumulateMS += timeLastFrame;
            if (m_accumulateMS < m_intervalInMS)
            {
                return;
            }
            m_accumulateMS -= m_intervalInMS;
            // position
            Vector3 position = m_gameObject.AbsPosition - m_randomSize.GetValue() / 2.0f +
                               new Vector3((float)(m_random.NextDouble() * m_randomSize.X),
                                           (float)(m_random.NextDouble() * m_randomSize.Y),
                                           (float)(m_random.NextDouble() * m_randomSize.Z));

            emitter.OneShot(m_oneShotNumber, position);
            // sound
            Camera  camera           = Mgr <Camera> .Singleton;
            Vector3 distanceToCamera = camera.CameraPosition - position;

            distanceToCamera.Z = 0.0f;
            float distance2 = distanceToCamera.LengthSquared();

            if (distance2 < 2.0f * 2.0f)
            {
                if (m_fireworkSoundName != "")
                {
                    string fireworkSoundFile = "sound\\" + m_fireworkSoundName;
                    Mgr <CatProject> .Singleton.SoundManager.SetSoundLimit(fireworkSoundFile,
                                                                           m_fireworkSoundLimit);

                    Mgr <CatProject> .Singleton.SoundManager.RandomPlaySound(fireworkSoundFile,
                                                                             position + new Vector3(0.0f, 0.0f, 20.0f), 0.2f, 0.2f);
                }
            }


            // background
//             if (m_random.NextDouble() > 0.9f) {
//                 MotionDelegator motionDelegator = Mgr<CatProject>.Singleton.MotionDelegator;
//                 MovieClip movieClip = motionDelegator.AddMovieClip();
//                 PostProcessColorAdjustment colorAdjustment =
//                     Mgr<Scene>.Singleton.PostProcessManager.GetPostProcess(
//                         typeof(PostProcessColorAdjustment).ToString())
//                         as PostProcessColorAdjustment;
//                 movieClip.AppendMotion(colorAdjustment.IllumiateRef, new CatFloat(0.6f), 100);
//                 movieClip.AppendMotion(colorAdjustment.IllumiateRef, new CatFloat(0.0f), 100);
//                 movieClip.Initialize();
//             }
        }