Exemple #1
0
        public override void UpdateLayout(object sender, UpdateEventArgs e)
        {
            if (MapToRender != null)
            {
                MapToRender.CalculateFOVIfNeeded(ApprenticeGame.Player.Position, 10, Radius.CIRCLE);
            }

            base.UpdateLayout(sender, e);

            // Print messages, if necessary, on top of everything
            if (splitMessages.Count != 0)
            {
                string message = (splitMessages.Count > 1) ? splitMessages[0] + MORE_SYMBOL : splitMessages[0];
                console.Print(MESSAGE_X, MESSAGE_Y, message, RLColor.White);
            }
        }
Exemple #2
0
        protected override void OnKeyPress(object sender, KeyPressEventArgs e)
        {
            if (splitMessages.Count != 0) // Any input goes to next message
            {
                splitMessages.RemoveAt(0);
            }
            else
            {
                Direction dirToMove = Direction.NONE;
                switch (Input.ActionFor(e.KeyPress))
                {
                case InputAction.UP:
                    dirToMove = Direction.UP;
                    e.Cancel  = true;
                    break;

                case InputAction.UP_RIGHT:
                    dirToMove = Direction.UP_RIGHT;
                    e.Cancel  = true;
                    break;

                case InputAction.RIGHT:
                    dirToMove = Direction.RIGHT;
                    e.Cancel  = true;
                    break;

                case InputAction.DOWN_RIGHT:
                    dirToMove = Direction.DOWN_RIGHT;
                    e.Cancel  = true;
                    break;

                case InputAction.DOWN:
                    dirToMove = Direction.DOWN;
                    e.Cancel  = true;
                    break;

                case InputAction.DOWN_LEFT:
                    dirToMove = Direction.DOWN_LEFT;
                    e.Cancel  = true;
                    break;

                case InputAction.LEFT:
                    dirToMove = Direction.LEFT;
                    e.Cancel  = true;
                    break;

                case InputAction.UP_LEFT:
                    dirToMove = Direction.UP_LEFT;
                    e.Cancel  = true;
                    break;

                case InputAction.DOWN_STAIR:
                    // Check for stairy-stuff.  Probably need to split this off, teleporter may go away since direction would be diff (Up gate vs down-gate would be seperate classes).
                    foreach (var gObject in MapToRender.ObjectsAt(ApprenticeGame.Player.Position))
                    {
                        if (gObject is Teleporter teleporter)
                        {
                            teleporter.Traverse(ApprenticeGame.Player);
                            e.Cancel = true;
                            break;
                        }
                    }
                    break;

                case InputAction.ACTIVATE:     // Activate top layer of whatever is below us, if something can be activated
                    int          topLayer    = (int)Map.Layer.Terrain;
                    IActivatable activatable = null;
                    foreach (var gObj in MapToRender.ObjectsAt(ApprenticeGame.Player.Position))
                    {
                        if (gObj is IActivatable activate && (int)gObj.Layer >= topLayer)
                        {
                            topLayer    = (int)gObj.Layer;
                            activatable = activate;
                        }
                    }

                    if (activatable != null)
                    {
                        activatable.Activate();
                        e.Cancel = true;
                    }
                    break;

                case InputAction.SPELLS_SCREEN:
                    ApprenticeGame.GameScreen.Hide();
                    ApprenticeGame.SpellsPanel.Show();
                    e.Cancel = true;
                    break;

                case InputAction.MESSAGE_RECALL_SCREEN:
                    ApprenticeGame.GameScreen.Hide();
                    ApprenticeGame.MessageRecallPanel.Show();
                    e.Cancel = true;
                    break;
                }


                if (dirToMove != Direction.NONE)
                {
                    if (!ApprenticeGame.Player.MoveIn(dirToMove))
                    {
                        ApprenticeGame.Player.Combat.AttackIn(dirToMove);
                    }
                }
            }
        }