Пример #1
0
        public Passus (CompositorColorCorrectionNode colorCorrectionNode,
            GameState state, AIManager aiManager, RendererContext rendererContext)
        {
            passusEmitter = new PassusGhostParticleEmitter ();

            PassusGameState = state;

            particlePassus = new ParticleSceneObject (passusEmitter.ParticleCount);
            particlePassus.Priority = 7001;
            state.Scene.AddObject (particlePassus);
            passusEmitter.Init (particlePassus, rendererContext);

            PassusEntity = EntityFactory.Instance.CreateWith ("Passus." + InstanceCount++, state.MessageProxy,
                new[] { typeof (ArtificialIntelligenceComponent) },
                new[] { typeof (ParticleSystem), typeof (PhysicsSystem) });

            PassusEntity.GetComponent<ParticleComponent> ().Emitter = passusEmitter;
            PassusEntity.GetComponent<ParticleComponent> ().Particle = particlePassus;

            RigidBody passusBody = new RigidBody (new SphereShape (1.2f));
            passusBody.AffectedByGravity = false;
            passusBody.AllowDeactivation = false;
            passusBody.Mass = 20;
            PassusEntity.GetComponent<PhysicsComponent> ().RigidBody = passusBody;
            PassusEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
            PassusEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;

            state.PhysicsManager.World.AddBody (passusBody);

            var AIcomp = PassusEntity.GetComponent<ArtificialIntelligenceComponent>();
            AIcomp.AIManager = aiManager;
            AIcomp.ArtificialIntelligence = new PassusAI (PassusEntity, state, colorCorrectionNode);
            aiManager.RegisterEntity (PassusEntity);
        }
Пример #2
0
        public Caligo (GameState state, AIManager aiManager, RendererContext rendererContext,
            CompositorWarpingNode warpingNode)
        {
            caligoEmitter = new CaligoParticleEmitter ();
            particleCaligo = new ParticleSceneObject (caligoEmitter.ParticleCount);
            particleCaligo.Priority = 7000;
            state.Scene.AddObject (particleCaligo);
            caligoEmitter.Init (particleCaligo, rendererContext);

            CaligoGameState = state;

            CaligoEntity = EntityFactory.Instance.CreateWith ("Caligo." + InstanceCount++, state.MessageProxy,
                new[] { typeof (ArtificialIntelligenceComponent) },
                new[] { typeof (ParticleSystem), typeof (PhysicsSystem) });

            CaligoEntity.GetComponent<ParticleComponent> ().Emitter = caligoEmitter;
            CaligoEntity.GetComponent<ParticleComponent> ().Particle = particleCaligo;

            RigidBody caligoBody = new RigidBody (new SphereShape (1.2f));
            caligoBody.AffectedByGravity = false;
            caligoBody.AllowDeactivation = false;
            caligoBody.Mass = 20;
            CaligoEntity.GetComponent<PhysicsComponent> ().RigidBody = caligoBody;
            CaligoEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
            CaligoEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;

            state.PhysicsManager.World.AddBody (caligoBody);

            var AIcomp = CaligoEntity.GetComponent<ArtificialIntelligenceComponent>();
            AIcomp.AIManager = aiManager;
            AIcomp.ArtificialIntelligence = new CaligoAI (CaligoEntity, state, warpingNode);
            aiManager.RegisterEntity (CaligoEntity);
        }
Пример #3
0
        public bool Init(ParticleSceneObject part, ParticleSceneObject eye1, ParticleSceneObject eye2, ParticleSceneObject smoke, RendererContext rc)
        {
            this.eye1 = eye1;
            this.eye2 = eye2;
            this.smoke = smoke;

            return base.Init (part, rc);
        }
Пример #4
0
        public virtual bool Init(ParticleSceneObject obj, RendererContext rc)
        {
            SceneObject = obj;

            InitializeParticles (rc);

            return true;
        }
Пример #5
0
        public Viridion (GameState state, AIManager aiManager, RendererContext rendererContext,
            CompositorColorCorrectionNode colorCorrectionNode)
        {
            viridionEmitter = new ViridionParticleEmitter ();

            ViridionGameState = state;

            particleViridion = new ParticleSceneObject (viridionEmitter.ParticleCount);
            particleViridion.Priority = 7002;
            state.Scene.AddObject (particleViridion);
            viridionEmitter.Init (particleViridion, rendererContext);

            ViridionEntity = EntityFactory.Instance.CreateWith ("Viridion." + InstanceCount++, state.MessageProxy,
                new[] { typeof (ArtificialIntelligenceComponent) },
                new[] { typeof (ParticleSystem), typeof (PhysicsSystem), typeof(LightSystem) });

            ViridionEntity.GetComponent<ParticleComponent> ().Emitter = viridionEmitter;
            ViridionEntity.GetComponent<ParticleComponent> ().Particle = particleViridion;

            var light = ViridionEntity.GetComponent<LightComponent> ().Light;
            light = new FreezingArcher.Renderer.Scene.Light (FreezingArcher.Renderer.Scene.LightType.PointLight);
            light.On = true;
            light.Color = new FreezingArcher.Math.Color4 (0.6f, 0.6f, 0.6f, 1.0f);
            light.PointLightLinearAttenuation = 0.4f;
            light.PointLightConstantAttenuation = 0.7f;
            light.PointLightExponentialAttenuation = 0.008f;

            ViridionEntity.GetComponent<LightComponent> ().Light = light;

            state.Scene.AddLight (light);

            RigidBody ghostBody = new RigidBody (new SphereShape (1.2f));
            ghostBody.AffectedByGravity = false;
            ghostBody.AllowDeactivation = false;
            ghostBody.Mass = 20;
            ViridionEntity.GetComponent<PhysicsComponent> ().RigidBody = ghostBody;
            ViridionEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
            ViridionEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;

            state.PhysicsManager.World.AddBody (ghostBody);

            ViridionEntity.GetComponent<ArtificialIntelligenceComponent>().AIManager = aiManager;
            ViridionEntity.GetComponent<ArtificialIntelligenceComponent>().ArtificialIntelligence =
                new ViridionAI (ViridionEntity, state, colorCorrectionNode);
            aiManager.RegisterEntity (ViridionEntity);
        }
Пример #6
0
        public FenFire (GameState state, AIManager aiManager, RendererContext rendererContext)
        {
            ghostEmitter = new FenFireParticleEmitter ();

            particleGhost = new ParticleSceneObject (ghostEmitter.ParticleCount);
            particleGhost.Priority = 7092;
            state.Scene.AddObject (particleGhost);
            ghostEmitter.Init (particleGhost, rendererContext);

            GhostGameState = state;

            GhostEntity = EntityFactory.Instance.CreateWith ("FenFire." + InstanceCount++, state.MessageProxy,
                new[] { typeof (ArtificialIntelligenceComponent) },
                new[] { typeof (ParticleSystem), typeof (PhysicsSystem), typeof(LightSystem) });

            GhostEntity.GetComponent<ParticleComponent> ().Emitter = ghostEmitter;
            GhostEntity.GetComponent<ParticleComponent> ().Particle = particleGhost;

            var light = GhostEntity.GetComponent<LightComponent> ().Light;
            light = new FreezingArcher.Renderer.Scene.Light (FreezingArcher.Renderer.Scene.LightType.PointLight);
            light.On = true;
            light.Color = new FreezingArcher.Math.Color4 (0.0f, 0.0f, 0.6f, 1.0f);
            light.PointLightLinearAttenuation = 0.4f;
            light.PointLightConstantAttenuation = 0.7f;
            light.PointLightExponentialAttenuation = 0.008f;

            GhostEntity.GetComponent<LightComponent> ().Light = light;

            state.Scene.AddLight (light);

            RigidBody ghostBody = new RigidBody (new SphereShape (0.4f));
            ghostBody.AffectedByGravity = false;
            ghostBody.AllowDeactivation = false;
            ghostBody.Mass = 20;
            GhostEntity.GetComponent<PhysicsComponent> ().RigidBody = ghostBody;
            GhostEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
            GhostEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;

            state.PhysicsManager.World.AddBody (ghostBody);

            GhostEntity.GetComponent<ArtificialIntelligenceComponent>().AIManager = aiManager;
            GhostEntity.GetComponent<ArtificialIntelligenceComponent>().ArtificialIntelligence =
                new FenFireAI (GhostEntity, state);
            aiManager.RegisterEntity (GhostEntity);
        }
Пример #7
0
        public Scobis (GameState state, AIManager aiManager, RendererContext rendererContext)
        {
            paremitter = new ScobisParticleEmitter ();
            particleEye1 = new ParticleSceneObject (paremitter.RedEye1.ParticleCount);
            particleEye2 = new ParticleSceneObject (paremitter.RedEye2.ParticleCount);
            particleSmoke = new ParticleSceneObject (paremitter.Smoke.ParticleCount);
            particleEye1.Priority = 5999;
            particleEye2.Priority = 5999;
            particleSmoke.Priority = 6000;

            ScobisGameState = state;

            state.Scene.AddObject (particleEye1);
            state.Scene.AddObject (particleEye2);
            state.Scene.AddObject (particleSmoke);

            particle = new ParticleSceneObject (paremitter.ParticleCount);
            particle.Priority = 5998;
            state.Scene.AddObject (particle);

            paremitter.Init (particle, particleEye1, particleEye2, particleSmoke, rendererContext);

            ScobisEntity = EntityFactory.Instance.CreateWith ("Scobis." + InstanceCount++, state.MessageProxy,
                new[] { typeof (ArtificialIntelligenceComponent) },
                new[] { typeof (ParticleSystem), typeof (PhysicsSystem) });

            ScobisEntity.GetComponent<ParticleComponent> ().Emitter = paremitter;
            ScobisEntity.GetComponent<ParticleComponent> ().Particle = particle;
            RigidBody scobisBody = new RigidBody (new SphereShape (0.3f));
            scobisBody.AffectedByGravity = false;
            scobisBody.AllowDeactivation = false;
            scobisBody.Mass = 20;
            ScobisEntity.GetComponent<PhysicsComponent> ().RigidBody = scobisBody;
            ScobisEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
            ScobisEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;

            state.PhysicsManager.World.AddBody (scobisBody);

            var AIcomp = ScobisEntity.GetComponent<ArtificialIntelligenceComponent>();
            AIcomp.AIManager = aiManager;
            AIcomp.ArtificialIntelligence = new ScobisAI (paremitter.Smoke, ScobisEntity, state);
            AIcomp.MaximumEntityDistance = 30;
            aiManager.RegisterEntity (ScobisEntity);
        }
Пример #8
0
        /// <summary>
        /// Processes the incoming message
        /// </summary>
        /// <param name="msg">Message to process</param>
        public void ConsumeMessage (IMessage msg)
        {
            if (msg.MessageId == (int) MessageId.Update)
            {
                var um = msg as UpdateMessage;

                if (maze [0].HasFinished && maze [1].HasFinished && !finishedLoading)
                {
                    #if DEBUG
                    maze [0].ExportAsImage ("overworld.png");
                    maze [1].ExportAsImage ("underworld.png");
                    #endif

                    //Add Portals
                    Portals = new List<Entity> ();

                    foreach (var node in maze[0].graph.Nodes)
                    {
                        if (node.Data.IsPortal)
                        {
                            var portalEmitter = new PortalParticles ();
                            var particleSceneObject = new ParticleSceneObject (portalEmitter.ParticleCount);
                            particleSceneObject.Priority = 7000;
                            game.GetGameState ("maze_overworld").Scene.AddObject (particleSceneObject); 

                            portalEmitter.Init (particleSceneObject, Application.Instance.RendererContext);

                            var portalEntity = EntityFactory.Instance.CreateWith ("PortalEmitter " + DateTime.Now.Ticks, 
                                                   game.GetGameState ("maze_overworld").MessageProxy, systems: new[] { typeof(ParticleSystem) });

                            portalEntity.GetComponent<ParticleComponent> ().Emitter = portalEmitter;
                            portalEntity.GetComponent<ParticleComponent> ().Particle = particleSceneObject;

                            portalEntity.GetComponent<TransformComponent> ().Position = node.Data.WorldPosition;

                            Portals.Add (portalEntity);
                        }
                    }

                    foreach (var node in maze[1].graph.Nodes)
                    {
                        if (node.Data.IsPortal)
                        {
                            var portalEmitter = new PortalParticles ();
                            var particleSceneObject = new ParticleSceneObject (portalEmitter.ParticleCount);
                            particleSceneObject.Priority = 7000;
                            game.GetGameState ("maze_underworld").Scene.AddObject (particleSceneObject); 

                            portalEmitter.Init (particleSceneObject, Application.Instance.RendererContext);

                            var portalEntity = EntityFactory.Instance.CreateWith ("PortalEmitter " + DateTime.Now.Ticks, 
                                                   game.GetGameState ("maze_underworld").MessageProxy, systems: new[] { typeof(ParticleSystem) });

                            portalEntity.GetComponent<ParticleComponent> ().Emitter = portalEmitter;
                            portalEntity.GetComponent<ParticleComponent> ().Particle = particleSceneObject;

                            portalEntity.GetComponent<TransformComponent> ().Position = node.Data.WorldPosition;

                            Portals.Add (portalEntity);
                        }
                    }

                    finishedLoading = true;

                    application.Window.CaptureMouse ();

                    loadingScreen.Ready ();

                    if (game.CurrentGameState.Name != "maze_overworld")
                    {
                        game.SwitchToGameState ("maze_overworld");

                        game.CurrentGameState.Scene.Active = true;
                    }

                    backgroundMusic.Play ();
                    FurryLana.MainMenuMusic.Stop ();
                }

                if (!finishedLoading)
                    loadingScreen.BringToFront ();

                if (game.CurrentGameState == game.GetGameState ("maze_overworld") && maze [0].HasFinished)
                    game.CurrentGameState.PhysicsManager.Update (um.TimeStamp);

                if (game.CurrentGameState == game.GetGameState ("maze_underworld") && maze [1].HasFinished)
                    game.CurrentGameState.PhysicsManager.Update (um.TimeStamp);

                if (application.FPSCounter >= 50)
                    FPS_Text.TextColor = System.Drawing.Color.Green;
                else
                if (application.FPSCounter < 50 && application.FPSCounter > 30)
                    FPS_Text.TextColor = System.Drawing.Color.Yellow;
                else
                    FPS_Text.TextColor = System.Drawing.Color.Red;

                FPS_Text.String = application.FPSCounter + " FPS";

                if (HealthOverlayNode.Factor > 0.0001f)
                {
                    var factor = HealthOverlayNode.Factor - 0.01f;
                    HealthOverlayNode.Factor = factor < 0 ? 0 : factor;
                }

                if (switch_maze)
                {
                    if ((DateTime.Now - lastPortal).TotalSeconds >= 10.0f)
                    {
                        if (entered_portal && ColorCorrectionNode.Contrast > 0.0f)
                        {
                            //ColorCorrectionNode.Brightness += (float) um.TimeStamp.TotalSeconds * 0.8f;
                            ColorCorrectionNode.Contrast -= (float) um.TimeStamp.TotalSeconds * 0.3f;
                            WarpingNode.WarpFactor = (1 - ColorCorrectionNode.Contrast) * 0.5f;
                        }
                        else
                        if (entered_portal && ColorCorrectionNode.Contrast <= 0.0f)
                        {
                            SwitchMaze ();
                            entered_portal = false;
                        }
                        else
                        if (!entered_portal && ColorCorrectionNode.Contrast < 1.0f)
                        {
                            //ColorCorrectionNode.Brightness -= (float) um.TimeStamp.TotalSeconds * 0.8f;
                            ColorCorrectionNode.Contrast += (float) um.TimeStamp.TotalSeconds * 0.3f;
                            WarpingNode.WarpFactor = (1 - ColorCorrectionNode.Contrast) * 0.5f;
                        }
                        else
                        {
                            ColorCorrectionNode.Contrast = 1.0f;
                            switch_maze = false;
                            Player.GetComponent<PhysicsComponent> ().IsMoveable = true;

                            //WarpingNode.WarpTexture = DefaultWarpingTexture;
                            WarpingNode.WarpFactor = 0;

                            lastPortal = DateTime.Now;
                        }
                    }
                    else
                    {
                        switch_maze = false;
                        Player.GetComponent<PhysicsComponent> ().IsMoveable = true;
                    }
                }

                if (Player.GetComponent<TransformComponent> ().Position.Y <= -10.0f &&
                    finishedLoading && game.CurrentGameState.Name != "MazeLoadingScreen")
                {
                    Player.GetComponent<HealthComponent> ().Health = 0.0f;
                }
                else if (Player.GetComponent<TransformComponent> ().Position.Y >= 5.9f &&
                    finishedLoading && game.CurrentGameState.Name != "MazeLoadingScreen")
                {/*
                        
                    Player.GetComponent<PhysicsComponent> ().RigidBody.Position = new Jitter.LinearMath.JVector (
                        Player.GetComponent<PhysicsComponent> ().RigidBody.Position.X, 8.0f, 
                        Player.GetComponent<PhysicsComponent> ().RigidBody.Position.Z);*/

                    /*
                    if (Player.GetComponent<PhysicsComponent> ().RigidBody.LinearVelocity.Y > 0)
                    {
                        Player.GetComponent<PhysicsComponent> ().RigidBody.LinearVelocity =
                            new Jitter.LinearMath.JVector (Player.GetComponent<PhysicsComponent> ().RigidBody.LinearVelocity.X,
                            0.0f, Player.GetComponent<PhysicsComponent> ().RigidBody.LinearVelocity.Z);
                    }*/

                    if ((DateTime.Now - lastDamage).TotalSeconds > 0.5f)
                    {
                        //Player.GetComponent<HealthComponent> ().Health -= Player.GetComponent<HealthComponent> ().MaximumHealth * 0.1f;
                        lastDamage = DateTime.Now;
                    }
                }
            }

            if (msg.MessageId == (int) MessageId.CollisionDetected)
            {
                CollisionDetectedMessage cdm = msg as CollisionDetectedMessage;

                if (cdm.Body1.Tag == null)
                {
                    if (cdm.Body2.Tag == null)
                        return;

                    MazeCell mc = cdm.Body2.Tag as MazeCell;
                    if (mc == null)
                        return;

                    if (mc.IsPortal)
                    {
                        if ((DateTime.Now - lastDamage).TotalSeconds > 10.0f)
                        {
                            if (!switch_maze)
                            {
                                entered_portal = true;
                                switch_maze = true;
                                Player.GetComponent<PhysicsComponent> ().IsMoveable = false;
                                switchMazeSound.Play ();
                            }
                        }
                    }
                }
                else if (cdm.Body2.Tag == null)
                {
                    if (cdm.Body1.Tag == null)
                        return;

                    MazeCell mc = cdm.Body1.Tag as MazeCell;
                    if (mc == null)
                        return;

                    if (mc.IsPortal)
                    {
                        if ((DateTime.Now - lastDamage).TotalSeconds > 10.0f)
                        {
                            if (!switch_maze)
                            {
                                entered_portal = true;
                                switch_maze = true;
                                Player.GetComponent<PhysicsComponent> ().IsMoveable = false;
                                switchMazeSound.Play ();
                            }
                        }
                    }
                }
            }

            if (msg.MessageId == (int) MessageId.HealthChanged && finishedLoading)
            {
                var hcm = msg as HealthChangedMessage;

                if (hcm.Entity == Player)
                {
                    if (hcm.HealthDelta < 0)
                    {
                        var factor = -hcm.HealthDelta / 20;
                        HealthOverlayNode.Factor = factor > 1 ? 1 : factor;

                        if (playerDamagedSound.GetState () != SourceState.Playing)
                            playerDamagedSound.Play ();
                    }

                    var healthComponent = Player.GetComponent<HealthComponent> ();
                    var health = healthComponent.Health > 0 ? healthComponent.Health : 0;
                    ColorCorrectionNode.Saturation = -((healthComponent.MaximumHealth - health) / (healthComponent.MaximumHealth)) / 4;

                    if (hcm.Health <= 0.0f && game.CurrentGameState.Name != "MazeLoadingScreen")
                    {
                        WarpingNode.Stop ();
                        endScreen.State.Scene = game.CurrentGameState.Scene;

                        game.SwitchToGameState ("endscreen_state");

                        if (playerDiedSound.GetState () != SourceState.Playing)
                            playerDiedSound.Play ();

                        if (MessageCreated != null)
                            MessageCreated (new GameEndedDiedMessage ());
                    }
                }
            }

            var im = msg as InputMessage;
            if (im != null)
            {
                #if RELEASE
                if (im.IsActionPressed ("frame"))
                {
                    if (FPS_Text.IsHidden)
                        FPS_Text.Show();
                    else
                        FPS_Text.Hide();
                }
                #else
                if (im.IsActionPressed ("drop"))
                    application.Window.CaptureMouse ();

                if (im.IsActionPressed ("frame"))
                {
                    if (lighting)
                    {
                        var state = game.CurrentGameState;
                        state.Scene.DistanceFogIntensity = 0;
                        state.Scene.AmbientIntensity = 1f;
                        //light1.PointLightLinearAttenuation = 99999;
                        lighting = false;
                    }
                    else
                    {
                        var state = game.CurrentGameState;
                        state.Scene.DistanceFogIntensity = 0.04f;
                        state.Scene.AmbientIntensity = 0.35f;
                        //light1.PointLightLinearAttenuation = 0.01f;
                        lighting = true;
                    }
                }

                if (im.IsActionPressed ("damage"))
                {
                    SwitchMaze ();
                }
                #endif
            }
           
            if (msg.MessageId == (int) MessageId.StaminaChanged && finishedLoading)
            {
                StaminaChangedMessage scm = msg as StaminaChangedMessage;

                if (scm.Stamina <= 0.1f)
                {
                    if (playerNoStamina.GetState () != SourceState.Playing)
                        playerNoStamina.Play ();
                }
            }

            if (msg.MessageId == (int) MessageId.ItemUse)
            {
                ItemUseMessage ium = msg as ItemUseMessage;
                if (ium.Usage.HasFlag (ItemUsage.Eatable) && ium.Item.ItemUsages.HasFlag (ItemUsage.Eatable))
                {
                    if (ium.Entity.Name != null)
                    {
                        try
                        {
                            if (ium.Item.Entity.Name.Contains ("choco_milk") || ium.Item.Entity.Name.Contains ("soda_can") ||
                            ium.Item.Entity.Name.Contains ("mate"))
                            {
                                if (playerDrinked.GetState () != SourceState.Playing)
                                    playerDrinked.Play ();
                            }
                            else
                            if (ium.Item.Entity.Name.Contains ("apple") || ium.Item.Entity.Name.Contains ("toast"))
                            {
                                if (playerEaten.GetState () != SourceState.Playing)
                                    playerEaten.Play ();
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }

            if (msg.MessageId == (int) MessageId.FlashlightToggled)
            {
                playerFlashlightTrigger.Play ();
            }
        }