public override void Draw(TimeSpan timeElapsed)
        {
            var characterWindow      = UserInterfaceManager.Get <CharacterWindow>();
            var generalKeybindings   = UserInterfaceManager.Get <GeneralKeybindingsWindow>();
            var locationKeybindings  = UserInterfaceManager.Get <LocationKeybindingsWindow>();
            var characterKeybindings = UserInterfaceManager.Get <CharacterKeybindingsWindow>();
            var actionKeybindings    = UserInterfaceManager.Get <ActionKeybindingsWindow>();

            generalKeybindings.Draw();

            if (characterWindow.IsVisible)
            {
                characterKeybindings.Draw();
            }
            else
            {
                locationKeybindings.Draw();
                actionKeybindings.Draw();
            }

            characterKeybindings.IsVisible = characterWindow.IsVisible ? true : false;
            locationKeybindings.IsVisible  = characterWindow.IsVisible ? false : true;

            base.Draw(timeElapsed);
        }
示例#2
0
        public void ButtonPressPlay(object sender, EventArgs args)
        {
            // Initialize user interface
            UserInterfaceManager.Initialize();

            // Remove mainmenu and transition
            Transition(UserInterfaceManager.Get <GameWindow>().Console);

            // Instantiate player in the middle of the map
            var spawnPosition = GridManager.Grid.GetCell(a => a.LightProperties.Brightness > 0.3f && a.CellProperties.Walkable);

            Game.Player = EntityManager.Create <Player>(spawnPosition.Position, GridManager.ActiveBlueprint.ObjectId);
            Game.Player.Initialize();

            // Show a tutorial dialog window.
            var dialogWindow = UserInterfaceManager.Get <DialogWindow>();

            dialogWindow.AddDialog("Game introduction", new[]
            {
                "Welcome to Emberpoint.",
                "This is a small introduction to the game.",
                "Press 'Enter' to continue."
            });
            dialogWindow.AddDialog("Flashlight introduction", new[]
            {
                "The flashlight can be used to discover new tiles.",
                "Turn on your flashlight and discover some new tiles.",
                "Press '" + KeybindingsManager.GetKeybinding(Keybindings.Flashlight) + "' to turn on your flashlight.",
                "Press 'Enter' to exit dialog."
            });
            dialogWindow.ShowNext();
        }
示例#3
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            if (UserInterfaceManager.Get <CharacterKeybindingsWindow>().IndexedKeybindings != null) // IndexedKeybindings is created after this window becomes visible
            {
                foreach (var keybinding in UserInterfaceManager.Get <CharacterKeybindingsWindow>().IndexedKeybindings)
                {
                    if (info.IsKeyPressed(keybinding.Key))
                    {
                        var itemPreviewWindow = UserInterfaceManager.Get <ItemPreviewWindow>();
                        itemPreviewWindow.
                        SetObjectForPreview(keybinding.ObjectId);
                        return(true);
                    }
                }
            }

            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.A))
            {
                Game.GameSession.Player.Experience += 1;
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
            }

            return(false);
        }
示例#4
0
        public bool Drain()
        {
            if (Power > 0)
            {
                Power--;
            }

            Game.Player.Inventory.UpdateInventoryText();

            if (Power == 0)
            {
                // Check if we have more than one battery
                if (Amount > 1)
                {
                    Game.Player.Inventory.RemoveInventoryItem <Battery>(1);
                    Power = Constants.Items.BatteryMaxPower;

                    UserInterfaceManager.Get <DialogWindow>().ShowDialog("Battery depleted.", new[] { "A battery has been depleted!", "Press enter to hide this message." });
                    return(true);
                }
                UserInterfaceManager.Get <DialogWindow>().ShowDialog("Battery depleted.", new[] { "You ran out of batteries!", "Press enter to hide this message." });
                return(false);
            }
            return(true);
        }
示例#5
0
        private static void Update(GameTime gameTime)
        {
            if (!UserInterfaceManager.IsInitialized)
            {
                return;
            }

            if (DialogWindow.IsVisible)
            {
                if (Global.KeyboardState.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Enter))
                {
                    DialogWindow.CloseDialog();
                }
            }

            if (UserInterfaceManager.IsPaused)
            {
                return;
            }

            Player.CheckForMovementKeys();
            Player.CheckForInteractionKeys();

            //Test trigger for game over state
            if (Global.KeyboardState.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.P))
            {
                UserInterfaceManager.Get <GameOverWindow>().Show();
            }
        }
示例#6
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            foreach (var keybinding in IndexedKeybindings)
            {
                if (info.IsKeyPressed(keybinding.Key))
                {
                    var itemPreviewWindow = UserInterfaceManager.Get <ItemPreviewWindow>();
                    itemPreviewWindow.
                    SetObjectForPreview(InventoryManager.GetSlot <ISlot>(Game.GameSession.Player.Inventory, keybinding.ObjectId).Item.FirstOrDefault().ObjectId);
                    return(true);
                }
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
                return(true);
            }

            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.E)) // REWORK
            {
                Equip();
            }

            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.U))
            {
                Enchant.EnchantSteel(Game.GameSession.Player.Inventory.CurrentWeapon);
            }

            return(false);
        }
示例#7
0
        private void OpenChoppingWindow()
        {
            var player = EntityManager.Get <IEntity>(Game.GameSession.Player.ObjectId);

            if (WorldObjectManager.ContainsWorldObject <ILocation>(player.CurrentLocation, GameObjects.WorldObjectBase.Objects.Tree))
            {
                this.SwitchFocusMakeVisible(UserInterfaceManager.Get <ChoppingWindow>());
            }
        }
示例#8
0
 public Player() : base(Constants.Player.Foreground, Color.Transparent, Constants.Player.Character, 1, 1)
 {
     FieldOfViewRadius  = 0;
     InteractionStatus  = false;
     _interaction       = UserInterfaceManager.Get <InteractionWindow>();
     interactionManager = new InteractionManager(_interaction, this);
     _fovObjectsWindow  = UserInterfaceManager.Get <FovWindow>();
     Components.Add(new EntityViewSyncComponent());
 }
示例#9
0
        private void DrawEquipButton()
        {
            if (ItemManager.GetItem <IItem>(UserInterfaceManager.Get <ItemPreviewWindow>().ObjectId) is WeaponItem)
            {
                var btn = new Input.ButtonString(new ColoredString("Equip"), Microsoft.Xna.Framework.Input.Keys.E, Constants.Theme.ButtonKeyColor, DefaultForeground,
                                                 Constants.Windows.PreviewX, Constants.Windows.PreviewY + Constants.Windows.ItemPreviewHeight - 1);

                btn.Draw(this);
            }
        }
示例#10
0
        public override void PickUp()
        {
            var inventory = Game.Player == null?UserInterfaceManager.Get <InventoryWindow>() : Game.Player.Inventory;

            var flashlight = inventory.GetItemOfType <Flashlight>();

            if (flashlight != null && flashlight.Battery == null)
            {
                flashlight.Battery = this;
            }
            base.PickUp();
        }
示例#11
0
        public GeneralKeybindingsWindow(int width, int height) : base(width, height)
        {
            Position = new Point(Constants.Windows.GeneralKeybindingsX, Constants.Windows.GeneralKeybindingsY);

            KeybindingManager.Initialize();

            Initialize();

            RefractoredDrawKeybindings();

            this.Parent = UserInterfaceManager.Get <KeybindingsWindow>();
        }
示例#12
0
 public static void Reset()
 {
     foreach (var inf in UserInterfaceManager.GetAll <IUserInterface>())
     {
         if (inf.Equals(UserInterfaceManager.Get <MainMenuWindow>()))
         {
             continue;
         }
         UserInterfaceManager.Remove(inf);
     }
     EntityManager.Clear();
     ItemManager.Clear();
 }
示例#13
0
        public static void Show()
        {
            foreach (var inf in UserInterfaceManager.GetAll <IUserInterface>())
            {
                if (inf.Equals(UserInterfaceManager.Get <GameOverWindow>()) ||
                    inf.Equals(UserInterfaceManager.Get <GameWindow>()))
                {
                    inf.IsVisible = true;
                    continue;
                }

                inf.IsVisible = false;
            }
        }
示例#14
0
        private static void Hide(SadConsole.Console transitionConsole)
        {
            var mainMenu = UserInterfaceManager.Get<MainMenuWindow>();
            if (mainMenu == null)
            {
                return;
            }

            mainMenu.IsVisible = false;
            mainMenu.IsFocused = false;
            mainMenu.IsCursorDisabled = true;

            Global.CurrentScreen = transitionConsole;
        }
示例#15
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.H))
            {
                ChopWood();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
            }

            return(false);
        }
示例#16
0
        private void OpenHelpWindow()
        {
            var helpWindow = UserInterfaceManager.Get <HelpWindow>();

            if (helpWindow == null)
            {
                helpWindow = new HelpWindow(Constants.Windows.HelpWidth, Constants.Windows.HelpHeight);
                UserInterfaceManager.Add(helpWindow);
                this.FullTransition(helpWindow);
            }
            else
            {
                this.FullTransition(helpWindow);
            }
        }
示例#17
0
        private static void Init()
        {
            // Initialize user interface
            UserInterfaceManager.Initialize();

            // Keep the dialog window in a global variable so we can check it in the game loop
            DialogWindow = UserInterfaceManager.Get <DialogWindow>();

            // Instantiate player in the middle of the map
            Player = EntityManager.Create <Player>(new Point(Constants.Map.Width / 2, Constants.Map.Height / 2));
            Player.RenderObject(UserInterfaceManager.Get <MapWindow>());

            // Show a tutorial dialog window.
            DialogWindow.ShowDialog("Tutorial", new string[] { "Welcome to Emberpoint.", "Press 'Enter' to continue." });
        }
示例#18
0
        public void ButtonPressPlay(object sender, EventArgs args)
        {
            // Initialize user interface
            UserInterfaceManager.Initialize();

            // Remove mainmenu and transition
            Transition(UserInterfaceManager.Get <GameWindow>().Console);

            // Keep the dialog window in a global variable so we can check it in the game loop
            Game.DialogWindow = UserInterfaceManager.Get <DialogWindow>();

            // Instantiate player in the middle of the map
            Game.Player = EntityManager.Create <Player>(GridManager.Grid.GetFirstCell(a => a.LightProperties.Brightness > 0f && a.CellProperties.Walkable).Position);
            Game.Player.Initialize();

            // Show a tutorial dialog window.
            Game.DialogWindow.ShowDialog("Tutorial", new string[] { "Welcome to Emberpoint.", "To turn on your flashlight, press 'F'.", "Press 'Enter' to continue." });
        }
示例#19
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            foreach (var keybinding in IndexedKeybindings)
            {
                if (info.IsKeyPressed(keybinding.Key))
                {
                    var player = EntityManager.Get <IEntity>(Game.GameSession.Player.ObjectId); // Todo: make gamesession player less accessible
                    EntityManager.TravelEntityToArea((Player)player, keybinding.ObjectId);
                    return(true);
                }
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
            }

            return(false);
        }
示例#20
0
        public static void Show()
        {
            var mainMenu = UserInterfaceManager.Get <MainMenuWindow>();

            if (mainMenu == null)
            {
                mainMenu = new MainMenuWindow(Constants.GameWindowWidth, Constants.GameWindowHeight);
                mainMenu.InitializeButtons();
                UserInterfaceManager.Add(mainMenu);
            }
            else
            {
                mainMenu.IsVisible        = true;
                mainMenu.IsFocused        = true;
                mainMenu.IsCursorDisabled = false;
            }
            Global.CurrentScreen = mainMenu;

            Game.Reset();
        }
示例#21
0
        private static void Update(GameTime gameTime)
        {
            if (_mainMenuWindow?.OptionsWindow != null && _mainMenuWindow.OptionsWindow.WaitingForAnyKeyPress)
            {
                if (Global.KeyboardState.KeysPressed.Any())
                {
                    _mainMenuWindow.OptionsWindow.ChangeKeybinding(Global.KeyboardState.KeysPressed.First().Key);
                }
            }

            if (!UserInterfaceManager.IsInitialized || UserInterfaceManager.IsPaused)
            {
                return;
            }

            if (Global.KeyboardState.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Enter))
            {
                UserInterfaceManager.Get <DialogWindow>().ShowNext();
            }
        }
示例#22
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            // TODO: SOMETIMES THROWS NULL REFERENCE
            if (UserInterfaceManager.Get <LocationKeybindingsWindow>().IndexedKeybindings != null)
            {
                foreach (var keybinding in UserInterfaceManager.Get <LocationKeybindingsWindow>().IndexedKeybindings)
                {
                    if (info.IsKeyPressed(keybinding.Key))
                    {
                        EntityManager.TravelEntityToLocation(Game.GameSession.Player, keybinding.ObjectId);
                        return(true);
                    }
                }
            }


            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Character)))
            {
                OpenCharacterWindow();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Inventory)))
            {
                OpenInventoryWindow();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Travel)))
            {
                OpenTravelWindow();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Chop)))
            {
                OpenChoppingWindow();
            }

            return(false);
        }
示例#23
0
        public static TitleWindow Show()
        {
            var titleWindow = UserInterfaceManager.Get <TitleWindow>();

            if (titleWindow == null)
            {
                titleWindow = new TitleWindow(Constants.Windows.TitleWidth, Constants.Windows.TitleHeight);
                UserInterfaceManager.Add(titleWindow);
            }
            else
            {
                titleWindow.IsVisible = true;
                titleWindow.IsFocused = true;
            }

            titleWindow.IsVisible = true;
            titleWindow.IsFocused = true;

            Global.CurrentScreen = titleWindow;

            return(titleWindow);
        }
示例#24
0
        private void AddStairsLogic(T cell, BlueprintTile tile)
        {
            string        stairsName = tile.Name.Equals("Stairs Up", StringComparison.OrdinalIgnoreCase) ? "Stairs Down" : "Stairs Up";
            Blueprint <T> blueprint  = tile.Name.Equals("Stairs Up", StringComparison.OrdinalIgnoreCase) ? StairsUpBlueprint : StairsDownBlueprint;

            // Initialize new blueprint with tracking of the previous
            GridManager.InitializeBlueprint(blueprint, true);

            // Make sure all entities are synced to correct blueprint
            EntityManager.MovePlayerToBlueprint(blueprint);

            // Move player
            var stairs = GridManager.Grid.GetCells(a => a.CellProperties.Name != null && a.CellProperties.Name.Equals(stairsName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (stairs == null)
            {
                throw new Exception($"[{GetType().Name}] No {stairsName} available for {tile.Name} at position: {cell.Position}");
            }

            GridManager.Grid.RenderObject(UserInterfaceManager.Get <MapWindow>());
            Game.Player.MoveTowards(stairs.Position, false, null, false);
            Game.Player.Initialize(false);
        }
示例#25
0
        public static void Reset()
        {
            UserInterfaceManager.IsInitialized = false;

            var skipInterfaces = new []
            {
                UserInterfaceManager.Get <MainMenuWindow>() as IUserInterface,
                UserInterfaceManager.Get <OptionsWindow>() as IUserInterface,
            };

            foreach (var inf in UserInterfaceManager.GetAll <IUserInterface>())
            {
                if (skipInterfaces.Contains(inf))
                {
                    continue;
                }
                UserInterfaceManager.Remove(inf);
            }

            Player = null;
            EntityManager.Clear();
            ItemManager.Clear();
        }
示例#26
0
 private void OpenTitleWindow()
 {
     this.FullTransition(UserInterfaceManager.Get <TitleWindow>());
 }
示例#27
0
 private void OpenInventoryWindow()
 {
     this.SwitchFocusMakeVisible(UserInterfaceManager.Get <InventoryWindow>());
 }
示例#28
0
 private void OpenCharacterWindow()
 {
     this.SwitchFocusMakeVisible(UserInterfaceManager.Get <CharacterWindow>());
 }
示例#29
0
 private void OpenTravelWindow()
 {
     this.SwitchFocusMakeVisible(UserInterfaceManager.Get <TravelWindow>());
 }
示例#30
0
 public void Initialize()
 {
     // Draw player on the map
     RenderObject(UserInterfaceManager.Get <MapWindow>());
 }