Ejemplo n.º 1
0
 public void ClickCard(CardGameObject cardSelected)
 {
     if (cardSelected.GetComponent <Cantrip>() == null)
     {
         cardSelected.TargetPosition = cardSelected.CardViewController.selectLocation.position;
     }
     cardSelected.locked = true;
 }
Ejemplo n.º 2
0
        public void RecalculateHandAppearance(HandState handState, List <CardGameObject> hand, CardGameObject cantrip, int maxHandSize)
        {
            int handSize = hand.Count;

            if (handState == HandState.IDLE)
            {
                for (int i = 0; i < handSize; i++)
                {
                    hand[i].handPosition   = handLocation.position + (i - (float)handSize / 2) * Vector3.right * Mathf.Lerp(cardWidth, 1, ((float)handSize) / (float)maxHandSize);
                    hand[i].handPosition  += Vector3.back * i;
                    hand[i].TargetPosition = hand[i].handPosition;
                    hand[i].targetScale    = baseScale;
                }
                //cantrip.TargetPosition = cantripLocation.position;
                cantrip.targetScale = cantrip.transform.localScale;
                cantrip.GetComponent <Cantrip>().Hover(false);
            }
            else if (handState == HandState.HOVER)
            {
                int hoverIndex = -1;
                for (int i = 0; i < handSize; i++)
                {
                    if (hand[i] == inputController.cardHovering)
                    {
                        hoverIndex = i;
                    }
                    hand[i].handPosition   = handLocation.position + (i - (float)handSize / 2) * Vector3.right * Mathf.Lerp(cardWidth, 1, ((float)handSize) / (float)maxHandSize);
                    hand[i].handPosition  += Vector3.back * i;
                    hand[i].TargetPosition = hand[i].handPosition;
                }
                if (hoverIndex == -1)
                {
                    cantrip.GetComponent <Cantrip>().Hover(true);
                    //cantrip.TargetPosition += Vector3.right;
                }
                else
                {
                    for (int i = 0; i < handSize; i++)
                    {
                        if (i != hoverIndex)
                        {
                            hand[i].TargetPosition += Vector3.left * (1.5f / (hoverIndex - i));
                        }
                        else
                        {
                            hand[i].TargetPosition += Vector3.up * upDistance; //+ Vector3.back * 3;
                            hand[i].targetScale     = baseScale * scaleChange;
                        }
                    }
                }
            }

            float averageXPos = 0;

            for (int i = 0; i < handSize; i++)
            {
                averageXPos += hand[i].transform.position.x;
            }
            averageXPos = averageXPos / handSize;

            for (int i = 0; i < handSize; i++)
            {
                hand[i].targetAngle = new Vector3(0, 0, ((5 * (averageXPos - hand[i].transform.position.x)) + 360) % 360);
            }
        }