Пример #1
0
        public bool CanWear(WearPlace selectedWear, Item item)
        {
            if (item == null)
            {
                return(true);
            }
            switch (selectedWear)
            {
            case WearPlace.LeftHand: return(item.ItemClass == ItemClass.Shield);

            case WearPlace.RightHand:
                return(item.ItemClass == ItemClass.Weapon ||
                       item.ItemClass == ItemClass.Block ||
                       item.ItemClass == ItemClass.Other);

            case WearPlace.MainArmor: return(item.ItemClass == ItemClass.MainArmor);

            case WearPlace.Boots: return(item.ItemClass == ItemClass.Boots);

            case WearPlace.Helmet: return(item.ItemClass == ItemClass.Helmet);

            case WearPlace.Gauntlet: return(item.ItemClass == ItemClass.Gauntlet);

            default: throw new Exception();
            }
        }
Пример #2
0
        public Item ItemAtWearPlace(WearPlace wearPlace, int activeMaterial)
        {
            switch (wearPlace)
            {
            case WearPlace.LeftHand: return(d_Inventory.LeftHand[activeMaterial]);

            case WearPlace.RightHand: return(d_Inventory.RightHand[activeMaterial]);

            case WearPlace.MainArmor: return(d_Inventory.MainArmor);

            case WearPlace.Boots: return(d_Inventory.Boots);

            case WearPlace.Helmet: return(d_Inventory.Helmet);

            case WearPlace.Gauntlet: return(d_Inventory.Gauntlet);

            default: throw new Exception();
            }
        }
Пример #3
0
        public void SetItemAtWearPlace(WearPlace wearPlace, int activeMaterial, Item item)
        {
            switch (wearPlace)
            {
            case WearPlace.LeftHand: d_Inventory.LeftHand[activeMaterial] = item; break;

            case WearPlace.RightHand: d_Inventory.RightHand[activeMaterial] = item; break;

            case WearPlace.MainArmor: d_Inventory.MainArmor = item; break;

            case WearPlace.Boots: d_Inventory.Boots = item; break;

            case WearPlace.Helmet: d_Inventory.Helmet = item; break;

            case WearPlace.Gauntlet: d_Inventory.Gauntlet = item; break;

            default: throw new Exception();
            }
        }
Пример #4
0
 public bool CanWear(WearPlace selectedWear, Item item)
 {
     if (item == null) { return true; }
     switch (selectedWear)
     {
         case WearPlace.LeftHand: return item.ItemClass == ItemClass.Shield;
         case WearPlace.RightHand:
             return item.ItemClass == ItemClass.Weapon
                 || item.ItemClass == ItemClass.Block
                 || item.ItemClass == ItemClass.Other;
         case WearPlace.MainArmor: return item.ItemClass == ItemClass.MainArmor;
         case WearPlace.Boots: return item.ItemClass == ItemClass.Boots;
         case WearPlace.Helmet: return item.ItemClass == ItemClass.Helmet;
         case WearPlace.Gauntlet: return item.ItemClass == ItemClass.Gauntlet;
         default: throw new Exception();
     }
 }
Пример #5
0
        public void Draw()
        {
            Point scaledMouse = mouse_current.MouseCurrent;

            the3d.Draw2dBitmapFile("inventory.png", InventoryStart.X, InventoryStart.Y, 512, 1024);

            //the3d.Draw2dTexture(terrain, 50, 50, 50, 50, 0);
            //the3d.Draw2dBitmapFile("inventory_weapon_shovel.png", 100, 100, 60 * 2, 60 * 4);
            //the3d.Draw2dBitmapFile("inventory_gauntlet_gloves.png", 200, 200, 60 * 2, 60 * 2);
            //main inventory
            foreach (var k in inventory.Items)
            {
                DrawItem(new Point(CellsStart.X + k.Key.X * CellDrawSize, CellsStart.Y + k.Key.Y * CellDrawSize), k.Value, null);
            }

            //draw area selection
            if (inventory.DragDropItem != null)
            {
                Point?selected = SelectedCell(scaledMouse);
                if (selected != null)
                {
                    int   x    = (selected.Value.X) * CellDrawSize + CellsStart.X;
                    int   y    = (selected.Value.Y) * CellDrawSize + CellsStart.Y;
                    Point size = dataItems.ItemSize(inventory.DragDropItem);
                    if (selected.Value.X + size.X <= CellCount.X &&
                        selected.Value.Y + size.Y <= CellCount.Y)
                    {
                        Color   c;
                        Point[] itemsAtArea = inventoryUtil.ItemsAtArea(selected.Value, size);
                        if (itemsAtArea == null || itemsAtArea.Length > 1)
                        {
                            c = Color.Red;
                        }
                        else //0 or 1
                        {
                            c = Color.Green;
                        }
                        the3d.Draw2dTexture(the3d.WhiteTexture(), x, y,
                                            CellDrawSize * size.X, CellDrawSize * size.Y,
                                            null, Color.FromArgb(100, c));
                    }
                }
                WearPlace?selectedWear = SelectedWearPlace(scaledMouse);
                if (selectedWear != null)
                {
                    Point p    = Offset(wearPlaceStart[(int)selectedWear], InventoryStart);
                    Point size = wearPlaceCells[(int)selectedWear];

                    Color c;
                    Item  itemsAtArea = inventoryUtil.ItemAtWearPlace(selectedWear.Value, ActiveMaterial.ActiveMaterial);
                    if (!dataItems.CanWear(selectedWear.Value, inventory.DragDropItem))
                    {
                        c = Color.Red;
                    }
                    else //0 or 1
                    {
                        c = Color.Green;
                    }
                    the3d.Draw2dTexture(the3d.WhiteTexture(), p.X, p.Y,
                                        CellDrawSize * size.X, CellDrawSize * size.Y,
                                        null, Color.FromArgb(100, c));
                }
            }

            //material selector
            DrawMaterialSelector();

            //wear
            DrawItem(Offset(wearPlaceStart[(int)WearPlace.LeftHand], InventoryStart), inventory.LeftHand[ActiveMaterial.ActiveMaterial], null);
            DrawItem(Offset(wearPlaceStart[(int)WearPlace.RightHand], InventoryStart), inventory.RightHand[ActiveMaterial.ActiveMaterial], null);
            DrawItem(Offset(wearPlaceStart[(int)WearPlace.MainArmor], InventoryStart), inventory.MainArmor, null);
            DrawItem(Offset(wearPlaceStart[(int)WearPlace.Boots], InventoryStart), inventory.Boots, null);
            DrawItem(Offset(wearPlaceStart[(int)WearPlace.Helmet], InventoryStart), inventory.Helmet, null);
            DrawItem(Offset(wearPlaceStart[(int)WearPlace.Gauntlet], InventoryStart), inventory.Gauntlet, null);

            //info
            if (SelectedCell(scaledMouse) != null)
            {
                Point selected   = SelectedCell(scaledMouse).Value;
                Point?itemAtCell = inventoryUtil.ItemAtCell(selected);
                if (itemAtCell != null)
                {
                    Item item = inventory.Items[new ProtoPoint(itemAtCell.Value)];
                    if (item != null)
                    {
                        int x = (selected.X) * CellDrawSize + CellsStart.X;
                        int y = (selected.Y) * CellDrawSize + CellsStart.Y;
                        DrawItemInfo(new Point(scaledMouse.X, scaledMouse.Y), item);
                    }
                }
            }
            if (SelectedWearPlace(scaledMouse) != null)
            {
                WearPlace selected        = SelectedWearPlace(scaledMouse).Value;
                Item      itemAtWearPlace = inventoryUtil.ItemAtWearPlace(selected, ActiveMaterial.ActiveMaterial);
                if (itemAtWearPlace != null)
                {
                    DrawItemInfo(new Point(scaledMouse.X, scaledMouse.Y), itemAtWearPlace);
                }
            }
            if (SelectedMaterialSelectorSlot(scaledMouse) != null)
            {
                int  selected = SelectedMaterialSelectorSlot(scaledMouse).Value;
                Item item     = inventory.RightHand[selected];
                if (item != null)
                {
                    DrawItemInfo(new Point(scaledMouse.X, scaledMouse.Y), item);
                }
            }

            if (inventory.DragDropItem != null)
            {
                DrawItem(new Point(scaledMouse.X, scaledMouse.Y), inventory.DragDropItem, null);
            }
        }