public void OnDrop(PointerEventData eventData) { _currentDraggedCard = DragHandler.draggedCard; var currentPlayer = GameCore.currentPlayer == 1 ? GameCore.player1 : GameCore.player2; _currentPlayerHandCards = GameCore.GetHandCardSlotOfPlayer(currentPlayer); int cardNumber = _currentDraggedCard.CardNumber; _cardInPlace = _cardInSlot(transform); _currentSlotNumber = _cardInPlace ? _cardInPlace.CardNumber : 200; _hasCardPlaced = _cardInPlace; if (CanDropCard(cardNumber)) { _currentDraggedCard.transform.SetParent(transform); _currentDraggedCard.transform.localPosition = new Vector3(0, 0, 0); SetChoiceButtons(true); cardHandler.DisableDragHandler(_currentDraggedCard, _cardInPlace); GameEvents.Invoke_OnCardDroppedInSlot(_currentDraggedCard, _currentPlayerHandCards.currentHandCards.Count); } else { GameEvents.Invoke_OnCardDropDeclined(); } }
internal static void SetPlayerHandCardsNonVisible(int playerNumber) { if (playerNumber == 2) { cardSlotPlayer2.gameObject.SetActive(false); cardSlotPlayer1.gameObject.SetActive(true); activeHandCardSlot = cardSlotPlayer1; } else { cardSlotPlayer1.gameObject.SetActive(false); cardSlotPlayer2.gameObject.SetActive(true); activeHandCardSlot = cardSlotPlayer2; } }
void SetupScene() { drawnNumbers = Enumerable.Range(2, 98).ToList(); GameEvents.OnCardDroppedInSlot += OnCardDroppedInSlot; GameEvents.OnEndTurnButtonClicked += SetupNextRound; for (int i = 0; i < numberOfPlayers; i++) { InstantiatePlayers(i + 1); } upwardCards = new List <CardSlot>(); downwardCards = new List <CardSlot>(); var cardSlots = FindObjectsOfType <CardSlot>(); foreach (var slot in cardSlots) { if (slot.isUpwardSlot) { upwardCards.Add(slot); } else { downwardCards.Add(slot); } } playerNumberUIElement = FindObjectOfType <ShowCurrentPlayerNumber>(); if (numberOfPlayers == 2) { var players = FindObjectsOfType <Player>(); foreach (var player in players) { if (player.playerNumber == 2) { player2 = player; } if (player.playerNumber == 1) { player1 = player; } cardSlotPlayer1 = cardHandler.cardSlotHandCardsPlayer1; cardSlotPlayer2 = cardHandler.cardSlotHandCardsPlayer2; } } if (player1 == null) { player1 = FindObjectOfType <Player>(); cardSlotPlayer1 = cardHandler.cardSlotHandCardsPlayer1; activeHandCardSlot = cardSlotPlayer1; } cardHandler.OnGameStart(); _initialNumberOfCards = drawnNumbers.Count; UpdateLeftCardsText(); }