Пример #1
0
    // Play other player cards
    private void EventPlayOPCards(Transform playerTransform, string[] cards)
    {
        int multipler = (int)Mathf.Ceil(cards.Length / 2);

        for (int i = 0; i < cards.Length; i++)
        {
            SelectableCard card = NGUITools.AddChild(playedCardHolder.gameObject,
                                                     Resources.Load(Global.SCREEN_PATH + "/GameScreen/SelectableCard", typeof(GameObject)) as GameObject).GetComponent <SelectableCard>();
            playedCards.Add(card);
            card.Init(GetCardTexture(cards[i]));
            card.transform.position = playerTransform.position;
            float rotateZ = Random.Range(0, cardMaxRotateZ);
            if (i < multipler)
            {
                card.PlayCard(playedCardHolder, new Vector3(-(multipler - i) * cardSpaceX, 0, 0), new Vector3(0, 0, rotateZ), false);
            }
            else
            {
                card.PlayCard(playedCardHolder, new Vector3((i - multipler) * cardSpaceX, 0, 0), new Vector3(0, 0, -rotateZ), false);
            }
        }
        SortCardDepth(playedCards);
    }
Пример #2
0
 public override void StartNewGame()
 {
     // Init user cards
     for (int i = 0; i < userCards.Count; i++)
     {
         GameObject tempCard = NGUITools.AddChild(cardHolder.gameObject, Resources.Load(Global.SCREEN_PATH + "/GameScreen/SelectableCard", typeof(GameObject)) as GameObject);
         tempCard.name = i.ToString();
         // UI2DSprite card = tempCard.GetComponent<UI2DSprite>();
         // card.sprite2D = GetCardTexture(userCards[i]);
         SelectableCard tempSelectableCard = tempCard.GetComponent <SelectableCard>();
         tempSelectableCard.Init(GetCardTexture(userCards[i]), true);
         userSelectableCards.Add(tempSelectableCard);
         tempSelectableCard.eventTrigger.inputParams = new object[] { tempSelectableCard };
         EventDelegate.Set(tempSelectableCard.eventTrigger.onClick, delegate() { SelectCard((SelectableCard)tempSelectableCard.eventTrigger.inputParams[0]); });
     }
     // Sort card depth to display (card on the right is on top)
     SortCardDepth(userSelectableCards);
     cardHolder.Reposition();
     for (int i = 0; i < userSelectableCards.Count; i++)
     {
         Utils.SetActive(userSelectableCards[i].gameObject, false);
         StartCoroutine(ShowCard(i));
     }
 }