本文整理汇总了C#中Card.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Card.GetComponent方法的具体用法?C# Card.GetComponent怎么用?C# Card.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card.GetComponent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDrop
public void OnDrop(PointerEventData eventData)
{
if (GameObject.Find("Player").GetComponent<whoseTurn>().isMyTurn) // is my Turn ?
{
d = eventData.pointerDrag.GetComponent<Card>();
if (this.name != "EnemiesHand" && this.name != "EnemiesArchers" && this.name != "EnemiesMelee")
{
if (this.name == d.getProperties().type.ToString())
if (checkIfEnoughResources(player.getResources(), d.getResources()))
{
drainResources(player.getResources(), d.getResources());
GameObject.Find("Gracz").GetComponent<Player>().cardsInHand--;
d.parentToReturnTo = this.transform;
PhotonView photonView = PhotonView.Get(this);
photonView.RPC("updateMana", PhotonTargets.Others, d.getResources().like, d.getResources().snap, d.getResources().tweet);
photonView.RPC("ChangeCardParent", PhotonTargets.Others, this.name, d.GetComponent<Properties>().CardId);
}
}
}
else
{
Transform panel = GameObject.Find("Canvas").transform.FindChild("Waiting");
panel.GetComponent<Text>().text = "Nie twoja tura !";
}
}
示例2: AddCard
public bool AddCard(Card card)
{
if (card != null)
{
if (card.ParentCardSlot != null)
{
card.ParentCardSlot.RemoveCard(card);
}
card.ParentCardSlot = this;
CardList.Add(card);
card.TargetTransform.rotation = transform.rotation;
card.TargetTransform.Rotate(card.TargetTransform.forward, Random.Range(-.4f, .4f), Space.Self);
float cardHeight = card.GetComponent<BoxCollider>().size.z;
card.TargetTransform.position = transform.position;
if (_inverseStack)
{
card.TargetTransform.Translate(new Vector3(0, 0, CardList.Count * (float)cardHeight) * -1f, Space.Self);
}
else
{
card.TargetTransform.Translate(new Vector3(0, 0, CardList.Count * (float)cardHeight), Space.Self);
}
card.SetDamp(_positionDamp, _rotationDamp);
return true;
}
else
{
return false;
}
}
示例3: AddCard
public override void AddCard(Card card, float delay = 0f)
{
var y = (float)stack.Count * -0.2f;
var z = (float)stack.Count * -0.1f;
Vector3 pos = transform.position + new Vector3(0f, y, z);
iTween.MoveTo(card.gameObject, iTween.Hash("position", pos, "time", 0.125f, "delay", delay));
stack.Add(card);
card.GetComponent<SpriteRenderer>().sortingOrder = stack.Count;
card.currentSlot = this;
}
示例4: AddChild
public bool AddChild(Card card)
{
cards.Add(card.gameObject);
foreach (var c in cards)
c.transform.SetParent(transform.parent);
foreach (var c in cards)
{
c.transform.SetParent(transform);
card.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);
}
card.parent = this;
FlexibleHeight();
return true;
}
示例5: dealCards
// Selects and places cards, then initializes the game.
void dealCards()
{
// Remove any existing cards on the board.
GameObject[] dealtCards = GameObject.FindGameObjectsWithTag("DealtCard");
foreach (GameObject dealtCard in dealtCards) {
Destroy(dealtCard);
}
int numberOfCards = this.boardCardWidth * this.boardCardWidth;
int numberOfCardPairs = numberOfCards / 2;
Card[] selectedCards = new Card[numberOfCards];
string[] suitNames = Enum.GetNames(typeof(Suits));
string[] rankNames = Enum.GetNames(typeof(Ranks));
int deckSize = suitNames.Length * rankNames.Length;
// Cards should all have the same initial facing (face-down).
Vector3 cardRotation = new Vector3(180.0f, 0.0f, 0.0f);
// Selects cards suits/ranks to be used in the game.
System.Random rng = new System.Random();
// Creates list of available card positions on the board.
List<int> cardPlacements = new List<int>(numberOfCards);
for (int i = 0; i < numberOfCards; i++) {
cardPlacements.Add(i);
}
// Creates list of available cards to select from.
List<Card> availableCards = new List<Card>(deckSize);
for (int suit = 0; suit < suitNames.Length; suit++) {
for (int rank = 0; rank < rankNames.Length; rank++) {
Card card = new Card(suit, rank);
availableCards.Add(card);
}
}
shuffleDeckAudio.Play();
for (int i = 0; i < numberOfCardPairs; i++) {
// Selects an available card.
int availableCardIndex = rng.Next(availableCards.Count);
selectedCards[i] = availableCards[availableCardIndex];
availableCards.RemoveAt(availableCardIndex);
// Places two copies of each selected card on the board.
for (int j = 0; j < 2; j++) {
// Selects a random place for the next card.
int cardPlacementIndex = rng.Next(cardPlacements.Count);
int cardPlacement = cardPlacements[cardPlacementIndex];
cardPlacements.RemoveAt(cardPlacementIndex);
// Calculates the coordinates of the selected place.
float cardPositionX = this.boardOrigin.x + ((float)cardPlacement % this.boardCardWidth) * this.boardCardSpacingX;
float cardPositionY = this.boardOrigin.y - (float)Math.Floor((double)cardPlacement / this.boardCardWidth) * this.boardCardSpacingY;
Vector3 cardPosition = new Vector3(cardPositionX, cardPositionY, this.cardObject.transform.position.z);
// Generates a card object at the selected position.
GameObject card = Instantiate(this.cardObject) as GameObject;
// Set the deck as the parent for the card.
card.transform.position = cardPosition;
card.transform.Rotate(cardRotation);
card.GetComponent<CardController>().setSuit(selectedCards[i].suit);
card.GetComponent<CardController>().setRank(selectedCards[i].rank);
card.GetComponent<CardController>().updateSprite();
if (debugMode) {
Debug.Log("Instantiating card at position " + cardPlacement + ", coodinates " + cardPosition);
}
}
}
// Initializes game after cards are dealt.
gameController.initializeGame(numberOfCardPairs);
}