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();
        }
Exemple #2
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            bool keyHandled = false;

            // Simplified way to check if any key we care about is pressed and set movement direction.
            foreach (var key in _playerMovements.Keys)
            {
                var binding = KeybindingsManager.GetKeybinding(key);
                if (info.IsKeyPressed(binding))
                {
                    var moveDirection = _playerMovements[key];
                    MoveTowards(moveDirection);
                    keyHandled = true;
                    break;
                }
            }

            //If this will grow in the future, we may want to add a Dictionary<Keybindings, EmberItem>
            // to efficiently retrieve and activate items.
            if (info.IsKeyPressed(KeybindingsManager.GetKeybinding(Keybindings.Flashlight)))
            {
                var flashLight = Game.Player.Inventory.GetItemOfType <Flashlight>();
                flashLight?.Switch();
                keyHandled = true;
            }

            if (keyHandled)
            {
                return(true);
            }
            else
            {
                return(base.ProcessKeyboard(info));
            }
        }
Exemple #3
0
 public void CheckForMovementKeys()
 {
     foreach (var movementKey in _playerMovements.Keys
              .Where(key => Global.KeyboardState.IsKeyPressed(KeybindingsManager.GetKeybinding(key))))
     {
         var(x, y) = _playerMovements[movementKey];
         MoveTowards(Position.Translate(x, y));
     }
 }
Exemple #4
0
 public void CheckForInteractionKeys()
 {
     //If this will grow in the future, we may want to add a Dictionary<Keybindings, EmberItem>
     // to efficiently retrieve and activate items.
     if (Global.KeyboardState.IsKeyPressed(KeybindingsManager.GetKeybinding(Keybindings.Flashlight)))
     {
         var flashLight = Game.Player.Inventory.GetItemOfType <Flashlight>();
         flashLight?.Switch();
     }
 }
        public override bool ProcessKeyboard(Keyboard info)
        {
            var baseValue = base.ProcessKeyboard(info);

            if (_textInput.DisableKeyboard && info.IsKeyPressed(KeybindingsManager.GetKeybinding(Keybindings.DeveloperConsole)))
            {
                if (IsVisible)
                {
                    Hide();
                }
                else
                {
                    Show();
                }
                return(true);
            }

            // Check for enter key press
            for (int i = 0; i < info.KeysPressed.Count; i++)
            {
                if (info.KeysPressed[i].Key == Microsoft.Xna.Framework.Input.Keys.Enter && _textInputInUse)
                {
                    if (!ParseCommand(_textInput.Text, out string output) && !string.IsNullOrWhiteSpace(output))
                    {
                        WriteText(output, Color.Red);
                    }
                    else
                    {
                        WriteText(output, Color.Green);
                    }

                    // Empty textfield but make sure we can keep typing
                    _textInput.Text            = string.Empty;
                    _textInput.DisableKeyboard = false;
                    return(true);
                }
            }

            return(baseValue);
        }
Exemple #6
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            bool keyHandled = false;

            // Simplified way to check if any key we care about is pressed and set movement direction.
            foreach (var key in _playerMovements.Keys)
            {
                var binding = KeybindingsManager.GetKeybinding(key);
                if (info.IsKeyPressed(binding))
                {
                    var moveDirection = _playerMovements[key];
                    _interaction.PrintMessage(Constants.EmptyMessage);
                    MoveTowards(moveDirection);
                    InteractionStatus = CheckInteraction(_interaction);
                    keyHandled        = true;
                    break;
                }
            }

            // Handle cell interactions
            if (info.IsKeyPressed(KeybindingsManager.GetKeybinding(Keybindings.Interact)) &&
                InteractionStatus && GetInteractedCell(out Point position))
            {
                interactionManager.HandleInteraction(position);
                keyHandled = true;
            }

            //If this will grow in the future, we may want to add a Dictionary<Keybindings, EmberItem>
            // to efficiently retrieve and activate items.
            if (info.IsKeyPressed(KeybindingsManager.GetKeybinding(Keybindings.Flashlight)))
            {
                var flashLight = Game.Player.Inventory.GetItemOfType <Flashlight>();
                flashLight?.Switch();
                keyHandled = true;
            }

            // Handle dialog window
            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Enter))
            {
                var devConsole = UserInterfaceManager.Get <DeveloperWindow>();
                if (!devConsole.IsVisible)
                {
                    var dialogWindow = UserInterfaceManager.Get <DialogWindow>();
                    if (dialogWindow.IsVisible)
                    {
                        dialogWindow.ShowNext();
                        keyHandled = true;
                    }
                }
            }

            // Handle dev console showing
            if (info.IsKeyPressed(KeybindingsManager.GetKeybinding(Keybindings.DeveloperConsole)))
            {
                var devConsole = UserInterfaceManager.Get <DeveloperWindow>();
                if (devConsole.IsVisible)
                {
                    devConsole.Hide();
                }
                else
                {
                    devConsole.Show();
                }
                keyHandled = true;
            }

            if (keyHandled)
            {
                return(true);
            }
            else
            {
                return(base.ProcessKeyboard(info));
            }
        }