Inheritance: System.Windows.Window
        void DropItemHandler(object sender, ExecutedRoutedEventArgs e)
        {
            var living = m_mainWindow.FocusedObject;

            if (living == null)
                return;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = m_mainWindow;
            dlg.DataContext = living.Inventory;
            dlg.Title = "Drop Item";

            var ret = dlg.ShowDialog();

            if (ret.HasValue && ret.Value == true)
            {
                var ob = dlg.SelectedItem;

                var action = new DropItemAction(ob);
                action.MagicNumber = 1;
                living.RequestAction(action);
            }

            e.Handled = true;
        }
        private void GetButton_Click(object sender, RoutedEventArgs e)
        {
            var living = (LivingObject)this.DataContext;

            var obs = living.Environment.GetContents(living.Location).OfType<ItemObject>();

            var dlg = new ItemSelectorDialog();
            dlg.DataContext = obs;
            var b = dlg.ShowDialog();

            if (!b.HasValue || b.Value == false)
                return;

            var action = new GetItemAction((ItemObject)dlg.SelectedItem);
            AddAction(action);
        }
示例#3
0
        private void GetButton_Click(object sender, RoutedEventArgs e)
        {
            var living = (LivingObject)this.DataContext;

            var obs = living.Environment.GetContents(living.Location).OfType <ItemObject>();

            var dlg = new ItemSelectorDialog();

            dlg.DataContext = obs;
            var b = dlg.ShowDialog();

            if (!b.HasValue || b.Value == false)
            {
                return;
            }

            var action = new GetItemAction((ItemObject)dlg.SelectedItem);

            AddAction(action);
        }
示例#4
0
        static void HandleBuildItem(string str)
        {
            var living = GameData.Data.FocusedObject;

            var workbench = living.Environment.GetContents(living.Location).OfType<ItemObject>()
                .Where(item => item.ItemCategory == ItemCategory.Workbench && item.IsInstalled)
                .FirstOrDefault();

            if (workbench == null)
            {
                Inform("No workbench");
                return;
            }

            var wbInfo = Workbenches.GetWorkbenchInfo(workbench.ItemID);

            BuildableItem buildableItem;

            {
                var dlg = new ItemSelectorDialog();
                dlg.Owner = App.Current.MainWindow;
                dlg.DataContext = wbInfo.BuildableItems;
                dlg.Title = "Buildable Items";
                bool? res = dlg.ShowDialog();

                if (res.HasValue == false || res == false)
                    return;

                buildableItem = (BuildableItem)dlg.SelectedItem;
            }

            foreach (var component in buildableItem.FixedBuildMaterials)
            {
                var obs = living.Inventory.Where(item => component.Match(item));

                if (obs.Any() == false)
                {
                    Inform("Missing required components");
                    return;
                }
            }

            List<ItemObject> materials = new List<ItemObject>();

            foreach (var component in buildableItem.FixedBuildMaterials)
            {
                var obs = living.Inventory.Where(item => component.Match(item));

                var dlg = new ItemSelectorDialog();
                dlg.Owner = App.Current.MainWindow;
                dlg.DataContext = obs;
                dlg.Title = "Select component";
                bool? res = dlg.ShowDialog();
                if (res.HasValue == false || res == false)
                    return;
                materials.Add((ItemObject)dlg.SelectedItem);
            }

            var action = new BuildItemAction(workbench, buildableItem.Key, materials);
            action.GUID = new ActionGUID(living.World.PlayerID, 0);
            living.RequestAction(action);
        }
示例#5
0
        static void HandleWearItem(string str)
        {
            var living = GameData.Data.FocusedObject;

            var obs = living.Inventory
                .Where(o => ((o.IsArmor || o.IsWeapon) && o.IsEquipped == false));

            if (obs.Any() == false)
                return;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = App.Current.MainWindow;
            dlg.DataContext = obs;
            dlg.Title = "Wear/Wield Item";

            var ret = dlg.ShowDialog();

            if (ret.HasValue && ret.Value == true)
            {
                var ob = (ItemObject)dlg.SelectedItem;

                GameAction action;
                if (ob.IsArmor || ob.IsWeapon)
                    action = new EquipItemAction(ob);
                else
                    throw new Exception();
                action.GUID = new ActionGUID(living.World.PlayerID, 0);
                living.RequestAction(action);
            }
        }
示例#6
0
        static void HandleInventory(string str)
        {
            var living = GameData.Data.FocusedObject;

            var obs = living.Inventory;

            if (obs.Any() == false)
                return;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = App.Current.MainWindow;
            dlg.DataContext = obs;
            dlg.Title = "Inventory";

            dlg.ShowDialog();
        }
示例#7
0
        static void HandleGetItem(string str)
        {
            var living = GameData.Data.FocusedObject;

            var obs = living.Environment.GetContents(living.Location).OfType<ItemObject>();

            if (obs.Any() == false)
                return;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = App.Current.MainWindow;
            dlg.DataContext = obs;
            dlg.Title = "Get Item";

            var ret = dlg.ShowDialog();

            if (ret.HasValue && ret.Value == true)
            {
                var ob = (ItemObject)dlg.SelectedItem;

                var action = new GetItemAction(ob);
                action.GUID = new ActionGUID(living.World.PlayerID, 0);
                living.RequestAction(action);
            }
        }
示例#8
0
        static void HandleDropItem(string str)
        {
            var living = GameData.Data.FocusedObject;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = App.Current.MainWindow;
            dlg.DataContext = living.Inventory;
            dlg.Title = "Drop Item";

            var ret = dlg.ShowDialog();

            if (ret.HasValue && ret.Value == true)
            {
                var ob = (ItemObject)dlg.SelectedItem;

                var action = new DropItemAction(ob);
                action.GUID = new ActionGUID(living.World.PlayerID, 0);
                living.RequestAction(action);
            }
        }
        void GetItemHandler(object sender, ExecutedRoutedEventArgs e)
        {
            var living = m_mainWindow.FocusedObject;

            if (living == null)
                return;

            var obs = living.Environment.GetContents(living.Location).OfType<ItemObject>();

            if (obs.Any() == false)
                return;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = m_mainWindow;
            dlg.DataContext = obs;
            dlg.Title = "Get Item";

            var ret = dlg.ShowDialog();

            if (ret.HasValue && ret.Value == true)
            {
                var ob = dlg.SelectedItem;

                var action = new GetItemAction(ob);
                action.MagicNumber = 1;
                living.RequestAction(action);
            }

            e.Handled = true;
        }
        void WearItemHandler(object sender, ExecutedRoutedEventArgs e)
        {
            var living = m_mainWindow.FocusedObject;

            if (living == null)
                return;

            var obs = living.Inventory.OfType<ItemObject>()
                .Where(o => ((o.IsArmor || o.IsWeapon) && o.IsEquipped == false));

            if (obs.Any() == false)
                return;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = m_mainWindow;
            dlg.DataContext = obs;
            dlg.Title = "Wear/Wield Item";

            var ret = dlg.ShowDialog();

            if (ret.HasValue && ret.Value == true)
            {
                var ob = dlg.SelectedItem;

                GameAction action;
                if (ob.IsArmor || ob.IsWeapon)
                    action = new EquipItemAction(ob);
                else
                    throw new Exception();
                action.MagicNumber = 1;
                living.RequestAction(action);
            }

            e.Handled = true;
        }
        void InventoryHandler(object sender, ExecutedRoutedEventArgs e)
        {
            var living = m_mainWindow.FocusedObject;

            if (living == null)
                return;

            var obs = living.Inventory;

            if (obs.Any() == false)
                return;

            var dlg = new ItemSelectorDialog();
            dlg.Owner = m_mainWindow;
            dlg.DataContext = obs;
            dlg.Title = "Inventory";

            dlg.ShowDialog();
        }