using UnityEngine; using System.Collections.Generic; public class HandController : MonoBehaviour { public static HandController instance; void Awake() { instance = this; } public List heldCards = new List(); public Transform minPos, maxPos; public List cardPositions = new List(); // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { SetCardPositionsInHand(); } // Update is called once per frame void Update() { } public void SetCardPositionsInHand() { cardPositions.Clear(); Vector3 distanceBetweenPoints = Vector3.zero; if(heldCards.Count > 1) { distanceBetweenPoints = (maxPos.position - minPos.position) / (heldCards.Count - 1); } for(int i = 0; i < heldCards.Count; i++) { cardPositions.Add(minPos.position + (distanceBetweenPoints * i)); //heldCards[i].transform.position = cardPositions[i]; //heldCards[i].transform.rotation = minPos.rotation; heldCards[i].MoveToPoint(cardPositions[i], minPos.rotation); heldCards[i].inHand = true; heldCards[i].handPosition = i; } } public void RemoveCardFromHand(Card cardToRemove) { if (heldCards[cardToRemove.handPosition] == cardToRemove) { heldCards.RemoveAt(cardToRemove.handPosition); } else { Debug.LogError("Card at position " + cardToRemove.handPosition + " is not the card being removed from the hand."); } SetCardPositionsInHand(); } public void AddCardToHand(Card cardToAdd) { heldCards.Add(cardToAdd); SetCardPositionsInHand(); } }