public TutorialMenu (Application application, Base parent) { this.application = application; this.parent = parent; window = new WindowControl (parent); window.DisableResizing(); window.Title = Localizer.Instance.GetValueForName("tutorial"); window.IsMoveable = false; window.Hide(); window.Height = parent.Height - (int) (parent.Height * 0.35); window.Y = (int) (parent.Height * 0.35) - 20; window.Width = parent.Width - 320; window.X = 280; scrollFrame = new ScrollControl (window); scrollFrame.AutoHideBars = true; scrollFrame.EnableScroll (false, true); scrollFrame.Width = window.Width - 12; scrollFrame.Height = window.Height - 32; updateTutorialText(Localizer.Instance.GetValueForName("tutorial_text")); ValidMessages = new[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale }; application.MessageManager += this; }
public LoadingScreen (Application application, MessageProvider messageProvider, string backgroundPath, string name, IEnumerable<Tuple<string, GameStateTransition>> from = null, IEnumerable<Tuple<string, GameStateTransition>> to = null) { if (application.Game.AddGameState(name, Content.Environment.Default, from, to)) LoadingState = application.Game.GetGameState(name); else { Logger.Log.AddLogEntry(LogLevel.Error, "LoadingScreen", "Could not add loading screen game state!"); return; } this.application = application; ValidMessages = new[] { (int) MessageId.WindowResize }; messageProvider += this; image = new ImagePanel(application.RendererContext.Canvas); image.ImageName = backgroundPath; updateImage(); image.BringToFront(); progressBar = new ProgressBar (image); progressBar.IsHorizontal = true; progressBar.AutoLabel = false; progressBar.Y = application.RendererContext.Canvas.Height - 70; progressBar.X = 40 + (image.Width - application.RendererContext.Canvas.Width) / 2; progressBar.Height = 30; progressBar.Width = application.RendererContext.Canvas.Width - 80; }
/// <summary> /// Create an application with the specified name. THIS IS GLOBAL - DO NOT USE MORE THAN ONCE! /// This should be the last call of your main method. Only run in main thread! /// </summary> /// <param name="name">Name.</param> /// <param name="args">Command line arguments.</param> public static void Create (string name, string[] args) { Instance = new Application (name, args); Instance.Init (); Instance.Load (); Instance.Run (); Instance.Destroy (); }
public PauseMenu (Application app, CompositorColorCorrectionNode colorCorrectionNode, Base parent, Action onContinue, Action onPause) { this.onContinue = onContinue; this.onPause = onPause; this.colorCorrectionNode = colorCorrectionNode; this.application = app; this.parent = parent; settings = new SettingsMenu (app, parent, colorCorrectionNode); window = new WindowControl (parent, Localizer.Instance.GetValueForName("pause")); window.DisableResizing(); window.IsMoveable = false; window.OnClose += (sender, arguments) => Hide(); window.Width = BUTTON_WIDTH + 20; window.Hide(); continueButton = new Button (window); continueButton.Text = Localizer.Instance.GetValueForName("back_to_game"); continueButton.Width = BUTTON_WIDTH; continueButton.X = 10; continueButton.Y = 10; continueButton.Clicked += (sender, arguments) => Hide(); settingsButton = new Button (window); settingsButton.Text = Localizer.Instance.GetValueForName("settings"); settingsButton.Width = BUTTON_WIDTH; settingsButton.X = 10; settingsButton.Y = 10 + continueButton.Y + continueButton.Height; settingsButton.Clicked += (sender, arguments) => settings.Show(); exitButton = new Button (window); exitButton.Text = Localizer.Instance.GetValueForName("quit_game"); exitButton.Width = BUTTON_WIDTH; exitButton.X = 10; exitButton.Y = 10 + settingsButton.Y + settingsButton.Height; exitButton.Clicked += (sender, arguments) => application.Window.Close (); window.Height += exitButton.Y + exitButton.Height + 10; window.X = (parent.Width - window.Width) / 2; window.Y = (parent.Height - window.Height) / 2; ValidMessages = new int[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale, (int) MessageId.Input }; app.MessageManager += this; }
/// <summary> /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.InputMessage"/> class. /// </summary> /// <param name="keys">Keys.</param> /// <param name="mouse">Mouse.</param> /// <param name="mouseMovement">Mouse movement.</param> /// <param name="mouseScroll">Mouse scroll.</param> /// <param name="deltaTime">Delta time.</param> internal InputMessage (List<KeyboardInput> keys, List<MouseInput> mouse, Vector2 mouseMovement, Vector2 mousePosition, Vector2 mouseScroll, TimeSpan deltaTime, Application app) { Keys = keys; Mouse = mouse; MouseMovement = mouseMovement; MousePosition = mousePosition; MouseScroll = mouseScroll; DeltaTime = deltaTime; ApplicationInstance = app; #if DEBUG_PERFORMANCE if (Keys.Count > 0) Logger.Log.AddLogEntry (LogLevel.Warning, "InputMessage", Status.AKittenDies, String.Concat (Keys.Select (k => k.KeyAction))); #endif }
public EndScreen (Application application, RendererContext rc, IEnumerable<Tuple<string, GameStateTransition>> from = null) { Renderer = rc; Application = application; if (!Application.Game.AddGameState ("endscreen_state", FreezingArcher.Content.Environment.Default, from)) { Logger.Log.AddLogEntry (LogLevel.Error, "EndScreen", "Could not add Endscreen-State!"); } State = Application.Game.GetGameState ("endscreen_state"); MessageProvider = State.MessageProxy; BackgroundTexture = null; ValidMessages = new int [] { (int) MessageId.GameEnded, (int) MessageId.GameEndedDied, (int) MessageId.WindowResize, (int) MessageId.UpdateLocale }; MessageProvider += this; }
public FreezingArcherInput(Application app, MessageProvider messageProvider) { application = app; ValidMessages = new int[] { (int) MessageId.Input }; messageProvider += this; }
public SettingsMenu (Application app, Base parent, CompositorColorCorrectionNode colorCorrectionNode) { this.application = app; this.parent = parent; this.colorCorrectionNode = colorCorrectionNode; window = new WindowControl (parent); window.DisableResizing(); window.Title = Localizer.Instance.GetValueForName("settings"); window.Hide(); float gamma = (float) ConfigManager.Instance["freezing_archer"].GetDouble("general", "gamma"); colorCorrectionNode.Gamma = gamma; string language = ConfigManager.Instance["freezing_archer"].GetString("general", "language"); Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), language); languageLabel = new Label (window); languageLabel.AutoSizeToContents = true; languageLabel.Y = 10; languageLabel.Text = Localizer.Instance.GetValueForName("language"); languageDropdown = new ComboBox (window); languageDropdown.Width = CONTROL_WIDTH; languageDropdown.Y = 10; foreach (var lang in Localizer.Instance.Locales) { var item = languageDropdown.AddItem(Localizer.Instance.GetValueForName(lang.Key.ToString()), lang.Key.ToString()); item.AutoSizeToContents = false; item.Width = CONTROL_WIDTH; } languageDropdown.SelectByText(Localizer.Instance.GetValueForName(Localizer.Instance.CurrentLocale.ToString())); languageDropdown.ItemSelected += handleSelect; gammaSlider = new HorizontalSlider (window); gammaSlider.SnapToNotches = false; gammaSlider.Min = 0; gammaSlider.Max = 3; gammaSlider.Value = gamma; gammaSlider.ValueChanged += (sender, arguments) => { var slider = sender as HorizontalSlider; ConfigManager.Instance["freezing_archer"].SetDouble("general", "gamma", slider.Value); if (slider != null) this.colorCorrectionNode.Gamma = slider.Value; }; gammaSlider.Width = CONTROL_WIDTH; gammaSlider.Height = 20; gammaSlider.Y = 10 + languageDropdown.Y + languageDropdown.Height; gammaLabel = new Label (window); gammaLabel.AutoSizeToContents = true; gammaLabel.Y = 10 + languageLabel.Y + languageLabel.Height; gammaLabel.Text = Localizer.Instance.GetValueForName("gamma"); int max_width = languageLabel.Width > gammaLabel.Width ? languageLabel.Width : gammaLabel.Width; languageLabel.X = 10 + max_width - languageLabel.Width; gammaLabel.X = 10 + max_width - gammaLabel.Width; languageDropdown.X = 10 + max_width + 5; gammaSlider.X = 10 + max_width + 5; window.Width = 40 + max_width + CONTROL_WIDTH; resetButton = new Button (window); resetButton.Text = Localizer.Instance.GetValueForName("reset"); resetButton.Width = (window.Width / 2) - 20; resetButton.X = 10; resetButton.Y = gammaSlider.Y + gammaSlider.Height + 10; resetButton.Clicked += (sender, arguments) => { var general = ConfigManager.DefaultConfig.B.FirstOrDefault (a => a.Key == "general"); var gamma_pair = general.Value.FirstOrDefault(a => a.Key == "gamma"); float _gamma = (float) gamma_pair.Value.Double; gammaSlider.Value = _gamma; colorCorrectionNode.Gamma = _gamma; var language_pair = general.Value.FirstOrDefault(a => a.Key == "language"); string lang = language_pair.Value.String; Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), lang); }; saveButton = new Button (window); saveButton.Text = Localizer.Instance.GetValueForName("save"); saveButton.Width = (window.Width / 2) - 20; saveButton.X = resetButton.X + resetButton.Width + 10; saveButton.Y = gammaSlider.Y + gammaSlider.Height + 10; saveButton.Clicked += (sender, arguments) => ConfigManager.Instance.SaveAll(); window.Height += languageDropdown.Height + gammaSlider.Height + 50; window.X = (parent.Width - window.Width) / 2; window.Y = (parent.Height - window.Height) / 2; ValidMessages = new[] { (int) MessageId.UpdateLocale }; application.MessageManager += this; }
public InventoryGUI (Application application, GameState state, Entity player, MessageProvider messageProvider, CompositorWarpingNode warpingNode) { this.application = application; this.player = player; this.MessageProvider = messageProvider; this.GameState = state; this.warpingNode = warpingNode; ValidMessages = new[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale, (int) MessageId.Input, (int) MessageId.Update, (int) MessageId.ActiveInventoryBarItemChanged }; messageProvider += this; }
/// <summary> /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.RunningMessage"/> class. /// </summary> /// <param name="application">Application.</param> public RunningMessage(Application application) { Application = application; }
public MainMenu (Application application, Action onPlayGame, CompositorColorCorrectionNode colorCorrectionNode) { this.application = application; this.onPlayGame = onPlayGame; ValidMessages = new[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale }; application.MessageManager += this; canvas = application.RendererContext.Canvas; var input = new FreezingArcherInput(application, application.MessageManager); input.Initialize (canvas); canvas.SetSize(application.Window.Size.X, application.Window.Size.Y); canvas.ShouldDrawBackground = false; settings = new SettingsMenu (application, canvas, colorCorrectionNode); tutorial = new TutorialMenu (application, canvas); background = new ImagePanel (canvas); background.ImageName = "Content/MainMenu.jpg"; updateBackground(); exitButton = new Button (canvas); exitButton.Text = Localizer.Instance.GetValueForName("quit_game"); exitButton.Width = BUTTON_WIDTH; exitButton.X = 40; exitButton.Y = canvas.Height - exitButton.Height - 60; exitButton.Clicked += (sender, arguments) => application.Window.Close (); settingsButton = new Button (canvas); settingsButton.Text = Localizer.Instance.GetValueForName("settings"); settingsButton.Width = BUTTON_WIDTH; settingsButton.X = 40; settingsButton.Y = exitButton.Y - settingsButton.Height - 40; settingsButton.Clicked += (sender, arguments) => settings.Show(); tutorialButton = new Button (canvas); tutorialButton.Text = Localizer.Instance.GetValueForName("tutorial"); tutorialButton.Width = BUTTON_WIDTH; tutorialButton.X = 40; tutorialButton.Y = settingsButton.Y - tutorialButton.Height - 40; tutorialButton.Clicked += (sender, arguments) => tutorial.Show(); startButton = new Button (canvas); startButton.Text = Localizer.Instance.GetValueForName("start_game"); startButton.Width = BUTTON_WIDTH; startButton.X = 40; startButton.Y = tutorialButton.Y - startButton.Height - 40; startButton.Clicked += (sender, arguments) => { application.MessageManager.UnregisterMessageConsumer(this); application.MessageManager.UnregisterMessageConsumer(settings); settings.Destroy(); canvas.Dispose(); onPlayGame(); }; acagamicsFoo = new ImagePanel (canvas); acagamicsFoo.ImageName = "Content/figure_color.png"; acagamicsFoo.Width = 64; acagamicsFoo.Height = 106; acagamicsFoo.X = canvas.Width - acagamicsFoo.Width - 10; acagamicsFoo.Y = canvas.Height - acagamicsFoo.Height - 10; }
/// <summary> /// Create an application with the specified name. /// This should be the last call of your main method. Only run in main thread! /// </summary> /// <param name="name">Name.</param> /// <param name="args">Command line arguments.</param> public static Application CreateApp (string name, string[] args) { Application app = new Application (name, args); app.Init (); app.Load (); app.Run (); app.Destroy (); return app; }
/// <summary> /// Create an application with the specified name. /// This should be the last call of your main method. Only run in main thread! /// </summary> /// <param name="name">Name.</param> /// <param name="args">Command line arguments.</param> /// <param name="application">The created application.</param> public static void Create (string name, string[] args, out Application application) { application = CreateApp (name, args); }
/// <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)); } }