public void UseCommandSlot(int index) { if (!m_chatEnabled && !m_spellTargetEnabled) { if (TryGetCommandBar(out List <CommandBarUI> commandBarList)) { SlotUI slot = commandBarList.FirstOrDefault()?.GetSlot(index); if (slot != null && slot.GetReferenceWindow() != null) { WindowType referenceWindowType = slot.GetReferenceWindow().GetWindowType(); int referenceIndex = slot.GetReferenceIndex(); if (referenceWindowType.Equals(WindowType.InventoryWindow) || referenceWindowType.Equals(WindowType.CharacterWindow)) { m_gameManager.SendUse(referenceIndex); } else if (referenceWindowType.Equals(WindowType.SpellsWindow)) { string spellTarget = slot.GetSpellTarget(); if (spellTarget.Equals("T")) { CastTargetSpell(referenceIndex); } else { m_gameManager.SendCast(referenceIndex, m_playerId); } } } } } }
// Start is called before the first frame update void Start() { AttackOne.onClick.AddListener(() => { GameManager.Instance.TriggerAttack(0); }); AttackTwo.onClick.AddListener(() => { GameManager.Instance.TriggerAttack(1); }); AttackOne.GetComponent <SlotUI>().OnObjectEquipped += OnObjectEquipped; AttackTwo.GetComponent <SlotUI>().OnObjectEquipped += OnObjectEquipped; _slotPrefab = Grid.GetComponentInChildren <SlotUI>(); if (_slotPrefab != null) { _slots = new SlotUI[12]; for (int i = 0; i < 12; ++i) { SlotUI s = Instantiate(_slotPrefab, Grid.transform); s.gameObject.name = $"Slot[{i}]"; s.InventoryIndex = i; s.OnObjectDropped += ChangeInventory; _slots[i] = s; } } _slotPrefab.gameObject.SetActive(false); GameManager.Instance.Player.OnItemMoved += OnItemMoved; GameManager.OnInventoryDisplay += () => { Grid.gameObject.SetActive(!Grid.gameObject.activeSelf); }; }
private void CursorEnterItem(SlotUI i) { i.Image.rectTransform.localScale = new Vector3(1.25f, 1.25f, 1); Vector3 pos = i.transform.localPosition; float biasx = 0; float biasy = 0; if ((i.SlotID >= 0) && (i.SlotID <= 29)) { biasx = -0.5f; biasy = 0; } else if ((i.SlotID >= 30) && (i.SlotID <= 39)) { biasx = 0; biasy = 0; } else if ((i.SlotID >= 40) && (i.SlotID <= 69)) { biasx = -0.5f; biasy = 0; } highlight.activateHighlight(pos.x + biasx, pos.y + biasy, 1, 1); }
public void Init(InventoryBase inventory, Func <int, InventoryBase, int, bool> onMoveItem) { this.inventory = inventory; Size = inventory.Size; slotUIs = new SlotUI[Size]; itemUIs = new ItemUI[Size]; // Clear Slots slotUIGroup.ClearChildren(); // Spawn Slots for (int i = 0; i < Size; i++) { SlotUI slot = Instantiate(slotUIPrefab.gameObject).GetComponent <SlotUI>(); slot.transform.SetParent(slotUIGroup, false); slot.name = $"Slot_{i}"; slot.Init(this, i); if (slot is DroppableSlotUI) { (slot as DroppableSlotUI).Init(onMoveItem); } slotUIs[i] = slot; } }
public void CreateNewCase() { Debug.Log("Creating new Case"); Slot newSlot = new Slot(GlobalProfile.gameSlots.NextID(), 3 /* ID do Hall */, DateTime.Now, new DateTime()); GlobalProfile.gameSlots.AddSlotToList(newSlot); SaveGameSystem.SaveGame(GlobalProfile.gameSlots, "slots"); GameObject slotGO = Instantiate(slotsPrefab); slotGO.transform.SetParent(slotsGroup.transform, false); //slotGO.transform.SetAsFirstSibling(); SlotUI ui = slotGO.GetComponent <SlotUI>(); ui.populate = this; ui.id = newSlot.id; ui.dataInicio = newSlot.date; ui.cenario = newSlot.scenario; ui.tempoDeJogo = newSlot.gameTime; ui.fadeEffect = fadeEffect; ui.gameObject.SetActive(false); AddToPage(ui); curr_page = pages.Count - 1; LoadPage(curr_page); }
public void ClickSlotEditSelect() { if (curSelectedEditDeckSlot == null) { return; } if (curSelectedEditSlot == null) { return; } int index = curSelectedEditDeckSlot.Index; if (tempDeckData.DataDic.ContainsKey(index)) { tempDeckData.DataDic[index] = curSelectedEditSlot.Data; } else { tempDeckData.AddData(index, curSelectedEditSlot.Data); } DeckManager.Instance.CheckDeckEffect(tempDeckData); curSelectedEditSlot.ActiveHighlight(false); curSelectedEditSlot = null; ActiveDeckEditUI(); }
public void MoveToTopOfMogi(CardEntity mogi) { HandUI.Instance.RemoveCard(entity); SlotUI slotHaveMogi = BoardUI.Instance.PutOnTopMogi(entity, (MogiEntity)mogi); this.MoveToSlot(slotHaveMogi, true, Dissolving); }
public void ClickSlotEditCancel() { curSelectedEditSlot?.ActiveHighlight(false); curSelectedEditSlot = null; ActiveDeckEditUI(); }
public void ClickSlot(SlotUI slotUI) { if (curSelectSlot != null && curSelectSlot.Index == slotUI.Index) { return; } curSelectSlot?.ActiveHighlight(false); curSelectSlot = slotUI; if (tempCharacter != null) { GameManager.Instance.RemoveCharacter(tempCharacter.Physics.PID); tempCharacter = null; } CameraManager.Instance.InitCreatePos(); CameraManager.Instance.AdjustScreen(); CameraManager.IsDragAble = false; var playerCreatePos = CameraManager.Instance.playerCreatePos.position; var e1 = Camera.main.WorldToViewportPoint(playerCreatePos); var e2 = UICamera.mainCamera.ViewportToWorldPoint(e1); characterPosSelectRoot.transform.position = new Vector3(e2.x, e2.y, 0); readyButtonRoot.SetActive(tempCharacter != null); readyCancelButtonRoot.SetActive(false); characterPosSelectRoot.SetActive(true); }
public void reloadView() { curParty = PartyControl.Instance.curParty; partyName.text = curParty.partyName; playerList = curParty.userList; for (int i = 0; i < 4; i++) { if (i > playerList.Count - 1) { SlotUI slot = playerSlotList[i]; slot.disableUI(); slot.playerName.text = ""; } else if (playerList[i] != null) { SlotUI slot = playerSlotList[i]; PlayerInfo player = (PlayerInfo)playerList[i]; Debug.Log(player.id + " " + Websocket.Instance.curPlayer.id); if (player.id != Websocket.Instance.curPlayer.id) { slot.disableUI(); slot.readyButton.GetComponent <ReadyButton>().player = player; slot.readyButton.GetComponent <ReadyButton>().readyClick(); } slot.playerName.text = player.playerName; slot.readyButton.GetComponent <ReadyButton>().player = player; slot.readyButton.GetComponent <ReadyButton>().readyClick(); } } }
////////////////////////////// MAIN INVENTORY CALLBACKS //////////////////////////////////// private void container_ItemClick(SlotUI i, IContainer container, IUserInterface UI) { Debug.Log("item click: " + i.SlotID); Debug.Log(container.getItem(i.SlotID)); Debug.Log((draggedItemUI.itemStack != null)); if ((container.getItem(i.SlotID) != null) && (draggedItemUI.itemStack != null)) { Debug.Log("A"); //If same item, stack them if (container.getItem(i.SlotID).item_id == draggedItemUI.Item.item_id) { StackItem(i, container); } //If not same item, then swap positions else { SwapItem(i, container); } } else if ((container.getItem(i.SlotID) != null) && (draggedItemUI.itemStack == null)) { Debug.Log("B"); SelectItem(i, container); } else if ((container.getItem(i.SlotID) == null) && (draggedItemUI.itemStack != null)) { Debug.Log("C"); InsertItem(i, container); } UI.Refresh(); }
private void SwapItem(SlotUI i, IContainer container) { ItemStack temp = draggedItemUI.itemStack; draggedItemUI.itemStack = container.getItemStack(i.SlotID); container.addItemStack(i.SlotID, temp); i.Image.rectTransform.localScale = new Vector3(1.25f, 1.25f, 1); }
private void toolbar_CursorEnterItem(SlotUI i) { i.Image.rectTransform.localScale = new Vector3(1.25f, 1.25f, 1); Vector3 pos = i.transform.localPosition; highlight.activateHighlight(pos.x, pos.y, 1, 1); }
public override void QuickTake(SlotUI toSlot) { if (toSlot.Slot.MaxAddAmount(Slot.Item, Slot.Amount) >= Slot.Amount) { toSlot.Slot.SetItemAmount(Slot.Item, Slot.Amount + toSlot.Slot.Amount); OnItemTaken?.Invoke(); } }
public void ResetCursor() { SetCursor(m_cursorType); m_selectedSlot = null; m_selectedWindow = null; m_selectedWindowOffset = Vector3.zero; ClearCursorSlot(); }
public void AddSlots() { for (int i = 0; i < Bag.Slots.Count; i++) { SlotUI slotUI = Instantiate(slotPrefab, transform).GetComponent <SlotUI>(); slotUI.Slot = Bag.Slots[i]; Bag.Slots[i].SlotUI = slotUI; } }
public void RemovePage(SlotUI slot) { for (int i = 0; i < pages.Count; i++) { if (pages[i].Contains(slot)) { pages[i].Remove(slot); } } CorrectPageAfterDelete(); }
bool TryGetSelectSlot(out WindowUI window, out SlotUI slot) { window = default(WindowUI); slot = default(SlotUI); if (TryGetMouseWorldPosition(out Vector3 worldPosition)) { window = GetWindowAtPoint(worldPosition); slot = GetSlotAtPoint(worldPosition); return(SlotSelected(window, slot)); } return(false); }
public void setSlot(SlotUI newSlot) { if (fromSlot != null) { fromSlot.removeCurrentItem(); } if (newSlot != null) { rectTransform.SetParent(newSlot.GetComponent <RectTransform> ().parent, false); } fromSlot = newSlot; }
void Refresh() { DestroyAllChildren(); foreach (var slot in inventory.SlotList) { SlotUI instButton = Instantiate(slotPrefab); var localSlot = slot; instButton.transform.SetParent(transform); instButton.Init(localSlot); instButton.button.onClick.AddListener(() => inventory.DropItem(localSlot.item)); } }
public void CopySlot(SlotUI slot, bool copyAsReference = false, bool swapSlots = false) { if (slot != null) { if (copyAsReference) { swapSlots = false; } int index = slot.GetSlotIndex(); int referenceIndex = slot.GetReferenceIndex(); int amount = slot.GetSlotAmount(true); int slotId = slot.GetSlotId(); int soundId = slot.GetSoundId(); int graphicId = slot.GetSlotGraphicId(); Color color = slot.GetSlotColor(); WindowUI window = slot.GetWindow(); WindowUI referenceWindow = slot.GetReferenceWindow(); SlotType slotType = slot.GetSlotType(); string slotName = slot.GetSlotName(); string spellTarget = slot.GetSpellTarget(); bool enabled = slot.GetSlotEnabled(); if (swapSlots) { slot.CopySlot(this); slot.SetSlotIndex(index); } SetSlotAmount(amount); SetSlotId(slotId); SetSoundId(soundId); SetSlotType(slotType); UpdateSlotGraphic(graphicId, color); SetSlotName(slotName); SetSpellTarget(spellTarget); if (copyAsReference) { SetReferenceIndex(index); SetReferenceWindow(window); } else { SetReferenceIndex(referenceIndex); SetReferenceWindow(referenceWindow); SetSlotEnabled(enabled); if (!swapSlots) { SetSlotIndex(index); } } } }
public void AddCommandSlot(int slotIndex, SlotUI slot) { if (TryGetCommandBar(out List <CommandBarUI> commandBarList)) { string playerName = GetMainPlayerName(); foreach (CommandBarUI commandBar in commandBarList) { commandBar.CopySlot(slotIndex, slot, playerName); } UserPrefs.Save(); } }
private void toolbar_CursorExitItem(SlotUI i) { if (i.SlotID == InventoryController.Instance.getCurrentItemID()) { i.Image.rectTransform.localScale = new Vector3(1.25f, 1.25f, 1); } else { i.Image.rectTransform.localScale = new Vector3(1, 1, 1); } //highlight = ToolbarUI.GetComponentInChildren<ItemHighlighUI>(); highlight.deactivateHighlight(); }
bool SlotSelected(WindowUI window, SlotUI slot) { if (window != null && slot != null) { int slotWindowId = slot.GetWindow().GetWindowId(); int expectedWindowId = window.GetWindowId(); if (slotWindowId.Equals(expectedWindowId)) { return(true); } } return(false); }
////////////////////////////// TOOLBAR CALLBACKS //////////////////////////////////// private void toolbar_ItemClick(SlotUI i) { i.Image.rectTransform.localScale = new Vector3(1.25f, 1.25f, 1); //update mode InvObject.selectedItemID = i.SlotID; //Update UI current tool outline position selectionOutline.updatePos(i.SlotID - 30); //refresh toolbar ToolbarUI.RefreshToolbarUI(); }
public void removeItem() { if (selectedSlot == null) { return; } int pos = System.Array.IndexOf(slots, selectedSlot); slots[pos].removeItem(); Inventory.instance.Remove(pos); selectedSlot = null; dropButton.SetActive(false); }
public void ClickSelectCancelButton() { curSelectSlot?.ActiveHighlight(false); curSelectSlot = null; if (tempCharacter != null) { GameManager.Instance.RemoveCharacter(tempCharacter.Physics.PID); tempCharacter = null; } readyButtonRoot.SetActive(false); readyCancelButtonRoot.SetActive(false); }
public void Init(int round, PlayerData curPlayerData, PlayerData player1, PlayerData player2) { var curDeck = curPlayerData.deckData; this.player1Name.text = string.Format("{0}", player1.team); this.player2Name.text = string.Format("{0}", player2.team); this.turnCount.text = string.Format("{0}/{1}", curPlayerData.UseIndexList.Count + 1, curDeck.DataDic.Count); this.leftTime.text = this.leftTimer.ToString(); this.roundCount.text = string.Format("{0}/{1}", round, GameManager.ROUND_COUNT); this.player1Score.text = player1.Score.ToString(); this.player2Score.text = player2.Score.ToString(); this.player1 = player1; this.player2 = player2; this.curSelectSlot = null; this.playerData = curPlayerData; this.tempCharacter = null; this.leftTimer = GameManager.TURN; for (int i = 0; i < slotArray.Length; i++) { if (curDeck.DataDic.ContainsKey(i)) { var data = curDeck.DataDic[i]; slotArray[i].Init(i, data, data.NAME, ClickSlot, PressSlot); if (curPlayerData.UseIndexList.Contains(i)) { slotArray[i].ActiveBlock(true); } } } menuRoot.SetActive(true); mainRoot.SetActive(true); characterInfoRoot.SetActive(false); profileRoot.SetActive(false); pauseRoot.SetActive(false); characterPosSelectRoot.SetActive(false); readyButtonRoot.SetActive(false); readyCancelButtonRoot.SetActive(false); }
public virtual void QuickTake(SlotUI toSlot) { if (toSlot.Slot.Item != null && toSlot.Slot.TrySetItem(Slot.Item)) { int amount = toSlot.Slot.AddAmount(Slot.Amount); Slot.Consume(amount); } else { Item tempItem = Slot.Item; int tempAmount = Slot.Amount; SetSlotValues(toSlot.Slot); toSlot.SetSlotValues(tempItem, tempAmount); } }
void UpdateSlotPrefs(int index, SlotUI slot, string playerName) { Debug.Log("UpdateSlotPrefs"); if (slot != null && slot.GetSlotGraphicId() > 0) { WindowType referenceWindowType = slot.GetReferenceWindow().GetWindowType(); int referenceIndex = slot.GetReferenceIndex(); UserPrefs.SetCommandBarReferenceIndex(index, referenceIndex, playerName); UserPrefs.SetCommandBarReferenceWindowType(index, referenceWindowType, playerName); } else { ClearSlot(index + 1, playerName); } }
private void OnSelectedSlot(SlotSelectedEventArgs args) { if (args.SelectedSlot.attachedItem == null) { EnableOnlyCorrectInventroy(args.SelectedSlot.Type); currentSelectedSlot = args.SelectedSlot; } else { args.SelectedSlot.DetachItem(); EnableOnlyCorrectInventroy(args.SelectedSlot.Type); currentSelectedSlot = args.SelectedSlot; } if (!inventoryShowing) { GetComponent<Animator>().Play("InventorySlideIn"); inventoryShowing = true; } }
public SlotSelectedEventArgs(SlotUI selectedSlot) { SelectedSlot = selectedSlot; }
public void DeselectSlot() { currentSelectedSlot = null; EnableAllInventory(); }