void Start() { instance = this; table = new Table(); deck = table.decks[0]; prototypeCard.gameObject.SetActive(false); table.cards.ForEach((card) => { DraggableCard obj = Instantiate(prototypeCard, transform); obj.id = (int)card.id; obj.color.color = colors[(int)card.Color]; obj.number.color = colors[(int)card.Color]; obj.number.text = card.Number.ToString(); RectTransform rtransform = obj.GetComponent <RectTransform>(); rtransform.Translate(Random.onUnitSphere * 500); obj.gameObject.SetActive(false); cardPooling.Add(obj); }); for (int i = 0; i < slots.Length; i++) { slots[i].id = i; } prototypeCard.gameObject.SetActive(true); Distribute(); }
public void PointerInit(DraggableCard draggableCard) { _draggableCard = draggableCard; var component = _draggableCard.GetComponent<ActionsWithCards>(); _selectedCard = component.CardGame; _draggeblePointer.Init(_draggableCard, _selectedCard.GetDataCard().Application); }
void Update() { for (int i = 0; i < slots.Length; i++) { if (deck.slots[i] != null) { DraggableCard draggableCard = cardPooling[(int)deck.slots[i].id]; draggableCard.targetSlot = i; if (draggableCard.onDrag) { continue; } draggableCard.gameObject.SetActive(true); RectTransform rtransformForCard = draggableCard.GetComponent <RectTransform>(); RectTransform rtransformForSlot = slots[i].GetComponent <RectTransform>(); rtransformForCard.position = Vector3.Lerp(rtransformForCard.position, rtransformForSlot.position, Time.deltaTime * dragForce); } } }