/// <summary> /// Called when the user clicks on the card slot /// </summary> public void OnUserClick() { // Removes the current card this.RemoveCard(); // Grabs the currently selected card var selectedCard = CardBehavior.CurrentlySelected; if (selectedCard != null) { // Create a new card var newCard = this.CreateCard(selectedCard.PokerCard); newCard.transform.localPosition = new Vector3(0, 0); this.PlacedCard = newCard; selectedCard.OnUserClick(); // Check all card slots and remove those who already have this card foreach (var instance in CardSlot._instances) { if (instance != this && instance.PlacedCard != null && instance.PlacedCard.PokerCard == newCard.PokerCard) { instance.RemoveCard(); } } } foreach (var action in CardSlot._checkActions) { action.Invoke(); } CardSlot._currentPlayerHand.RenderPlayerHand(PlayerController.LocalPlayer.MyPlayerState); }
/// <summary> /// Removes the current card /// </summary> public void RemoveCard() { if (this.PlacedCard != null) { Destroy(this.PlacedCard.gameObject); this.PlacedCard = null; } foreach (var action in CardSlot._checkActions) { action.Invoke(); } }