private void Awake()
 {
     myImage = GetComponent <Image>();
     if (Instance != null)
     {
         Debug.LogError("More than one instance of ActionCardDisplay present");
     }
     Instance = this;
 }
예제 #2
0
    /// <summary>
    /// Called when a UI action card is moved over the card catcher square. Visually queues the card up to be used.
    /// </summary>
    public void CatchCard(ActionCardDisplay card)
    {
        GameObject caughtCard = Instantiate(card.gameObject, transform.parent);

        // Do all the visual tricks to position the card nicely where it's meant to go, and also keep
        // it from interfering with the game.
        caughtCard.transform.SetAsLastSibling();
        caughtCard.transform.localScale                 = caughtCardScale;
        caughtCard.transform.localEulerAngles           = Vector3.zero;
        caughtCard.GetComponent <Image>().raycastTarget = false; // keep players from being able to click the card

        caughtCard.transform.localPosition = new Vector3(0, runningCardDistance, 0);
        runningCardDistance -= CardDistanceIncrement;
    }
예제 #3
0
    private void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError("More than one instance of HandManager present");
        }
        Instance = this;

        for (int i = 0; i < transform.childCount; i++)
        {   // Initialize all card displayer objects for interactions to come
            ActionCardDisplay thisDisplay = transform.GetChild(i).GetComponent <ActionCardDisplay>();
            cardDisplayers.Add(thisDisplay);
            thisDisplay.ToggleMoneyAndCarbonDisplays(thisDisplay.DisplayCardIndex == ActiveCardIndex);
            thisDisplay.Centered = thisDisplay.DisplayCardIndex == ActiveCardIndex;
        }
        cardDisplayers.Sort((x, y) => x.DisplayCardIndex.CompareTo(y.DisplayCardIndex));
    }
예제 #4
0
    /// <summary>
    /// Changes which card within the hand of cards is currently centered onscreen
    /// </summary>
    /// <param name="centeredCard">The new card to become centered</param>
    public void ShiftCenter(ActionCardDisplay centeredCard)
    {
        foreach (ActionCardDisplay card in cardDisplayers)
        {
            if (!card.Equals(centeredCard))
            {
                card.Centered = false;
                card.ToggleMoneyAndCarbonDisplays(false);
            }

            // Perform animation of cards shifting
            int cardDifference = card.DisplayCardIndex - centeredCard.DisplayCardIndex;
            StartCoroutine(card.ShiftCard(
                               new Vector3(CardXFrames.Evaluate(cardDifference), CardYFrames.Evaluate(cardDifference), 0),
                               Quaternion.Euler(0, 0, CardZRotationFrames.Evaluate(cardDifference)),
                               new Vector3(CardScales.Evaluate(cardDifference), CardScales.Evaluate(cardDifference), 1)));
        }
    }