void IBeginDragHandler.OnBeginDrag(PointerEventData eve) { DeckUI deckUI = DeckUI.GetInstance(); prePos = eve.position; selectedIndex = (int)((eve.position.x - cardPanel.position.x) / deckUI.slotSize + 1); }
public void OpenDeckSimulator() { // UI -> include DeckData.Load UI = Instantiate(UI) as GameObject; deckUI = DeckUI.GetInstance(); DeckSettingUI.synchronizeAll(); }
void IDragHandler.OnDrag(PointerEventData eve) { Vector2 moveOffset = eve.position - prePos; DeckUI deckUI = DeckUI.GetInstance(); item.GetComponent <RectTransform>().Translate(moveOffset); prePos = eve.position; }
void IEndDragHandler.OnEndDrag(PointerEventData eve) { if (dragType == "vertical") { DeckSettingUI selectedDeck; DeckUI deckUI = DeckUI.GetInstance(); if (selectedDeck = DeckSettingUI.SearchEnterMouseObject(eve.position)) { selectedDeck.SetCardIndex(deckUI.readonlyCardList[selectedIndex]); } else { DeckSlot selectedSlot = DeckSlot.GetSlotByCard(deckUI.readonlyCardList[selectedIndex]); selectedSlot.SlotFree(); selectedIndex = -1; } Destroy(currentSelectedItem.gameObject); } prePos = Vector2.zero; dragType = ""; }
public void SetCardIndex(Card inputCard) { DeckUI deckUI = DeckUI.GetInstance(); if (card != null) { DeckSlot previousSlot = DeckSlot.GetSlotByCard(card); previousSlot.SlotFree(); } DeckSlot selectedSlot = DeckSlot.GetSlotByCard(inputCard); selectedSlot.SlotSelect(); card = inputCard; // Image Component Copy Image copyImage = DeckSlot.GetSlotByCard(inputCard).GetItemGameObject().GetComponent <Image>(); Util.CopyImage(copyImage, item); // regist -> Controller dc.SetDeckData(card, 0, deckColIdx); }
public void SynchronizeDeckData() { DeckData deckData = DeckData.GetInstance(); int cardIdx = deckData.deck[0, deckColIdx]; if (cardIdx <= 0) { return; } Card c = deckData.characterCardList[cardIdx]; card = c; DeckUI deckUI = DeckUI.GetInstance(); DeckSlot selectedSlot = DeckSlot.GetSlotByCard(card); selectedSlot.SlotSelect(); // Image Component Copy Image copyImage = DeckSlot.GetSlotByCard(card).GetItemGameObject().GetComponent <Image>(); Util.CopyImage(copyImage, item); }
void IDragHandler.OnDrag(PointerEventData eve) { Vector2 moveOffset = eve.position - prePos; if (dragType == "horizon") { cardPanel.Translate(Vector2.right * moveOffset.x, 0); prePos = eve.position; } else if (dragType == "vertical") { DeckUI deckUI = DeckUI.GetInstance(); currentSelectedItem.GetComponent <RectTransform>().Translate(moveOffset); prePos = eve.position; } if (dragType == "" && Vector2.Distance(eve.position, prePos) > 1.0f) { if (Math.Abs(moveOffset.x) > Math.Abs(moveOffset.y)) { dragType = "horizon"; } else { // drage vertical DeckUI deckUI = DeckUI.GetInstance(); Camera _camera = Camera.main; float screenWidth = _camera.pixelWidth; if (eve.position.x < 20 || eve.position.x > screenWidth - 20) { return; } // n <= ( mouse position - k - widthPad ) / slotSize + 1 if (selectedIndex <= 0 || selectedIndex > deckData.characterCardList.Count - 1) { return; } if (DeckSlot.GetSlotByCard(deckUI.readonlyCardList[selectedIndex]).slotSelected == true) { return; } //select marking DeckSlot selectedSlot = DeckSlot.GetSlotByCard(deckUI.readonlyCardList[selectedIndex]); selectedSlot.SlotSelect(); //Selected Screen correction /* slotSize(n-1) + k + 20 -> StartPoint */ if (deckUI.slotSize * (selectedIndex - 1) + cardPanel.position.x < deckUI.horizonPad) { cardPanel.localPosition = new Vector2(0 - (50 * (selectedIndex - 1)) + deckUI.horizonPad, cardPanel.localPosition.y); } if (deckUI.slotSize * (selectedIndex - 1) + cardPanel.position.x + deckUI.slotSize > screenWidth - deckUI.horizonPad) { cardPanel.Translate(-1 * Vector2.right * (deckUI.slotSize * selectedIndex + cardPanel.position.x - screenWidth + deckUI.horizonPad)); } currentSelectedItem = deckUI.GetSelectedItem(selectedIndex); dragType = "vertical"; } } }