Esempio n. 1
0
        public SkyInstance(Sky sky)
        {
            m_sky = sky;

            m_litEffect = new LitEffectInstance(sky.RenderPass);
            m_litEffect.AmbientLight = new AmbientLight(Vector3.Zero);
            m_litEffect.Light        = new DirectionalLight(Vector3.UnitY, Vector3.Zero);
            m_litEffect.Light2       = new DirectionalLight(Vector3.UnitY, Vector3.Zero);

            if (m_sky.AnimPath != null)
            {
                m_animation = LuaAnimation.Get(m_sky.AnimPath);
                m_animTime  = 0.0f;
            }
            if (m_sky.ModelPath != null)
            {
                var model = Model.Get(m_sky.ModelPath);
                m_model           = new ModelInstance(model, Matrix4.Identity);
                m_model.Animation = m_animation;
                m_model.AnimTime  = m_animTime;
                m_model.Animate();
            }
            if (m_sky.ForegroundModelPath != null)
            {
                var model = Model.Get(m_sky.ForegroundModelPath);
                m_foregroundModel           = new ModelInstance(model, Matrix4.Identity);
                m_foregroundModel.Animation = m_animation;
                m_foregroundModel.AnimTime  = m_animTime;
                m_foregroundModel.Animate();
            }
            AnimateLights();
        }
Esempio n. 2
0
        protected override void OnInit()
        {
            var direction = Tile.GetDirection(Level, Location);
            var behaviour = (TelepadTileBehaviour)Tile.Behaviour;
            var model     = behaviour.GetModel(Level, Location);
            var transform = Tile.BuildTransform(Location, direction);

            if (model != null)
            {
                m_model = new ModelInstance(model, transform);
            }
            Level.Telepads.AddTelepad(behaviour.Colour, Location);
            if (behaviour.Animation != null)
            {
                if (m_model != null)
                {
                    m_model.Animation = LuaAnimation.Get(behaviour.Animation);
                    m_model.AnimTime  = Level.TimeMachine.RealTime;
                }
            }
            if (behaviour.PFX != null)
            {
                if (m_model != null)
                {
                    m_emitter           = Level.Particles.Create(ParticleStyle.Get(behaviour.PFX), false, true);
                    m_emitter.Transform = transform;
                }
            }
        }
Esempio n. 3
0
        private void ContinueGame()
        {
            // Animate the robot
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/startscreen/robot_move.anim.lua"), false);
            m_robot.PlaySoundAfterDelay("sound/new_robot/idle_loop.wav", true, 0.3f);

            var delay = 1.25f;

            if (App.Demo)
            {
                // Start the main campaign
                var campaign       = Campaign.Get("campaigns/demo.campaign");
                var playthrough    = new Playthrough(Campaign.Get("campaigns/demo.campaign"), 0);
                var firstLevel     = campaign.Levels[0];
                var firstLevelData = LevelData.Get(firstLevel);
                if (firstLevelData.Intro != null)
                {
                    WipeToState(new CutsceneState(Game, null, firstLevelData.Intro, CutsceneContext.LevelIntro, playthrough), delay);
                }
                else
                {
                    WipeToState(new CampaignState(Game, null, playthrough));
                }
            }
            else
            {
                // Open the campaign select
                WipeToState(new CampaignSelectState(Game), delay);
            }
        }
Esempio n. 4
0
        private void Quit()
        {
            // Animate the robot
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/startscreen/robot_die.anim.lua"), false);

            // Quit
            BlackoutToState(new ShutdownState(Game), 1.0f);
        }
Esempio n. 5
0
        protected override void GoBack()
        {
            // Animate
            StartCameraAnimation("animation/menus/options/camera_fromscreen.anim.lua");
            Robot.StartAnimation(LuaAnimation.Get("animation/menus/options/robot_fromscreen.anim.lua"), false);

            // Show options
            CutToState(new MainMenuState(Game), 1.25f);
        }
Esempio n. 6
0
        private void Options()
        {
            // Animate the camera
            StartCameraAnimation("animation/menus/startscreen/camera_toscreen.anim.lua");
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/startscreen/robot_toscreen.anim.lua"), false);

            // Show options
            CutToState(new MainOptionsState(Game), 1.25f);
        }
Esempio n. 7
0
        private void Arcade()
        {
            // Animate the camera
            StartCameraAnimation("animation/menus/startscreen/camera_toscreen.anim.lua");
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/startscreen/robot_toscreen.anim.lua"), false);
            Game.Audio.PlaySound("sound/arcade_boot.wav", false);

            // Show options
            CutToState(new ArcadeState(Game), 1.25f);
        }
Esempio n. 8
0
 protected override void OnInit()
 {
     m_model = new ModelInstance(
         Model.Get("models/entities/spawn_marker.obj"),
         BuildTransform()
         );
     m_model.Animation = LuaAnimation.Get(
         "animation/entities/spawn_marker/preview.anim.lua"
         );
     m_model.AnimTime = 0.0f;
 }
Esempio n. 9
0
        protected void GoBack()
        {
            // Animate
            StartCameraAnimation("animation/menus/options/camera_fromscreen.anim.lua");
            Game.Audio.PlaySound("sound/arcade_shutdown.wav", false);
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/options/robot_fromscreen.anim.lua"), false);
            m_robot.ScreenTexture = null;

            // Show options
            CutToState(new MainMenuState(Game), 1.25f);
        }
Esempio n. 10
0
        protected override void OnReveal()
        {
            base.OnReveal();

            // Create robot
            m_robot = CreateEntity("models/entities/new/red_robot.obj");

            // Start animation
            StartCameraAnimation("animation/menus/startscreen/camera_initial.anim.lua");
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/startscreen/robot.anim.lua"), false);

            // Reposition sky
            Game.Sky.ForegroundModelTransform = Matrix4.CreateTranslation(-5.0f, 5.0f, -20.0f);
        }
Esempio n. 11
0
        public LuaArgs playCameraAnimation(LuaArgs args)
        {
            var path = args.GetString(0);

            if (LuaAnimation.Exists(path))
            {
                var anim = LuaAnimation.Get(path);
                m_state.StartCameraAnimation(anim);
                return(LuaArgs.Empty);
            }
            else
            {
                throw new LuaError(string.Format("No such animation: {0}", path));
            }
        }
Esempio n. 12
0
            public LuaArgs playAnimation(LuaArgs args)
            {
                var path        = args.GetString(0);
                var animateRoot = args.IsNil(1) ? true : args.GetBool(1);

                if (LuaAnimation.Exists(path))
                {
                    var anim = LuaAnimation.Get(path);
                    m_entity.StartAnimation(anim, animateRoot);
                    return(LuaArgs.Empty);
                }
                else
                {
                    throw new LuaError(string.Format("No such animation: {0}", path));
                }
            }
Esempio n. 13
0
        protected override void OnInit()
        {
            var direction = Tile.GetDirection(Level, Location);
            var model     = Tile.Behaviour.GetModel(Level, Location);

            if (model != null)
            {
                var behaviour = (ConveyorTileBehaviour)Tile.Behaviour;
                m_model = new ModelInstance(model, Tile.BuildTransform(Location, direction));
                if (behaviour.Animation != null)
                {
                    m_model.Animation = LuaAnimation.Get(behaviour.Animation);
                    m_model.AnimTime  = 0.0f;
                }
            }
            PushState(new ConveyorState(ConveyorMode.Stopped, 0.0f, CurrentTime));
        }
Esempio n. 14
0
        protected override void OnReveal()
        {
            base.OnReveal();

            // Create robot
            m_robot = new ArcadeRobot(
                Model.Get("models/entities/new/red_robot.obj")
                );
            Level.Entities.Add(m_robot);

            // Start animation
            StartCameraAnimation("animation/menus/options/camera.anim.lua");
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/options/robot_arcade.anim.lua"), false);
            m_robot.ScreenTexture = m_displayTexture;

            // Reposition sky
            Game.Sky.ForegroundModelTransform = Matrix4.CreateTranslation(-5.0f, 5.0f, -20.0f);
        }
Esempio n. 15
0
        protected override void OnInit()
        {
            var direction = Tile.GetDirection(Level, Location);
            var behaviour = (TurntableTileBehaviour)Tile.GetBehaviour(Level, Location);

            PushState(new TurntableState(TurntableMode.Wait, direction, CurrentTime));

            var model = behaviour.GetModel(Level, Location);

            if (model != null)
            {
                m_model = new ModelInstance(model, Tile.BuildTransform(Location, direction));
                if (behaviour.Animation != null)
                {
                    m_model.Animation = LuaAnimation.Get(behaviour.Animation);
                    m_model.AnimTime  = 0.0f;
                }
            }
            UpdateModel();
        }
Esempio n. 16
0
        private void EditMod(Mod mod)
        {
            // Animate the robot
            m_robot.StartAnimation(LuaAnimation.Get("animation/menus/startscreen/robot_move_alt.anim.lua"), false);
            m_robot.PlaySoundAfterDelay("sound/new_robot/beam_up.wav", false, 0.3f);

            // Open the mod editor
            Func <State> fnNextState = delegate()
            {
                return(new ModEditorState(Game, mod));
            };

            if (!mod.Loaded)
            {
                Assets.AddSource(mod.Assets);
                mod.Loaded = true;
                LoadToState(fnNextState, 1.75f);
            }
            else
            {
                WipeToState(fnNextState.Invoke(), 1.75f);
            }
        }
Esempio n. 17
0
        protected override void OnInit()
        {
            var behaviour = (AnimatedTileBehaviour)Tile.Behaviour;
            var direction = behaviour.GetModelDirection(Level, Location);
            var transform = Tile.BuildTransform(Location, direction);

            m_powered = !Level.InEditor && Tile.IsPowered(Level, Location);

            var model = behaviour.GetModel(Level, Location);

            if (model != null)
            {
                m_model = new ModelInstance(model, transform);
                if (behaviour.Animation != null)
                {
                    m_model.Animation = LuaAnimation.Get(behaviour.Animation);
                    m_model.AnimTime  = Level.TimeMachine.RealTime;
                }
            }
            var poweredModel = behaviour.GetPoweredModel(Level, Location);

            if (poweredModel != null && poweredModel != model)
            {
                m_poweredModel = new ModelInstance(poweredModel, transform);
                if (behaviour.PoweredAnimation != null)
                {
                    m_poweredModel.Animation = LuaAnimation.Get(behaviour.PoweredAnimation);
                    m_poweredModel.AnimTime  = Level.TimeMachine.RealTime;
                }
            }
            if (behaviour.PFX != null)
            {
                m_emitter           = Level.Particles.Create(ParticleStyle.Get(m_powered ? behaviour.PoweredPFX : behaviour.PFX), false, true);
                m_emitter.Transform = transform;
            }
        }
Esempio n. 18
0
        public void ReloadAssets()
        {
            // Refresh models
            if (m_sky.ModelPath != null)
            {
                var model = Model.Get(m_sky.ModelPath);
                m_model = new ModelInstance(model, Matrix4.Identity);
            }
            else
            {
                m_model = null;
            }

            if (m_sky.ForegroundModelPath != null)
            {
                var model        = Model.Get(m_sky.ForegroundModelPath);
                var oldTransform = (m_foregroundModel != null) ? m_foregroundModel.Transform : Matrix4.Identity;
                m_foregroundModel = new ModelInstance(model, oldTransform);
            }
            else
            {
                m_foregroundModel = null;
            }

            // Refresh animation
            if (m_sky.AnimPath != null)
            {
                m_animation = LuaAnimation.Get(m_sky.AnimPath);
            }
            else
            {
                m_animation = null;
            }

            Animate();
        }
Esempio n. 19
0
 protected void FuzzToState(State state)
 {
     m_robot.StartAnimation(LuaAnimation.Get("animation/menus/options/robot_fuzz.anim.lua"), false);
     CutToState(state, 0.5f);
 }
Esempio n. 20
0
 protected void StartCameraAnimation(string animPath)
 {
     m_animatedCamera.Play(LuaAnimation.Get(animPath));
 }
Esempio n. 21
0
 public override IAnimation GetAnimation(RobotState state)
 {
     return(LuaAnimation.Get("animation/invisible.anim.lua"));
 }
Esempio n. 22
0
        public void Draw(ModelEffectInstance modelEffect, RenderPass pass)
        {
            // Draw the geometry for the current pass
            var geometry = m_geometry[(int)pass];

            if (geometry.IndexCount > 0)
            {
                modelEffect.ModelMatrix     = Matrix4.Identity;
                modelEffect.UVOffset        = Vector2.Zero;
                modelEffect.UVScale         = Vector2.One;
                modelEffect.DiffuseColour   = Vector4.One;
                modelEffect.DiffuseTexture  = m_atlas;
                modelEffect.SpecularColour  = Vector3.One;
                modelEffect.SpecularTexture = m_atlas;
                modelEffect.NormalTexture   = m_atlas;
                modelEffect.EmissiveColour  = Vector3.One;
                modelEffect.EmissiveTexture = m_atlas;
                modelEffect.Bind();
                geometry.Draw();

                /*
                 * // Wireframe test code
                 * modelEffect.ModelMatrix = Matrix4.Identity;
                 * modelEffect.DiffuseColour = Vector4.One;
                 * modelEffect.DiffuseTexture = Texture.White;
                 * modelEffect.SpecularColour = Vector3.One;
                 * modelEffect.SpecularTexture = Texture.White;
                 * modelEffect.NormalTexture = Texture.Flat;
                 * modelEffect.Bind();
                 * using( var wireframe = geometry.ToWireframe( lines:false, normals:true, tangents:true, binormals:true ) )
                 * {
                 *  wireframe.Draw();
                 * }
                 */
            }

            foreach (var pair in m_liquidGeometry)
            {
                var behaviour      = pair.Key;
                var liquidGeometry = pair.Value;
                if (liquidGeometry.IndexCount > 0 && behaviour.Tile.RenderPass == pass)
                {
                    bool    visible;
                    Matrix4 modelMatrix;
                    Vector2 uvOffset, uvScale;
                    Vector4 colour;
                    if (behaviour.Animation != null)
                    {
                        float cameraFOV;
                        var   anim = LuaAnimation.Get(behaviour.Animation);
                        anim.Animate("Liquid", m_level.TimeMachine.RealTime, out visible, out modelMatrix, out uvOffset, out uvScale, out colour, out cameraFOV);
                    }
                    else
                    {
                        visible     = true;
                        modelMatrix = Matrix4.Identity;
                        uvOffset    = Vector2.Zero;
                        uvScale     = Vector2.One;
                        colour      = Vector4.One;
                    }
                    if (visible)
                    {
                        var surface = Texture.Get(behaviour.Texture, false);
                        surface.Wrap = true;

                        modelEffect.ModelMatrix     = modelMatrix;
                        modelEffect.UVOffset        = uvOffset;
                        modelEffect.UVScale         = uvScale;
                        modelEffect.DiffuseColour   = colour;
                        modelEffect.DiffuseTexture  = surface;
                        modelEffect.SpecularColour  = Vector3.One;
                        modelEffect.SpecularTexture = Texture.Black;
                        modelEffect.NormalTexture   = Texture.Flat;
                        modelEffect.EmissiveColour  = Vector3.One;
                        modelEffect.EmissiveTexture = Texture.Black;
                        modelEffect.Bind();
                        liquidGeometry.Draw();
                    }
                }
            }
        }