protected void ShowCard(DeckOfCards.Card card, GameObject cardObj, int pos) { cardObj.name = card.ToString(); cardObj.transform.SetParent(handBase.transform); List <GameObject> cardList = new List <GameObject>(); foreach (Transform cardTransform in handBase.transform) { cardList.Add(cardTransform.gameObject); } cardObj.GetComponent <RectTransform>().localScale = new Vector2(1, 1); /*cardObj.GetComponent<RectTransform>().anchoredPosition = * new Vector2( * xOffset + pos * 110, * yOffset);*/ cardObj.GetComponentInChildren <Text>().text = deck.GetNumberString(card); cardObj.GetComponentsInChildren <Image>()[1].sprite = deck.GetSuitSprite(card); for (int i = 0; i < cardList.Count; i++) { float spacing = Mathf.Clamp(110, 0, 330 / Mathf.Clamp(cardList.Count - 1, 1, Mathf.Infinity)); cardList[i].GetComponent <RectTransform>().anchoredPosition = new Vector2(spacing * (i - (cardList.Count - 1) / 2f), yOffset); } }
public void HitMe() { if (!stay) { newCard = deck.DrawCard(); newCardObject = Instantiate(Resources.Load("prefab/Card")) as GameObject; ShowCard(newCard, newCardObject, viewingBase, 1); ActivateButtons(true); } }
protected void ShowCard(DeckOfCards.Card card, GameObject cardObj, int pos) { cardObj.name = card.ToString(); cardObj.transform.SetParent(handBase.transform); cardObj.GetComponent <RectTransform>().localScale = new Vector2(1, 1); cardObj.GetComponent <RectTransform>().anchoredPosition = new Vector2( xOffset + pos * 110, yOffset); cardObj.GetComponentInChildren <Text>().text = deck.GetNumberString(card); cardObj.GetComponentsInChildren <Image>()[1].sprite = deck.GetSuitSprite(card); }
public void HitMe() { if (!stay) { DeckOfCards.Card card = deck.DrawCard(); GameObject cardObj = Instantiate(Resources.Load("prefab/Card")) as GameObject; ShowCard(card, cardObj, hand.Count); hand.Add(card); ShowValue(); } }
public void DealMeIn(List <DeckOfCards.Card> currentHand, Transform handBase, Text total, int currentHandValue) { if (!stay) { DeckOfCards.Card card = deck.DrawCard(); GameObject cardObj = Instantiate(Resources.Load("prefab/Card")) as GameObject; cards.Add(cardObj); ShowCard(card, cardObj, handBase, currentHand.Count); currentHand.Add(card); ShowValue(currentHand, handBase, total, currentHandValue); } }
public void HitMeWithAce() { if (Skills.mP < 3) { return; } Skills.mP -= 3; DeckOfCards.Card card = new DeckOfCards.Card(DeckOfCards.Card.Type.A, (DeckOfCards.Card.Suit)Random.Range(0, 4)); GameObject cardObj = Instantiate(Resources.Load("prefab/Card")) as GameObject; ShowCard(card, cardObj, hand.Count); hand.Add(card); ShowValue(); }