void Start() { _torchActive = false; UIEventListener.Get(MainHud.AttackButton).onClick += OnAttackButtonClick; UIEventListener.Get(MainHud.AttackButton).onPress += OnAttackButtonPress; UIEventListener.Get(MainHud.GetItemButton).onClick += OnGetItemClick; UIEventListener.Get(MainHud.UseButton).onClick += OnUseButtonClick; UIEventListener.Get(MainHud.RemovePlaceItemButton).onClick += OnRemoveCurrentPlacedItem; UIEventListener.Get(MainHud.UpFoundationButton).onClick += OnUpFoundation; UIEventListener.Get(MainHud.DownFoundationButton).onClick += OnDownFoundation; _simpleEvents.Attach(Player.PLAYER_UNDER_WATER, OnUnderWater); _simpleEvents.Attach(Inventory.INVENTORY_ADD_ITEM, OnAddItemToInventory); }
void Start() { _simpleEvents.Attach(Player.PLAYER_UPDATE_STATS, OnStatsUpdate); _simpleEvents.Attach(Player.PLAYER_GET_DAMAGE, OnGetDamage); InventoryPanel.OnSlotClickAction += OnInventorySlotClick; InventoryPanel.QuickSlotsPanel.OnSlotClickAction += OnQuickSlotClick; InventoryPanel.EquipPanel.OnSlotClickAction += OnEquipSlotClick; SetAutoAim(false); ZoomButton.SetActive(false); AmmoLabel.enabled = false; SniperZoom.SetActive(false); UIEventListener.Get(InventoryButton).onClick += OnInventoryButtonClick; UIEventListener.Get(CraftButton).onClick += OnCraftButtonClick; UIEventListener.Get(OptionsButton).onClick += OnOptionButtonClick; UIEventListener.Get(AutoAimButton).onClick += OnAutoAimClick; UIEventListener.Get(CurrencyObject).onClick += OnShowShop; CurrencyManager.OnChangeCurrency += UpdateBalance; _getItemButtonIsActive = true; }
public override void Init(GameManager gameManager) { base.Init(gameManager); QuickSlotsPanel.Init(gameManager); EquipPanel.Init(gameManager); var intentoryModel = GameManager.PlayerModel.Inventory; for (int i = 0; i < intentoryModel.MaxSlots; i++) { var itemModel = GameManager.PlayerModel.Inventory.Slots[i]; var go = NGUITools.AddChild(SlotsGrid.gameObject, ItemPrefab); go.name = "InventorySlot_" + i; var slotUi = go.GetComponent <UiSlot>(); slotUi.Init(GameManager, itemModel, i); slotUi.OnSlotClickAction += OnSlotClick; Slots.Add(slotUi); } SlotsGrid.Reposition(); UIEventListener.Get(BackCollider.gameObject).onClick += OnBackClick; _simpleEvents.Attach(Inventory.INVENTORY_ADD_ITEM, OnAddItem); }