Пример #1
0
        private void DoAct()
        {
            MotionDelegator motionDelegator = Mgr <CatProject> .Singleton.MotionDelegator;
            MovieClip       movieClip       = motionDelegator.AddMovieClip();
            // logo
            ModelComponent logoModel =
                ModelComponent.GetModelOfGameObjectInCurrentScene(m_logoObjectName);

            if (logoModel != null)
            {
                movieClip.AppendMotion(
                    logoModel.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(1.0f),
                    2000);
                movieClip.AppendEmptyTime(2000);
                movieClip.AppendMotion(
                    logoModel.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(0.0f),
                    2000);
            }
            // intro
            ModelComponent introModel =
                ModelComponent.GetModelOfGameObjectInCurrentScene(m_introObjectName);

            if (introModel != null)
            {
                movieClip.AppendMovieClip(new PlayMusic(m_musicName));
                movieClip.AppendMotion(
                    introModel.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(1.0f),
                    2000);
                movieClip.AppendEmptyTime(3000);
            }

            // storm
            int             timestamp = movieClip.GetEditCurClip();
            ParticleEmitter emitter   =
                ParticleEmitter.GetParticleEmitterOfGameObjectInCurrentScene(m_emitterObjectName);

            if (emitter != null)
            {
                movieClip.AppendMovieClip(new StormOn(emitter));
                movieClip.AppendMotion(emitter.GenerateRatePerSecondRef,
                                       new CatInteger(512), 5000);
            }

            // Screen bright
            PostProcessColorAdjustment colorAdjustment =
                Mgr <Scene> .Singleton.PostProcessManager.GetPostProcess(typeof(PostProcessColorAdjustment).ToString())
                as PostProcessColorAdjustment;

            if (colorAdjustment != null)
            {
                movieClip.AddMotion(colorAdjustment.IllumiateRef, new CatFloat(1.0f), timestamp, 5000);
            }
            movieClip.AppendMovieClip(new SwitchScene(m_nextSceneName));
            movieClip.Initialize();
        }
Пример #2
0
        private void DoAct()
        {
            ModelComponent model = ModelComponent.GetModelOfGameObjectInCurrentScene(m_introGameObjectName);

            if (model != null)
            {
                MotionDelegator motionDelegator = Mgr <CatProject> .Singleton.MotionDelegator;
                MovieClip       movieClip       = motionDelegator.AddMovieClip();

                movieClip.AppendMotion(
                    model.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(1.0f),
                    2000);
                movieClip.AppendEmptyTime(2000);
                movieClip.AppendMotion(
                    model.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(0.0f),
                    2000);

                movieClip.Initialize();
            }
        }
Пример #3
0
        public override void Update(int timeLastFrame)
        {
            base.Update(timeLastFrame);

            m_currentTime += (float)timeLastFrame / m_dayDurationInMS;
            m_currentTime -= (int)m_currentTime;

            if (m_ambientLightMapName != "")
            {
                if (Mgr <Scene> .Singleton != null && Mgr <Scene> .Singleton.m_shadowSystem != null)
                {
                    Mgr <Scene> .Singleton.m_shadowSystem.Time = m_currentTime;
                }
            }

            ModelComponent modelComponent = m_gameObject.GetComponent(typeof(ModelComponent)) as ModelComponent;

            if (modelComponent != null && modelComponent.GetCatModelInstance() != null)
            {
                if (modelComponent.GetCatModelInstance().GetMaterial() != null &&
                    modelComponent.GetCatModelInstance().GetMaterial().HasParameter("Time"))
                {
                    modelComponent.GetCatModelInstance().GetMaterial().SetParameter("Time", new CatFloat(m_currentTime));
                }
            }

            if (m_diffuseLights != null && m_diffuseLightArray != null)
            {
                Color diffuseColor = m_diffuseLightArray[(int)(m_diffuseLightArray.Length * m_currentTime) % m_diffuseLightArray.Length];
                foreach (Light light in m_diffuseLights)
                {
                    if (light != null)
                    {
                        light.DiffuseColor = diffuseColor;
                    }
                }
            }
        }
Пример #4
0
        protected override void PostCreatGameObject(GameObject _gameObject, int _index)
        {
            _gameObject.Position += m_randomScale *
                                    new Vector3((float)m_random.NextDouble(),
                                                (float)m_random.NextDouble(),
                                                (float)m_random.NextDouble());
            // random color
            CatColor color = new CatColor();

            color.SetFromHSV(new Vector4((float)m_random.NextDouble(), 0.9f, 0.8f, 0.0f));
            ModelComponent model = _gameObject.GetComponent(typeof(ModelComponent).ToString())
                                   as ModelComponent;

            if (model != null)
            {
                model.GetCatModelInstance().GetMaterial().SetParameter("BiasColor", color);
            }
        }
Пример #5
0
        public void Draw(int timeLastFrame)
        {
            if (!Enable)
            {
                return;
            }

            ModelComponent modelComponent = m_gameObject.GetComponent(
                typeof(ModelComponent).ToString()) as ModelComponent;
            GraphicsDevice gd = Mgr <GraphicsDevice> .Singleton;

            gd.SetVertexBuffer(m_vertexBuffer);
            Effect  effect        = null;
            Vector3 finalPosition = new Vector3(m_position.X - m_offset.X,
                                                m_position.Y - m_offset.Y,
                                                m_depth);

            if (modelComponent != null && modelComponent.Model != null)
            {
                CatMaterial material = modelComponent.GetCatModelInstance().GetMaterial();
                material.SetParameter("World", new CatMatrix(Matrix.CreateTranslation(
                                                                 finalPosition)));
                material.SetParameter("View", new CatMatrix(Matrix.Identity));
                material.SetParameter("Projection", new CatMatrix(Matrix.Identity));
                effect = material.ApplyMaterial();
            }
            else
            {
                effect = Mgr <DebugTools> .Singleton.DrawEffect;
                ((BasicEffect)effect).Alpha              = 1.0f;
                ((BasicEffect)effect).DiffuseColor       = new Vector3(1.0f, 0.0f, 1.0f);
                ((BasicEffect)effect).View               = Matrix.Identity;
                ((BasicEffect)effect).Projection         = Matrix.Identity;
                ((BasicEffect)effect).VertexColorEnabled = false;
                ((BasicEffect)effect).World              = Matrix.CreateTranslation(finalPosition);
            }
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                gd.DrawUserPrimitives <VertexPositionTexture>(
                    PrimitiveType.TriangleStrip, m_vertex, 0, 2);
            }
        }
Пример #6
0
        protected override void Exit(Fixture _fixtureA, Fixture _fixtureB)
        {
            if (_fixtureA.UserData == null && _fixtureB.UserData == null)
            {
                return;
            }
            ModelComponent modelComponent =
                m_gameObject.GetComponent(typeof(ModelComponent).ToString())
                as ModelComponent;

            if (modelComponent != null)
            {
                MotionDelegator motionDelegator = Mgr <CatProject> .Singleton.MotionDelegator;
                MovieClip       movieClip       = motionDelegator.AddMovieClip();
                movieClip.AppendMotion(
                    modelComponent.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(0.0f), 10000);
                movieClip.Initialize();
            }
        }
Пример #7
0
        public void OnSuccess()
        {
            m_isInQTE = false;
            m_sucess  = true;
            // go normal
            MotionDelegator motionDelegator = Mgr <CatProject> .Singleton.MotionDelegator;
            MovieClip       movieClip       = motionDelegator.AddMovieClip();

            movieClip.AppendMotion(Mgr <GameEngine> .Singleton.TimeScaleRef, new CatFloat(1.0f), 500);
            PostProcessMotionBlur motionBlur =
                Mgr <Scene> .Singleton.PostProcessManager.GetPostProcess(typeof(PostProcessMotionBlur).ToString())
                as PostProcessMotionBlur;

            int time = movieClip.GetStartTick();

            if (motionBlur != null)
            {
                movieClip.AddMotion(motionBlur.BlurIntensityRef, new CatFloat(0.2f), time,
                                    500);
            }
            PostProcessVignette vignette =
                Mgr <Scene> .Singleton.PostProcessManager.GetPostProcess(typeof(PostProcessVignette).ToString())
                as PostProcessVignette;

            if (vignette != null)
            {
                movieClip.AddMotion(vignette.RadiusRef, new CatVector2(0.0f, 1.4f), time, 500);
            }
            movieClip.Initialize();
            // change color
            Random   random = new Random();
            CatColor color  = new CatColor();

            color.SetFromHSV(new Vector4((float)random.NextDouble(), 0.9f, 0.8f, 0.0f));
            ModelComponent parentModel = m_gameObject.GetComponent(typeof(ModelComponent).ToString())
                                         as ModelComponent;

            if (parentModel != null)
            {
                parentModel.GetCatModelInstance().GetMaterial().SetParameter("BiasColor", color);
            }
            // long tail
            if (m_gameObject.Children != null && m_gameObject.Children.Count > 0)
            {
                GameObject      emit    = m_gameObject.Children[0];
                ParticleEmitter emitter = emit.GetComponent(
                    typeof(ParticleEmitter).ToString()) as ParticleEmitter;
                emitter.ParticleLifetimeInMS = 400;

                ModelComponent childModel = emit.GetComponent(typeof(ModelComponent).ToString())
                                            as ModelComponent;
                if (childModel != null)
                {
                    childModel.GetCatModelInstance().GetMaterial().SetParameter("BiasColor", color);
                }
            }
            // add score
            GameObject scoreboardGameObject = Mgr <Scene> .Singleton._gameObjectList.
                                              GetOneGameObjectByName(m_scoreboardGameObjectName);

            if (scoreboardGameObject != null)
            {
                HorseScoreboard scoreboard =
                    scoreboardGameObject.GetComponent(typeof(HorseScoreboard).ToString())
                    as HorseScoreboard;
                if (scoreboard != null)
                {
                    scoreboard.AddScore();
                }
            }
        }
Пример #8
0
        protected override bool Enter(Fixture _fixtureA, Fixture _fixtureB, Contact _contact)
        {
            if (_fixtureA.UserData == null && _fixtureB.UserData == null)
            {
                return(true);
            }

            // stop walking and disable camera follower
            GameObject player = Mgr <Scene> .Singleton._gameObjectList.
                                GetOneGameObjectByName(m_playerName);

            if (player != null)
            {
                HorseController controller = player.GetComponent(
                    typeof(HorseController).ToString()) as HorseController;
                if (controller != null)
                {
                    controller.MotorSpeed = 0.0f;
                }
                CameraFollower cameraFollower = player.GetComponent(
                    typeof(CameraFollower).ToString()) as CameraFollower;
                if (cameraFollower != null)
                {
                    cameraFollower.Enable = false;
                }
            }

            // light candle
            List <string> candles = Mgr <Scene> .Singleton.
                                    _gameObjectList.GetGameObjectsGuidByName(m_candleName);

            foreach (string guid in candles)
            {
                GameObject candle = Mgr <Scene> .Singleton._gameObjectList.GetItem(guid);

                GameObject      fire            = candle.Children[0];
                ParticleEmitter particleEmitter = fire.GetComponent(
                    typeof(ParticleEmitter).ToString()) as ParticleEmitter;
                if (particleEmitter != null)
                {
                    particleEmitter.IsEmitting = true;
                }
            }

            int lightDurationInMS = 200;
            // screen light
            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(1.0f), lightDurationInMS);
            // show cake
            GameObject cake = Mgr <Scene> .Singleton._gameObjectList.
                              GetOneGameObjectByName(m_cakeName);

            if (cake != null)
            {
                ModelComponent modelComponent =
                    cake.GetComponent(typeof(ModelComponent).ToString())
                    as ModelComponent;
                movieClip.AddMotion(
                    modelComponent.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(1.0f),
                    movieClip.GetStartTick(),
                    lightDurationInMS);
            }
            // screen dark
            movieClip.AppendMotion(colorAdjustment.IllumiateRef, new CatFloat(0.0f), lightDurationInMS);

            // camera up
            int    cameraUpTime = movieClip.GetEditCurClip();
            Camera camera       = Mgr <Camera> .Singleton;

            camera.ForceUpdateMatrixByCameraUpdate = true;
            camera.TargetObject = null;
            if (m_finalCameraPositionObjectName != "")
            {
                GameObject finalPosition =
                    Mgr <Scene> .Singleton._gameObjectList.GetOneGameObjectByName(
                        m_finalCameraPositionObjectName);

                if (finalPosition != null)
                {
                    movieClip.AppendEmptyTime(3000);
                    cameraUpTime = movieClip.GetEditCurClip();
                    movieClip.AppendMotion(camera.TargetPositionRef,
                                           new CatVector3(finalPosition.AbsPosition), 8000,
                                           AnimationClip.PlayMode.CLAMP,
                                           0.0f,
                                           MotionDelegatorPack.AccelerationMode.AccelerateNDecelerate);
                }
            }

            // show wish
            int            wishTime  = cameraUpTime + 5000;
            ModelComponent wishModel =
                ModelComponent.GetModelOfGameObjectInCurrentScene(m_wishObjectName);

            if (wishModel != null)
            {
                movieClip.AddMotion(
                    wishModel.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(1.0f), wishTime, 2000);
            }
            int            hbTime  = wishTime + 3000;
            ModelComponent hbModel =
                ModelComponent.GetModelOfGameObjectInCurrentScene(m_hbObjectName);

            if (hbModel != null)
            {
                movieClip.AddMotion(
                    hbModel.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(1.0f), hbTime, 2000);
            }
            int            escTime  = hbTime + 3000;
            ModelComponent escModel =
                ModelComponent.GetModelOfGameObjectInCurrentScene(m_quitObjectName);

            if (escModel != null)
            {
                movieClip.AddMotion(
                    escModel.GetCatModelInstance().GetMaterial().GetParameter("Alpha"),
                    new CatFloat(1.0f), escTime, 2000);
            }

            // speed up firework
            if (m_fireworkControllerName != "")
            {
                GameObject firework =
                    Mgr <Scene> .Singleton._gameObjectList.GetOneGameObjectByName(
                        m_fireworkControllerName);

                if (firework != null)
                {
                    FireworkController fc =
                        firework.GetComponent(typeof(FireworkController).ToString())
                        as FireworkController;
                    if (fc != null)
                    {
                        fc.IntervalInMS = 100;
                    }
                }
            }

            movieClip.Initialize();
            return(true);
        }