Esempio n. 1
0
 private void ButtonSinglePlayer_Click(object sender, RoutedEventArgs e)
 {
     var placement = this.GetPlacement();
     GameWindow gameWindow = new GameWindow(this._loginData, placement, GameMode.Singleplayer);
     gameWindow.Show();
     this.Close();
 }
        public LoadingScreen(GameOptions options)
        {
            InitializeComponent();

            Window gameWindow = new GameWindow(options);
            gameWindow.Show();
            this.Hide();
        }
Esempio n. 3
0
        public ListSelection(GameWindow window, IEnumerable<INamedItem> items, string title)
        {
            InitializeComponent();

            DismissOnSelection = true;
            Title = title;

            window.DisableFocusPopup();
            Closed += (o, e) => { window.EnableFocusPopup(); };

            List.ItemsSource = items;
            if (items.Count() > 0)
                List.SelectedIndex = 0;
            Focus();
        }
Esempio n. 4
0
 GameController(GameWindow gw)
 {
 }
 private void PlayGame()
 {
     if(SelectedQuiz.VragenLijst != null){
         if (SelectedQuiz.VragenLijst.Count > 1)
         {
             GetVraag();
             addGameWindow = new GameWindow();
             addGameWindow.Show();
         }
         else
         {
             MessageBox.Show("Quiz moet minstens 2 vragen bevatten!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
 private static void HandleDirection(Direction direction, Map map, GameWindow window, IGameEngine engine)
 {
     if (!map.InTargettingMode)
     {
         if (Keyboard.Modifiers != ModifierKeys.Shift)
         {
             engine.Actions.Move(direction);
             window.UpdateWorld();
         }
         else
         {
             RunningKeyboardHandler runner = new RunningKeyboardHandler(window, engine);
             runner.StartRunning(direction);
         }
     }
     else
     {
         throw new InvalidOperationException("DefaultKeyboardHandler and Map disagree on current state");
     }
 }
 private static void OnRunTargetSelected(GameWindow window, IGameEngine engine, MageCrawlPoint point)
 {
     window.Map.InTargettingMode = false;
     RunningKeyboardHandler runner = new RunningKeyboardHandler(window, engine);
     runner.StartRunning(point);
 }
        public void OnKeyboardDown(MagecrawlKey key, Map map, GameWindow window, IGameEngine engine)
        {
            // TODO - This switch is unfortunate and too large...
            switch (key)
            {
                case MagecrawlKey.LessThan:
                {
                    HandleStairs(m_engine.Actions.MoveUpStairs);
                    break;
                }
                case MagecrawlKey.GreaterThan:
                {
                    HandleStairs(m_engine.Actions.MoveDownStairs);
                    break;
                }
                case MagecrawlKey.Q:
                {
                    string text = "Quitting the game will delete your current character. To stop playing now and continue your adventure later, use save instead.";
                    TwoButtonDialog d = new TwoButtonDialog(window, text);
                    d.Closed += (o, e) =>
                    {
                        if (((TwoButtonDialog)o).DialogResult == true)
                        {
                            // Do quit here? How do you quit SL? go back to main menu?
                        }
                    };

                    d.Show();
                    break;
                }
                case MagecrawlKey.S:
                {
                    string text = "Saving the game will end your current session and allow you to pickup playing later.";
                    TwoButtonDialog d = new TwoButtonDialog(window, text);
                    d.Closed += (o, e) =>
                    {
                        if (((TwoButtonDialog)o).DialogResult == true)
                        {
                            m_engine.Save();
                            // Do quit here? How do you quit SL? go back to main menu?
                        }
                    };

                    d.Show();
                    break;
                }
                case MagecrawlKey.a:
                {
                    if (m_engine.Player.CurrentWeapon.IsRanged && !m_engine.Player.CurrentWeapon.IsLoaded)
                    {
                        m_engine.Actions.ReloadWeapon();
                        window.MessageBox.AddMessage(string.Format("{0} reloads the {1}.", m_engine.Player.Name, m_engine.Player.CurrentWeapon.DisplayName));
                    }
                    else
                    {
                        List<EffectivePoint> targetPoints = m_engine.GameState.CalculateTargetablePointsForEquippedWeapon();
                        OnTargetSelect selectionDelegate = (w, e, p) => 
                        {
                            if (p != m_engine.Player.Position)
                                m_engine.Actions.Attack(p);
                        };
                        TargettingModeKeyboardHandler handler = new TargettingModeKeyboardHandler(TargettingModeKeyboardHandler.TargettingType.Monster, engine, m_map, selectionDelegate, targetPoints);
                        window.SetKeyboardHandler(handler.OnKeyboardDown);
                    }
                    break;
                }
                case MagecrawlKey.o:
                {
                    List<EffectivePoint> operatePoints = CalculateOperatePoints();
                    TargettingModeKeyboardHandler handler = new TargettingModeKeyboardHandler(TargettingModeKeyboardHandler.TargettingType.Operatable, engine, m_map, (w,e,p) => m_engine.Actions.Operate(p), operatePoints);
                    window.SetKeyboardHandler(handler.OnKeyboardDown);
                    break;
                }
                case MagecrawlKey.v:
                {
                    TargettingModeKeyboardHandler handler = new TargettingModeKeyboardHandler(TargettingModeKeyboardHandler.TargettingType.None, engine, m_map, null);
                    m_map.UseViewCursor = true;                    
                    window.SetKeyboardHandler(handler.OnKeyboardDown);
                    break;
                }
                case MagecrawlKey.A:
                {
                    TargettingModeKeyboardHandler handler = new TargettingModeKeyboardHandler(TargettingModeKeyboardHandler.TargettingType.None, engine, m_map, OnRunTargetSelected, null);
                    window.SetKeyboardHandler(handler.OnKeyboardDown);
                    break;
                }
                case MagecrawlKey.i:
                {
                    ListSelection listSelection = new ListSelection(window, engine.Player.Items.OfType<INamedItem>(), "Inventory");
                    listSelection.SelectionDelegate = i =>
                    {
                        ItemSelection.OnSelection onItemSelection = (item, option) =>
                        {
                            TargetingInfo targetInfo = m_engine.Targetting.GetTargettingTypeForInventoryItem(item, option);
                            HandleInvoke(targetInfo, p => m_engine.Actions.SelectedItemOption(item, option, p), item);
                        };

                        ItemSelection selection = new ItemSelection(engine, (IItem)i, onItemSelection);
                        selection.ParentWindow = listSelection;
                        selection.Show();
                    };
                    listSelection.DismissOnSelection = false;
                    listSelection.Show();
                    break;
                }
                case MagecrawlKey.z:
                {
                    ListSelection listSelection = new ListSelection(window, engine.Player.Spells.OfType<INamedItem>(), "Spellbook");
                    listSelection.SelectionDelegate = s =>
                    {
                        TargetingInfo targetInfo = ((ISpell)s).Targeting;
                        HandleInvoke(targetInfo, p => m_engine.Actions.CastSpell((ISpell)s, p), s);
                    };

                    listSelection.Show();
                    break;
                }
                case MagecrawlKey.E:
                {
                    ListSelection listSelection = new ListSelection(window, engine.Player.StatusEffects.OfType<INamedItem>(), "Dismiss Effect");
                    listSelection.SelectionDelegate = i => engine.Actions.DismissEffect(i.DisplayName);
                    listSelection.Show();
                    break;
                }
                case MagecrawlKey.Comma:
                {
                    List<INamedItem> itemsAtLocation = engine.Map.Items.Where(i => i.Second == engine.Player.Position).Select(i => i.First).OfType<INamedItem>().ToList();
                    if (itemsAtLocation.Count > 1)
                    {
                        ListSelection listSelection = new ListSelection(window, itemsAtLocation, "Pickup Item");
                        listSelection.SelectionDelegate = i => engine.Actions.GetItem((IItem)i);
                        listSelection.Show();
                    }
                    else
                    {
                        engine.Actions.GetItem();
                        window.UpdateWorld();
                    }
                    break;
                }
                case MagecrawlKey.Backquote:
                {
                    engine.Actions.SwapPrimarySecondaryWeapons();
                    window.UpdateWorld();
                    break;
                }
                case MagecrawlKey.Period:
                {
                    engine.Actions.Wait();
                    window.UpdateWorld();
                    break;
                }
                case MagecrawlKey.PageUp:
                {
                    window.MessageBox.PageUp();
                    break;
                }
                case MagecrawlKey.PageDown:
                {
                    window.MessageBox.PageDown();
                    break;
                }
                case MagecrawlKey.Backspace:
                {
                    window.MessageBox.Clear();
                    break;
                }
                case MagecrawlKey.Left:
                    HandleDirection(Direction.West, m_map, window, engine);
                    break;
                case MagecrawlKey.Right:
                    HandleDirection(Direction.East, m_map, window, engine);
                    break;
                case MagecrawlKey.Down:
                    HandleDirection(Direction.South, m_map, window, engine);
                    break;
                case MagecrawlKey.Up:
                    HandleDirection(Direction.North, m_map, window, engine);
                    break;
                case MagecrawlKey.Insert:
                    HandleDirection(Direction.Northwest, m_map, window, engine);
                    break;
                case MagecrawlKey.Delete:
                    HandleDirection(Direction.Southwest, m_map, window, engine);
                    break;
                case MagecrawlKey.Home:
                    HandleDirection(Direction.Northeast, m_map, window, engine);
                    break;
                case MagecrawlKey.End:
                    HandleDirection(Direction.Southeast, m_map, window, engine);
                    break;
            }
        }
 public DefaultKeyboardHandler(GameWindow window, IGameEngine engine, Map map)
 {
     m_window = window;
     m_engine = engine;
     m_map = map;
 }
Esempio n. 10
0
        private void LaunchGame( Object filler = null )
        {
            // ROBIN: I previously attempted to pass the Client object to the GameWindow's constructor. As a result (for an unknown reason),
            // the Client's callback messages were not registering. Therefore, each client is disconnected from the server before launching the game.
            // A new Client object is created and connected to the server when the GameWindow is constructed.
            Client.Disconnect("Bye");
            Client.UnregisterReceivedCallback(this.Callback);
            this.Disconnected = true;

            GameWindow gameWindow = new GameWindow(this.Player.Name, this.ServerIP, this.Turn);
            gameWindow.Show();
            this.Close();
        }