Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
        }