Beispiel #1
0
 public InventoryBackground(Base parent, Inventory inventory, InventoryGUI inventoryGui) : 
 base(parent)
 {
     this.inventory = inventory;
     this.inventoryGui = inventoryGui;
 }
Beispiel #2
0
        public InventoryBarButton (Base parent, MessageProvider messageProvider, List<InventoryBarButton> barItems,
            Inventory inventory, InventoryGUI inventoryGui, ItemComponent item, byte position, int boxSize) :
        base (parent)
        {
            ValidMessages = new[] { (int) MessageId.ItemUsageChanged, (int) MessageId.BarItemMoved };
            this.boxSize = boxSize;
            this.IsToggle = true;
            this.item = item;
            this.inventory = inventory;
            this.barItems = barItems;
            this.inventoryGui = inventoryGui;

            if (!string.IsNullOrEmpty(item.ImageLocation))
                SetImage(item.ImageLocation, true);

            Width = boxSize - 1;
            Height = boxSize - 1;
            X = boxSize * position + 1;
            Y = 2;

            usageProgress = new ProgressBar(this);
            usageProgress.AutoLabel = false;
            usageProgress.Text = string.Empty;
            usageProgress.TextPadding = Padding.Zero;
            usageProgress.Value = 1 - item.Usage;
            usageProgress.SetSize(Width, 10);
            usageProgress.Y = Height - usageProgress.Height;
            usageProgress.X = 0;

            var max = item.Size.X > item.Size.Y ? item.Size.X : item.Size.Y;
            m_Image.Width = (boxSize / max) * item.Size.X;
            m_Image.Height = (boxSize / max) * item.Size.Y;
            DragAndDrop_SetPackage (true, "bar_drag");

            messageProvider += this;
            this.MessageProvider = messageProvider;
        }
Beispiel #3
0
 public InventoryBarSpace (Base parent, MessageProvider messageProvider, Inventory inventory,
     InventoryGUI inventoryGui, List<InventoryBarButton> barItems, int boxSize) : base (parent)
 {
     DrawDebugOutlines = true;
     foreach (var child in Children)
         child.DrawDebugOutlines = false;
     ShouldDrawBackground = false;
     BoundsOutlineColor = Color.Gray;
     this.boxSize = boxSize;
     this.inventory = inventory;
     this.barItems = barItems;
     this.inventoryGui = inventoryGui;
     this.MessageProvider = messageProvider;
 }
Beispiel #4
0
        public InventoryButton (Base parent, MessageProvider messageProvider, Inventory inventory, ItemComponent item,
            InventoryGUI inventoryGui, Vector2i position, int boxSize) : base (parent)
        {
            ValidMessages = new[] { (int) MessageId.ItemUsageChanged };
            this.boxSize = boxSize;
            this.IsToggle = true;
            this.inventory = inventory;
            this.inventoryGui = inventoryGui;
            this.item = item;
            X = position.X * boxSize + 1;
            Y = position.Y * boxSize + 1;

            if (!string.IsNullOrEmpty(item.ImageLocation))
                SetImage(item.ImageLocation, true);

            usageProgress = new ProgressBar(this);
            usageProgress.AutoLabel = false;
            usageProgress.Text = string.Empty;
            usageProgress.Value = 1 - item.Usage;
            usageProgress.TextPadding = Padding.Zero;
            UpdateSize();
            DragAndDrop_SetPackage (true, "item_drag");

            MessageProvider = messageProvider;

            messageProvider += this;
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FreezingArcher.Game.MazeTest"/> class.
        /// </summary>
        /// <param name="messageProvider">The message provider for this instance.</param>
        /// <param name="objmnr">The object manager for this instance.</param>
        /// <param name="rendererContext">The renderer context for the maze scenes.</param>
        /// <param name="game">The game the maze should be generated in.</param>
        public MazeTest (MessageProvider messageProvider, ObjectManager objmnr, RendererContext rendererContext,
            Content.Game game, Application app, CompositorNodeScene sceneNode,
            CompositorImageOverlayNode healthOverlayNode, CompositorColorCorrectionNode colorCorrectionNode,
            CompositorNodeOutput outputNode, CompositorWarpingNode warpingNode)
        {
            ValidMessages = new[] {
                (int) MessageId.Input,
                (int) MessageId.Update,
                (int) MessageId.HealthChanged,
                (int) MessageId.CollisionDetected,
                (int) MessageId.StaminaChanged,
                (int) MessageId.ItemUse,
                (int) MessageId.FlashlightToggled
            };
            messageProvider += this;
            mazeGenerator = new MazeGenerator (objmnr);

            MazeSceneNode = sceneNode;
            HealthOverlayNode = healthOverlayNode;
            ColorCorrectionNode = colorCorrectionNode;
            OutputNode = outputNode;
            WarpingNode = warpingNode;
            this.game = game;
            application = app;

            FPS_Text = new Gwen.ControlInternal.Text (app.RendererContext.Canvas);
            FPS_Text.String = "0 FPS";
            FPS_Text.Font = new Gwen.Font (app.RendererContext.GwenRenderer);
            FPS_Text.SetPosition (5, 5);
            FPS_Text.Font.Size = 15;
            FPS_Text.Hide ();

            HealthOverlayNode.OverlayTexture = rendererContext.CreateTexture2D ("bloodsplatter", true, "Content/bloodsplatter.png");
            HealthOverlayNode.Factor = 0;
            HealthOverlayNode.Blending = OverlayBlendMode.Multiply;
            warpingNode.WarpTexture = rendererContext.CreateTexture2D ("warp", true, "Content/warp.jpg");

            game.SceneNode = MazeSceneNode;

            game.AddGameState ("maze_overworld", Content.Environment.Default, null);
            var state = game.GetGameState ("maze_overworld");

            state.Scene = new CoreScene (rendererContext, messageProvider);
            state.Scene.SceneName = "MazeOverworld";
            state.Scene.Active = false;
            state.Scene.BackgroundColor = Color4.Fuchsia;
            state.Scene.DistanceFogIntensity = 0.07f;
            state.Scene.AmbientColor = Color4.White;
            state.Scene.AmbientIntensity = 0.3f;
            state.Scene.MaxRenderingDistance = 1000.0f;

            state.AudioContext = new AudioContext (state.MessageProxy);

            state.MessageProxy.StartProcessing ();

            loadingScreen = new LoadingScreen (application, messageProvider, "Content/loading.png",
                "MazeLoadingScreen",
                new[] { new Tuple<string, GameStateTransition> ("main_menu", GameStateTransition.DefaultTransition) },
                new[] { new Tuple<string, GameStateTransition> (state.Name, new GameStateTransition (0)) });

            endScreen = new EndScreen (application, rendererContext, new Tuple<string, GameStateTransition>[] {
                new Tuple<string, GameStateTransition> ("maze_overworld", GameStateTransition.DefaultTransition),
                new Tuple<string, GameStateTransition> ("maze_underworld", GameStateTransition.DefaultTransition)
            });

            game.SwitchToGameState ("MazeLoadingScreen");

            Player = EntityFactory.Instance.CreateWith ("player", state.MessageProxy, new[] {
                typeof(HealthComponent),
                typeof(StaminaComponent)
            }, new[] {
                typeof(MovementSystem),
                typeof(KeyboardControllerSystem),
                typeof(MouseControllerSystem),
                typeof(SkyboxSystem),
                typeof(PhysicsSystem)
            });

            inventoryGui = new InventoryGUI (app, state, Player, messageProvider, warpingNode);
            var inventory = new Inventory (messageProvider, state, Player, new Vector2i (5, 7), 9);
            inventoryGui.Init (rendererContext.Canvas, inventory);

            PauseMenu = new PauseMenu (application, ColorCorrectionNode, rendererContext.Canvas,
                () => maze [currentMaze].AIManager.StartThinking (), () => maze [currentMaze].AIManager.StopThinking ());
            
            AddAudio (state);

            // embed new maze into game state logic and create a MoveEntityToScene
            SkyboxSystem.CreateSkybox (state.Scene, Player);
            Player.GetComponent<TransformComponent> ().Position = new Vector3 (0, 1.85f, 0);
            var maze_cam_entity = EntityFactory.Instance.CreateWith ("maze_cam_transform", state.MessageProxy, new[] { typeof(TransformComponent) });
            var maze_cam_transform = maze_cam_entity.GetComponent<TransformComponent> ();
            var maze_cam = new BaseCamera (maze_cam_entity, state.MessageProxy, orthographic: true);
            state.Scene.CameraManager.AddCamera (maze_cam, "maze");
            maze_cam_transform.Position = new Vector3 (115, 240, 110);
            maze_cam_transform.Rotation = Quaternion.FromAxisAngle (Vector3.UnitX, MathHelper.PiOver2);
            state.Scene.CameraManager.AddCamera (new BaseCamera (Player, state.MessageProxy), "player");

            RigidBody playerBody = new RigidBody (new SphereShape (1f));
            playerBody.Position = Player.GetComponent<TransformComponent> ().Position.ToJitterVector ();
            playerBody.AllowDeactivation = false;
            playerBody.Material.StaticFriction = 0f;
            playerBody.Material.KineticFriction = 0f;
            playerBody.Material.Restitution = 0.1f;
            //playerBody.Mass = 1000000.0f;
            playerBody.Update ();
            Player.GetComponent<PhysicsComponent> ().RigidBody = playerBody;
            Player.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
            Player.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;

            #if PRESENTATION
            Player.GetComponent<HealthComponent>().MaximumHealth = 500;
            Player.GetComponent<HealthComponent>().Health = 500;
            #endif

            state.PhysicsManager.World.AddBody (playerBody);

            int seed = new FastRandom ().Next ();
            var rand = new FastRandom (seed);
            Logger.Log.AddLogEntry (LogLevel.Debug, "MazeTest", "Seed: {0}", seed);

            #if PRESENTATION
            maze [0] = mazeGenerator.CreateMaze<OverworldMazeTheme> (rand.Next (), state.MessageProxy, state.PhysicsManager, app.AudioManager, 10, 10);
            #else
            maze [0] = mazeGenerator.CreateMaze<OverworldMazeTheme> (rand.Next (), state.MessageProxy, state.PhysicsManager, app.AudioManager, 30, 30);
            #endif
            maze [0].PlayerPosition += Player.GetComponent<TransformComponent> ().Position;
            maze [0].AIManager.RegisterEntity (Player);

            for (int i = 0; i < OverworldScobisCount; i++)
            {
                ScobisInstances.Add (new Scobis (state, maze [0].AIManager, rendererContext));
            }

            for (int i = 0; i < OverworldCaligoCount; i++)
            {
                CaligoInstances.Add (new Caligo (state, maze [0].AIManager, rendererContext, warpingNode));
            }

            for (int i = 0; i < OverworldViridionCount; i++)
            {
                ViridionInstances.Add (new Viridion (state, maze [0].AIManager, rendererContext, ColorCorrectionNode)); 
            }

            for (int i = 0; i < OverworldGhostCount; i++)
            {
                GhostInstances.Add (new Ghost (state, maze [0].AIManager, rendererContext, ColorCorrectionNode));
            }

            game.AddGameState ("maze_underworld", Content.Environment.Default,
                new[] { new Tuple<string, GameStateTransition> ("maze_overworld", new GameStateTransition (0)) },
                new[] { new Tuple<string, GameStateTransition> ("maze_overworld", new GameStateTransition (0)),
                    new Tuple<string, GameStateTransition> ("endscreen_state", new GameStateTransition (0))
                });
            state = game.GetGameState ("maze_underworld");
            state.Scene = new CoreScene (rendererContext, messageProvider);
            state.Scene.SceneName = "MazeUnderworld";
            state.Scene.Active = false;
            state.Scene.BackgroundColor = Color4.AliceBlue;
            state.Scene.DistanceFogIntensity = 0.07f;
            state.Scene.AmbientColor = Color4.White;
            state.Scene.AmbientIntensity = 0.3f;
            state.Scene.MaxRenderingDistance = 1000.0f;

            state.AudioContext = new AudioContext (state.MessageProxy);

            AddAudio (state);

            state.Scene.CameraManager.AddCamera (new BaseCamera (Player, state.MessageProxy), "player");
            #if PRESENTATION
            maze [1] = mazeGenerator.CreateMaze<UnderworldMazeTheme> (rand.Next (), state.MessageProxy, state.PhysicsManager, app.AudioManager, 10, 10);
            #else
            maze [1] = mazeGenerator.CreateMaze<UnderworldMazeTheme> (rand.Next (), state.MessageProxy, state.PhysicsManager, app.AudioManager, 30, 30);
            #endif
            maze [1].PlayerPosition += Player.GetComponent<TransformComponent> ().Position;
            maze [1].AIManager.RegisterEntity (Player);

            Func<int, int, bool> containsPortalFunc = (x, y) =>
            {
                foreach (var m in maze)
                {
                    var cell = m.entities [x, y].GetComponent<PhysicsComponent> ().RigidBody.Tag as MazeCell;
                    if (cell != null && cell.IsPortal)
                    {
                        return true;
                    }
                }
                return false;
            };

            mazeWallMover = new MazeWallMover (maze [0], maze [1], game.GetGameState ("maze_overworld"), containsPortalFunc);

            state.MessageProxy.StopProcessing ();
            //game.SwitchToGameState("maze_overworld");

            for (int i = 0; i < UnderworldCaligoCount; i++)
            {
                CaligoInstances.Add (new Caligo (state, maze [1].AIManager, rendererContext, warpingNode));
            }

            for (int i = 0; i < UnderworldPassusCount; i++)
            {
                PassusInstances.Add (new Passus (ColorCorrectionNode, state, maze [1].AIManager, rendererContext));
            }

            for (int i = 0; i < UnderworldRoachesCount; i++)
            {
                RoachesInstances.Add(new Roaches (state, maze [0].AIManager, rendererContext));
            }

            for (int i = 0; i < UnderworldFenFireCount; i++)
            {
                FenFireInstances.Add (new FenFire (state, maze [1].AIManager, rendererContext));
            }
        }