Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            // Dispose state
            if (m_pendingState == null)
            {
                m_currentState.Shutdown();
            }
            m_currentState.PostShutdown();

            // Dispose the rest
            m_fullScreenQuad.Dispose();
            if (m_audio is IDisposable)
            {
                ((IDisposable)m_audio).Dispose();
            }
            m_screen.Dispose();
            m_window.Dispose();
            if (m_steamControllers != null)
            {
                m_steamControllers.Dispose();
            }
            if (m_pendingScreenshot != null)
            {
                m_pendingScreenshot.Dispose();
            }
            m_cameraAxisMarker.Dispose();

            // Shutdown animation
            LuaAnimation.UnloadAll();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo 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);
        }
Ejemplo n.º 10
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;
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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));
            }
        }
Ejemplo n.º 13
0
 public void PlayAnimation(LuaAnimation anim, MapEvent kill = null, LuaContext context = null)
 {
     if (anim == null)
     {
         return;
     }
     chara.doll.GetComponent <CharaAnimationTarget>().ConfigureToBattler(this);
     chara.PerformWhenDoneAnimating(
         CoUtils.RunWithCallback(chara.doll.GetComponent <AnimationPlayer>().PlayAnimationRoutine(anim, context), () => {
         if (kill != null)
         {
             battle.map.RemoveEvent(kill);
         }
     }));
 }
Ejemplo n.º 14
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));
                }
            }
Ejemplo n.º 15
0
 public void TakeDamage(int damage, LuaAnimation damageAnimation)
 {
     if (!IsDead())
     {
         unit.stats.Sub(StatTag.HP, damage);
         if (!tookDamageThisTurn)
         {
             battler.PlayAnimation(damageAnimation);
         }
         tookDamageThisTurn = true;
         if (IsDead())
         {
             Die();
         }
     }
 }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
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();
        }
Ejemplo n.º 19
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);
            }
        }
Ejemplo n.º 20
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;
            }
        }
Ejemplo n.º 21
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();
        }
Ejemplo 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();
                    }
                }
            }
        }
Ejemplo n.º 23
0
 public IEnumerator PlayAnimationRoutine(LuaAnimation anim, LuaContext context = null)
 {
     this.anim = anim;
     yield return(PlayAnimationRoutine(context));
 }
Ejemplo n.º 24
0
 public IEnumerator PlayAnimationRoutine(LuaAnimation anim, CharaAnimationTarget attacker, CharaAnimationTarget defender)
 {
     this.attacker = attacker;
     this.defender = defender;
     yield return(PlayAnimationRoutine(anim));
 }
Ejemplo n.º 25
0
 protected void StartCameraAnimation(string animPath)
 {
     m_animatedCamera.Play(LuaAnimation.Get(animPath));
 }
Ejemplo n.º 26
0
 public IEnumerator PlayAnimationRoutine(LuaAnimation animation)
 {
     yield return(GetComponent <AnimationPlayer>().PlayAnimationRoutine(animation));
 }
Ejemplo n.º 27
0
 public override IAnimation GetAnimation(RobotState state)
 {
     return(LuaAnimation.Get("animation/invisible.anim.lua"));
 }
Ejemplo n.º 28
0
 public IEnumerator PlayAnimationRoutine(LuaAnimation anim)
 {
     this.anim = anim;
     yield return(PlayAnimationRoutine());
 }
Ejemplo n.º 29
0
        protected override void OnUpdate(float dt)
        {
            // Advance state
            m_timeInStage += dt;
            switch (m_stage)
            {
            case LoadStage.LoadingNewAssets:
            {
                // Start asset load
                if (m_loadTask == null)
                {
                    m_loadTask = StartLoad();
                }

                // Load some assets
                m_loadTask.LoadSome(new TimeSpan(250 * TimeSpan.TicksPerMillisecond));
                var loadProgress = (m_loadTask.Total > 0) ? ((float)m_loadTask.Loaded / (float)m_loadTask.Total) : 1.0f;
                SetProgress(loadProgress);

                // Continue
                if (m_loadTask.Remaining == 0)
                {
                    if (m_loadTask.Total > 0)
                    {
                        App.Log("Loaded {0} assets", m_loadTask.Total);
                    }
                    NextStage();
                }
                break;
            }

            case LoadStage.UnloadingOldAssets:
            {
                // Unload some assets
                var loaded = Assets.Count;
                Assets.UnloadUnsourced();
                if (loaded > Assets.Count)
                {
                    App.Log("Unloaded {0} assets", loaded - Assets.Count);
                }
                NextStage();
                break;
            }

            case LoadStage.LoadingAtlases:
            {
                TextureAtlas.Reload("models/tiles");
                NextStage();
                break;
            }

            case LoadStage.LoadingAnims:
            {
                LuaAnimation.ReloadAll();
                NextStage();
                break;
            }

            case LoadStage.Finalising:
            {
                Game.SelectLanguage();
                GC.Collect();
                NextStage();
                break;
            }

            case LoadStage.Animating:
            {
                // Loading is done. Make the robot blink
                m_widget.Texture = Texture.Get("gui/load_complete.png", true);
                if (m_timeInStage < 0.4f || m_timeInStage >= 0.55f)
                {
                    m_widget.Area = new Quad(0.0f, 0.0f, 0.5f, 1.0f);
                }
                else
                {
                    m_widget.Area = new Quad(0.5f, 0.0f, 0.5f, 1.0f);
                }
                if (m_timeInStage >= 1.0f)
                {
                    NextStage();
                }
                break;
            }

            default:
            {
                NextStage();
                break;
            }
            }
        }
Ejemplo n.º 30
0
 public IEnumerator SyncPlayAnim(LuaAnimation anim, LuaContext context = null)
 {
     PlayAnimation(anim, null, context);
     yield return(FinishAnims());
 }