//------------------------------------------------------------------------------------------------------------------------
        //                                                  ShopBrowseState()
        //------------------------------------------------------------------------------------------------------------------------
        public ShopBrowseState(List <Item> items, Actor pCustumer)
        {
            //create shop
            ShopModel shop = new ShopModel(items);

            //create controller
            _shopController = new ShopController(shop);


            //create shop view
            _shopView = new ShopView(_shopController, pCustumer);
            _shopView.Subscribe(shop);
            AddChild(_shopView);
            Helper.AlignToCenter(_shopView, true, true);

            //create item info view
            _itemInfoView = new ItemInfoView();
            _itemInfoView.Subscribe(shop);
            AddChild(_itemInfoView);


            //create message view
            _shopMessageView = new ShopMessageView();
            _shopMessageView.Subscribe(shop);
            AddChild(_shopMessageView);
            Helper.AlignToCenter(_shopMessageView, true, false);
        }
Exemple #2
0
        public async Task <ActionResult <ItemInfoView> > Get(int id)
        {
            Item item = await _db.Items
                        .Include(x => x.QuestItems)
                        .ThenInclude(x => x.Quest)
                        .Include(x => x.QuestItems)
                        .ThenInclude(x => x.StartingNpc)
                        .FirstOrDefaultAsync(x => x.Id == id);

            if (item == null)
            {
                return(NotFound());
            }
            var itemInfo = new ItemInfoView
            {
                Item = new Item
                {
                    AmountReady = item.AmountReady,
                    Description = item.Description,
                    Id          = item.Id,
                    ItemType    = item.ItemType,
                    PictureLink = item.PictureLink,
                    Name        = item.Name,
                },
                QuestItems = item.QuestItems.Select(x => new QuestItem
                {
                    AmountNeeded             = x.AmountNeeded,
                    Id                       = x.Id,
                    IsReady                  = x.IsReady,
                    IsTechnicalDocumentReady = x.IsTechnicalDocumentReady,
                    TechnicalDocumentForNpc  = x.TechnicalDocumentForNpc,
                    Quest                    = new Quest
                    {
                        Id   = x.QuestId,
                        Name = x.Quest.Name,
                    },
                    StartingNpc = new Npc
                    {
                        Id   = x.StartingNpcId,
                        Name = x.StartingNpc.Name,
                    },
                    Item = new Item
                    {
                        Id          = x.ItemId,
                        Name        = x.Item.Name,
                        PictureLink = x.Item.PictureLink,
                    },
                }).ToList(),
            };

            return(new ObjectResult(itemInfo));
        }
Exemple #3
0
            public InventorySingleView(InventoryView parent, Inventory inventory, Vector2 size)
                : base(size)
            {
                myInventoryView = parent;

                Inventory = inventory;

                mySlots = new SlotButton[Inventory.Capacity];

                InventorySlot[] slots = Inventory.Slots;

                int x = 0, y = 0;
                int cols = (int)((size.X - 4.0f) / 44.0f);

                for (int i = 0; i < mySlots.Length; ++i)
                {
                    SlotButton btn = new SlotButton(slots[i])
                    {
                        Position = new Vector2(x * 44.0f + 4.0f, y * 44.0f + 4.0f)
                    };
                    mySlots[i] = btn;

                    btn.Click += delegate(object sender, MouseButtonEventArgs e)
                    {
                        if (SlotButtonClicked != null)
                        {
                            SlotButtonClicked(sender, new SlotButtonClickedEventArgs(Inventory, (sender as SlotButton).Slot));
                        }
                    };

                    btn.MouseUp += delegate(object sender, MouseButtonEventArgs e)
                    {
                        if (myInventoryView.IsDraggingItem)
                        {
                            myInventoryView.StopDraggingItem(btn);
                        }
                    };

                    btn.MouseEnter += delegate(object sender, MouseMoveEventArgs e)
                    {
                        if (btn.Slot.HasItem && !myInventoryView.IsDraggingItem && (ItemView == null || ItemView.Item != btn.Slot.Item))
                        {
                            if (ItemView != null)
                            {
                                Parent.RemoveChild(ItemView);
                            }

                            ItemView          = new ItemInfoView(btn);
                            ItemView.Flipped  = Parent.Parent.MousePosition.X + 224.0f > Parent.Parent.InnerWidth;
                            ItemView.Position = Parent.MousePosition + new Vector2(ItemView.Flipped ? -208.0f : 16.0f, 0.0f);
                            Parent.AddChild(ItemView);
                        }
                    };

                    btn.MouseMove += delegate(object sender, MouseMoveEventArgs e)
                    {
                        if (btn.Slot.HasItem && ItemView != null && ItemView.Item == btn.Slot.Item)
                        {
                            ItemView.Flipped  = Parent.Parent.MousePosition.X + 224.0f > Parent.Parent.InnerWidth;
                            ItemView.Position = Parent.MousePosition + new Vector2(ItemView.Flipped ? -208.0f : 16.0f, 0.0f);
                        }
                    };

                    btn.MouseLeave += delegate(object sender, MouseMoveEventArgs e)
                    {
                        if (btn.Slot.HasItem && ItemView != null && ItemView.Item == btn.Slot.Item)
                        {
                            Parent.RemoveChild(ItemView);
                            ItemView = null;
                        }

                        if (btn.MouseButtonPressed && btn.Slot.HasItem)
                        {
                            myInventoryView.StartDraggingItem(btn);
                        }
                    };

                    btn.Slot.SlotContentsChanged += delegate(object sender, EventArgs e)
                    {
                        if (ItemView != null && ItemView.Button == btn && btn.Slot.Item != ItemView.Item)
                        {
                            Parent.RemoveChild(ItemView);
                            ItemView = null;

                            if (btn.IsEnabled && btn.Slot.HasItem)
                            {
                                ItemView          = new ItemInfoView(btn);
                                ItemView.Flipped  = Parent.Parent.MousePosition.X + 224.0f > Parent.Parent.InnerWidth;
                                ItemView.Position = Parent.MousePosition + new Vector2(ItemView.Flipped ? -208.0f : 16.0f, 0.0f);
                                Parent.AddChild(ItemView);
                            }
                        }
                    };

                    AddChild(btn);

                    ++x;
                    if (x >= cols)
                    {
                        x = 0;
                        ++y;
                    }
                }
            }
Exemple #4
0
 public void Refresh(Hero hero, ItemInfoView itemInfo)
 {
     _currentHero = hero;
     _itemInfo    = itemInfo;
 }