예제 #1
0
    public void ReturnToHand()
    {
        currentSlot.RemoveCard();

        inHand      = true;
        currentSlot = null;
        transform.SetParent(InputManager.instance.handTransform);
        transform.position   = originalHandPosition;
        transform.localScale = normalHandSize;
        // TODO: Place back into hand controller and rearrange
    }
예제 #2
0
    private void CastRay()
    {
        Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity);

        // Only do card logic on weekdays
        if (GameManager.instance.currentPhase == PlayPhase.WEEKDAY)
        {
            if (hit)
            {
                CardView            cardHit = hit.collider.GetComponent <CardView>();
                CalendarWeekdaySlot slotHit = hit.collider.GetComponent <CalendarWeekdaySlot>();

                // Case when player moves mouse from board onto card or moves mouse off card onto another card
                if (currentHoveredCard != cardHit)
                {
                    if (currentHoveredCard)
                    {
                        currentHoveredCard.EndHover();
                    }
                }

                // Case when player hovers over a card
                if (cardHit)
                {
                    currentHoveredCard = cardHit;
                    currentHoveredCard.StartHover();
                    currentHoveredSlot = null;
                }

                // Case when player hovers over empty slot
                if (slotHit)
                {
                    currentHoveredSlot = slotHit;
                    currentHoveredCard = null;
                }
            }
            else
            {
                // No hits, reset all hovered

                // Case when player moves mouse off card onto board
                if (currentHoveredCard)
                {
                    currentHoveredCard.EndHover();
                    currentHoveredCard = null;
                }
                currentHoveredSlot = null;
            }
        }
    }
예제 #3
0
    public void SetCardInSlot(CalendarWeekdaySlot slot)
    {
        if (slot.isOccupied)
        {
            return;
        }

        inHand    = false;
        isHovered = true;                                 // Done to make sure hover state is reset correctly after placement
        slot.AcceptCard(GetComponent <CardController>()); // TODO Fix this paradigm breaker
        currentSlot = slot;
        transform.SetParent(slot.transform);
        Vector3 newPosition = slot.transform.position + placedOffset;

        transform.position   = new Vector3(newPosition.x, newPosition.y, transform.position.z); // Preserve z value
        transform.localScale = hoveredPlacedSize;
    }