コード例 #1
0
        private void Update()
        {
            RaycastHit2D hit = Physics2D.GetRayIntersection(Camera.main.ScreenPointToRay(Input.mousePosition));

            if (hit.collider != null && CardGameObjectMap.ContainsValue(hit.collider.gameObject))
            {
                GameObject cardGo = hit.collider.gameObject;
                holderUnderMouse = cardGo.GetComponent <CardHolder_Board>();
                holderUnderMouse.OnCardHighlight();
            }
            else
            {
                holderUnderMouse = null;
            }
        }
コード例 #2
0
        // FIXME: create a more centralized mouse manager
        private void HandleMouseClicks()
        {
            // if we click the mouse over a card in the hand (which, presumably, is the highlighted card)
            // FIXME: What if we try to click on a card that for some reason has not been set as the highlighted card? is this a bug?
            if (highlightedCard != null && Input.GetMouseButtonDown(0))
            {
                if (TurnManager.Instance.OpponentTurn)
                {
                    Debug.LogWarning("You cannot select cards! It's not your turn!");
                    return;
                }
                if (highlightedCard.OnCardSelected != null)
                {
                    highlightedCard.OnCardSelected(highlightedCard);
                }
            }
            // another reason why we might click is to place a card
            // FIXME: Make it so that it automatically figures out where to place the card on a board
            // We shouldn't need to check it it's our turn since you shouldn't even be able to select a card, but we are checking nonetheless

            else if (TurnManager.Instance.PlayerTurn == true && selectedCard != null && Input.GetMouseButtonDown(0))
            {
                GameObject selectedCardGO = CardGameObjectMap[selectedCard];
                if (Mathf.Abs(Camera.main.ScreenToWorldPoint(Input.mousePosition).x - BoardCenter.x) < MaxDistanceFromBoardCenter.x &&
                    Mathf.Abs(Camera.main.ScreenToWorldPoint(Input.mousePosition).y - BoardCenter.y) < MaxDistanceFromBoardCenter.y)
                {
                    GameObject cardGO = CardGameObjectMap[selectedCard];
                    CardGameObjectMap.Remove(selectedCard);
                    // FIXME: Animations!
                    Destroy(cardGO);
                    BoardManager.Instance.PlayerBoard.PlayCard(selectedCard);
                    UpdateCardPositions(); // FIXME: SHould we instead add this onto the cardPlayed callback
                    selectedCard = null;
                }
                else
                {
                    CardGameObjectMap[selectedCard].SetSortingLayerRecursively("CardsInHand");
                    CardGameObjectMap[selectedCard].GetComponent <CardHolder_Hand>().UnSelectCard();
                    selectedCardGO.SetLayerRecursively(8);
                    // FIXME: this is simply not scalable
                    selectedCard = null;
                    UpdateCardPositions();
                }
            }
        }
コード例 #3
0
        private void SetupPlayerCardGameObject(Card c)
        {
            GameObject cardGO = CardManager.Instance.GetGameObjectForCardOnBoard(c, TurnManager.Instance.PlayerTurn ? playerBoardParent : opponentBoardParent);

            cardGO.SetLayerRecursively(10);

            CoroutineManager.Instance.SetupTimer(0.1f, null, () =>
            {
                Minion minion = cardGO.GetComponent <Minion>();
                if (minion == null)
                {
                    Debug.LogWarning("This doesn't have a minion?");
                }
                else
                {
                    minion.OnCardDeath += UpdateCardPositionsWrapper;
                }
            }
                                                 );


            CardGameObjectMap.Add(c, cardGO);
        }