예제 #1
0
        private void SetModuleForItem(Item item)
        {
            ItemAttributes attrs = ItemUtils.GetItemAttributes(item.ItemID);
            // decide and create item module accordingly.
            Type itemType = ItemControllers.FirstOrDefault(
                x => item.ItemID == (x.GetCustomAttribute(typeof(ItemAttribute)) as ItemAttribute).ItemID);

            if (itemType != null)
            {
                if (ItemModules[item.Slot] == null || !(ItemModules[item.Slot].GetType().IsAssignableFrom(itemType)))
                {
                    ItemModules[item.Slot]?.Dispose();
                    ItemModules[item.Slot] = itemType.GetMethod("Create")
                                             .Invoke(null, new object[] { this.leds.Length, this.gameState, item.Slot, this.lightingMode, this.preferredCastMode })
                                             as ItemModule;
                    ItemModules[item.Slot].RequestActivation += OnItemActivated;
                    ItemModules[item.Slot].NewFrameReady     += OnNewFrameReceived;
                    ItemCooldownController.AssignItemIdToSlot(item.Slot, item.ItemID);
                    if (item.ItemID == WardingTotemModule.ITEM_ID)
                    {
                        WardingTotemModule.Current = ItemModules[item.Slot] as WardingTotemModule; // HACK to make it accessible to HUDModule
                    }
                    // TODO: Show an item buy animation here?
                }
                ItemModules[item.Slot].UpdateGameState(gameState);
            }
            else
            {
                ItemModules[item.Slot]?.Dispose();
                ItemModules[item.Slot] = null;
            }
        }
예제 #2
0
        protected ItemModule(int itemID, int itemSlot, GameState state, LightingMode preferredMode)
        {
            LightingMode       = preferredMode;
            ItemAttributes     = ItemUtils.GetItemAttributes(itemID);
            GameState          = state;
            this._ItemID       = itemID;
            this.itemSlot      = itemSlot;
            this.activationKey = GetKeyForItemSlot(itemSlot); // TODO: Handle key rebinds...

            // Should this be needed for all items modules? Only active ones
            KeyboardHookService.Instance.OnMouseClicked += OnMouseClick; // TODO. Abstract this to league of legends module, so it pairs with summoner spells and items.
            KeyboardHookService.Instance.OnKeyPressed   += OnKeyPress;
            KeyboardHookService.Instance.OnKeyReleased  += OnKeyRelease;
        }