コード例 #1
0
        public GameplayOutput(Vector2 pPosition, MainGame pMainGame, MapFile mapFile, Hero pPlayer, SceneGameplay pCurrentScene)
        {
            Position       = pPosition;
            mainGame       = pMainGame;
            currentScene   = pCurrentScene;
            currentMapFile = mapFile;
            player         = pPlayer;

            //Item Inventory Texture
            ItemTexture.Populate(mainGame);

            //Item Data
            ItemData.PopulateData();

            //Overlay
            OverlayActive     = false;
            overlayOptionMenu = new OverlayOptionMenu(new Vector2(MainGame.ScreenWidth / 2 - OverlayOptionMenu.Width / 2,
                                                                  (int)(MainGame.ScreenHeight / 2) - OverlayOptionMenu.Height / 2),
                                                      mainGame, currentScene);

            //Inventory
            InventoryManager = new InventoryManager();
            InventoryManager.AddObject("SCYTHE", 1);
            InventoryManager.AddObject("BASEBATON", 1);

            //ItemBar
            float itemBarX = MainGame.ScreenWidth / 2 - 520 / 2;
            float itemBarY = MainGame.ScreenHeight - MainGame.ScreenHeight / 6 + 50 / 2;

            itemBar = new ItemBar(InventoryManager, new Vector2(itemBarX, itemBarY));
            itemBar.Populate();

            //InvetoryOverlay
            float InventoryposX = MainGame.ScreenWidth / 2 - 600 / 2;
            float InventoryposY = MainGame.ScreenHeight / 2 - 350 / 2;

            overlayInventory = new OverlayInventory(mainGame, InventoryManager, new Vector2(InventoryposX, InventoryposY), itemBar);

            overlayInventory.Populate();

            //player
            player.inventoryManager = InventoryManager;
            player.overlayInventory = overlayInventory;

            //Time
            timePosition = new Vector2(MainGame.ScreenWidth - 70, 5);

            //Fps
            Fps_CountPosition = new Vector2(0, 0);

            //Interact
            interactString   = "Press R";
            IsInteracting    = false;
            interactPosition = new Vector2(0, 0);

            //SpellSelector
            spellSelector = new HeroSpellSelector(player);
        }
コード例 #2
0
        public void Populate()
        {
            lstIcons.Clear();
            lstSlots.Clear();
            float x = Position.X + 9f;
            float y = Position.Y + 9f;

            slotSelected = -1;
            slotFrom     = -1;
            int col  = 1;
            int line = 1;
            int slot = 0;

            for (int i = 0; i < InventoryManager.MAXITEM; i++)
            {
                float xIcon = x + (col - 1) * (textureSlot.Width + 3);
                float yIcon = y + (line - 1) * (textureSlot.Height + 7);

                lstSlots.Add(new Rectangle((int)xIcon, (int)yIcon, WIDTHICON, HEIGHTICON));

                Item item = inventoryManager.GetItemAt(slot);

                if (item != null)
                {
                    Texture2D texture = ItemTexture.Textures[item.ID];
                    lstIcons.Add(new InventoryIcon(texture, new Vector2(xIcon, yIcon), item.Quantity, true));
                }

                slot++;

                col++;
                if (col > COLS)
                {
                    col = 1;
                    line++;
                    if (line > LINES)
                    {
                        break;
                    }
                }
            }

            itemBar.Populate();
        }