Пример #1
0
    public override void OnNewFrameDraw2d(Game game_, float deltaTime)
    {
        game = game_;
        if (dataItems == null)
        {
            dataItems      = new GameDataItemsClient();
            dataItems.game = game_;
            controller     = ClientInventoryController.Create(game_);
            inventoryUtil  = game.d_InventoryUtil;
        }
        if (game.guistate == GuiState.MapLoading)
        {
            return;
        }
        DrawMaterialSelector();
        if (game.guistate != GuiState.Inventory)
        {
            return;
        }
        if (ScrollingUpTimeMilliseconds != 0 && (game.platform.TimeMillisecondsFromStart() - ScrollingUpTimeMilliseconds) > 250)
        {
            ScrollingUpTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
            ScrollUp();
        }
        if (ScrollingDownTimeMilliseconds != 0 && (game.platform.TimeMillisecondsFromStart() - ScrollingDownTimeMilliseconds) > 250)
        {
            ScrollingDownTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
            ScrollDown();
        }

        PointRef scaledMouse = PointRef.Create(game.mouseCurrentX, game.mouseCurrentY);

        game.Draw2dBitmapFile("inventory.png", InventoryStartX(), InventoryStartY(), 1024, 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
        for (int i = 0; i < game.d_Inventory.ItemsCount; i++)
        {
            Packet_PositionItem k = game.d_Inventory.Items[i];
            if (k == null)
            {
                continue;
            }
            int screeny = k.Y - ScrollLine;
            if (screeny >= 0 && screeny < CellCountInPageY)
            {
                DrawItem(CellsStartX() + k.X * CellDrawSize, CellsStartY() + screeny * CellDrawSize, k.Value_, 0, 0);
            }
        }

        //draw area selection
        if (game.d_Inventory.DragDropItem != null)
        {
            PointRef selectedInPage = SelectedCell(scaledMouse);
            if (selectedInPage != null)
            {
                int x     = (selectedInPage.X) * CellDrawSize + CellsStartX();
                int y     = (selectedInPage.Y) * CellDrawSize + CellsStartY();
                int sizex = dataItems.ItemSizeX(game.d_Inventory.DragDropItem);
                int sizey = dataItems.ItemSizeY(game.d_Inventory.DragDropItem);
                if (selectedInPage.X + sizex <= CellCountInPageX &&
                    selectedInPage.Y + sizey <= CellCountInPageY)
                {
                    int        c;
                    IntRef     itemsAtAreaCount = new IntRef();
                    PointRef[] itemsAtArea      = inventoryUtil.ItemsAtArea(selectedInPage.X, selectedInPage.Y + ScrollLine, sizex, sizey, itemsAtAreaCount);
                    if (itemsAtArea == null || itemsAtAreaCount.value > 1)
                    {
                        c = Game.ColorFromArgb(100, 255, 0, 0); // red
                    }
                    else //0 or 1
                    {
                        c = Game.ColorFromArgb(100, 0, 255, 0); // green
                    }
                    game.Draw2dTexture(game.WhiteTexture(), x, y,
                                       CellDrawSize * sizex, CellDrawSize * sizey,
                                       null, 0, c, false);
                }
            }
            IntRef selectedWear = SelectedWearPlace(scaledMouse);
            if (selectedWear != null)
            {
                PointRef p    = PointRef.Create(wearPlaceStart[selectedWear.value].X + InventoryStartX(), wearPlaceStart[selectedWear.value].Y + InventoryStartY());
                PointRef size = wearPlaceCells[selectedWear.value];

                int         c;
                Packet_Item itemsAtArea = inventoryUtil.ItemAtWearPlace(selectedWear.value, game.ActiveMaterial);
                if (!dataItems.CanWear(selectedWear.value, game.d_Inventory.DragDropItem))
                {
                    c = Game.ColorFromArgb(100, 255, 0, 0); // red
                }
                else //0 or 1
                {
                    c = Game.ColorFromArgb(100, 0, 255, 0); // green
                }
                game.Draw2dTexture(game.WhiteTexture(), p.X, p.Y,
                                   CellDrawSize * size.X, CellDrawSize * size.Y,
                                   null, 0, c, false);
            }
        }

        //material selector
        DrawMaterialSelector();

        //wear
        //DrawItem(Offset(wearPlaceStart[(int)WearPlace.LeftHand], InventoryStart), inventory.LeftHand[ActiveMaterial.ActiveMaterial], null);
        DrawItem(wearPlaceStart[WearPlace_.RightHand].X + InventoryStartX(), wearPlaceStart[WearPlace_.RightHand].Y + InventoryStartY(), game.d_Inventory.RightHand[game.ActiveMaterial], 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.MainArmor].X + InventoryStartX(), wearPlaceStart[WearPlace_.MainArmor].Y + InventoryStartY(), game.d_Inventory.MainArmor, 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.Boots].X + InventoryStartX(), wearPlaceStart[WearPlace_.Boots].Y + InventoryStartY(), game.d_Inventory.Boots, 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.Helmet].X + InventoryStartX(), wearPlaceStart[WearPlace_.Helmet].Y + InventoryStartY(), game.d_Inventory.Helmet, 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.Gauntlet].X + InventoryStartX(), wearPlaceStart[WearPlace_.Gauntlet].Y + InventoryStartY(), game.d_Inventory.Gauntlet, 0, 0);

        //info
        if (SelectedCell(scaledMouse) != null)
        {
            PointRef selected = SelectedCell(scaledMouse);
            selected.Y += ScrollLine;
            PointRef itemAtCell = inventoryUtil.ItemAtCell(selected);
            if (itemAtCell != null)
            {
                Packet_Item item = GetItem(game.d_Inventory, itemAtCell.X, itemAtCell.Y);
                if (item != null)
                {
                    int x = (selected.X) * CellDrawSize + CellsStartX();
                    int y = (selected.Y) * CellDrawSize + CellsStartY();
                    DrawItemInfo(scaledMouse.X, scaledMouse.Y, item);
                }
            }
        }
        if (SelectedWearPlace(scaledMouse) != null)
        {
            int         selected        = SelectedWearPlace(scaledMouse).value;
            Packet_Item itemAtWearPlace = inventoryUtil.ItemAtWearPlace(selected, game.ActiveMaterial);
            if (itemAtWearPlace != null)
            {
                DrawItemInfo(scaledMouse.X, scaledMouse.Y, itemAtWearPlace);
            }
        }
        if (SelectedMaterialSelectorSlot(scaledMouse) != null)
        {
            int         selected = SelectedMaterialSelectorSlot(scaledMouse).value;
            Packet_Item item     = game.d_Inventory.RightHand[selected];
            if (item != null)
            {
                DrawItemInfo(scaledMouse.X, scaledMouse.Y, item);
            }
        }

        if (game.d_Inventory.DragDropItem != null)
        {
            DrawItem(scaledMouse.X, scaledMouse.Y, game.d_Inventory.DragDropItem, 0, 0);
        }
    }
Пример #2
0
 public static ClientInventoryController Create(Game game)
 {
     ClientInventoryController c = new ClientInventoryController();
     c.g = game;
     return c;
 }