Ejemplo n.º 1
0
        public void update()
        {
            string levelUid = LevelSystem.currentLevelUid;

            _oldGamepadState = _newGamepadState;
            _oldKeyState     = _newKeyState;
            _oldMouseState   = _newMouseState;
            _newGamepadState = GamePad.GetState(PlayerIndex.One);
            _newMouseState   = Mouse.GetState();
            _newKeyState     = Keyboard.GetState();

            if (_inFocus)
            {
                if (_newKeyState.IsKeyDown(Keys.D1) && _oldKeyState.IsKeyUp(Keys.D1))
                {
                    _equipmentSystem.selectToolbarSlot(levelUid, _toolbarComponent, 0);
                }
                if (_newKeyState.IsKeyDown(Keys.D2) && _oldKeyState.IsKeyUp(Keys.D2))
                {
                    _equipmentSystem.selectToolbarSlot(levelUid, _toolbarComponent, 1);
                }
                if (_newKeyState.IsKeyDown(Keys.D3) && _oldKeyState.IsKeyUp(Keys.D3))
                {
                    _equipmentSystem.selectToolbarSlot(levelUid, _toolbarComponent, 2);
                }
                if (_newKeyState.IsKeyDown(Keys.D4) && _oldKeyState.IsKeyUp(Keys.D4))
                {
                    _equipmentSystem.selectToolbarSlot(levelUid, _toolbarComponent, 3);
                }
            }
        }
Ejemplo n.º 2
0
        // Load player toolbar
        public static void loadPlayerToolbar()
        {
            XElement           toolbarData        = _playerData.Element("ToolbarState");
            ToolbarComponent   toolbarComponent   = new ToolbarComponent(int.Parse(toolbarData.Attribute("slots").Value), PlayerSystem.PLAYER_ID);
            EquipmentSystem    equipmentSystem    = _systemManager.getSystem(SystemType.Equipment) as EquipmentSystem;
            InventoryComponent inventoryComponent = _entityManager.getComponent("global", PlayerSystem.PLAYER_ID, ComponentType.Inventory) as InventoryComponent;

            _entityManager.addComponent("global", PlayerSystem.PLAYER_ID, toolbarComponent);
            foreach (XElement slotData in toolbarData.Elements("Slot"))
            {
                equipmentSystem.assignItemToToolbar(
                    "global",
                    equipmentSystem.getInventoryItem(inventoryComponent, int.Parse(slotData.Attribute("inventory_slot").Value)),
                    toolbarComponent,
                    int.Parse(slotData.Attribute("slot_id").Value));
            }

            equipmentSystem.selectToolbarSlot("global", toolbarComponent, int.Parse(toolbarData.Attribute("selected_index").Value));
        }