public void ActOnCardPair(PlayingCardController card1, PlayingCardController card2) { // Handle two run cards if ((card1.cardType == CardType.RunLeft || card1.cardType == CardType.RunRight) && (card2.cardType == CardType.RunLeft || card2.cardType == CardType.RunRight)) { // Sum up the powers and make them the end result float card1RelPower = ((card1.cardType == CardType.RunLeft) ? -1 : 1) * card1.cardPower; float card2RelPower = ((card2.cardType == CardType.RunLeft) ? -1 : 1) * card2.cardPower; float relativeSumPower = card1RelPower + card2RelPower; Direction sumDirection = (relativeSumPower < 0) ? Direction.LEFT : Direction.RIGHT; if (relativeSumPower == 0) { // Do nothing for zero sum return; } ActionRun(sumDirection, Mathf.Abs(relativeSumPower)); } else { int multiplier = 1; // Jump level 2 doubles a move if (card1.cardType == CardType.JumpHigh || card2.cardType == CardType.JumpHigh) { multiplier = 2; } ActOnCard(card1, multiplier); ActOnCard(card2, multiplier); } }
public void ActivateCard(PlayingCardController card) { mPlayer.ActOnCard(card); mDiscardPile.AddToDiscard(card.gameObject); PlayAudio(AudioCategory.CardPlay); DiscardHand(); }
public void ActOnCard(PlayingCardController card, int multiplier = 1) { Debug.Log("Player acting on card: " + card.gameObject.name); switch (card.cardType) { case CardType.RunLeft: ActionRunLeft(card.cardPower * multiplier); break; case CardType.RunRight: ActionRunRight(card.cardPower * multiplier); break; case CardType.JumpLow: ActionJumpLow(); break; case CardType.JumpHigh: ActionJumpHigh(); break; case CardType.Block: break; } }
private GameObject MakeCard() { // Random for now GameObject result = Instantiate(PREFAB_CARD); PlayingCardController card = result.GetComponent <PlayingCardController>(); float roll = Random.Range(0.0f, 1.0f); // TODO: Actually not make this random because random is terrible if (roll < 0.25) { card.cardType = CardType.JumpLow; } else if (roll < 0.5) { card.cardType = CardType.RunLeft; card.cardPower = Random.Range(1, 6); } else if (roll < 0.75) { card.cardType = CardType.RunRight; card.cardPower = Random.Range(1, 6); } else { card.cardType = CardType.JumpHigh; } Debug.Log("New card created: " + card.cardType + ", " + card.cardPower); result.name = string.Format("card_{0}_{1}", card.cardType, card.cardPower); return(result); }
public void ConsumeCard(PlayingCardController card, bool isFirst = true) { Vector3 targetDir = ((isFirst) ? Vector3.right : Vector3.left) * 50.0f; Vector3 targetPosition = mPlayZone.transform.position + targetDir; // Move to the "consume combo!" position, then callback onCardComsumed iTween.MoveTo(card.gameObject, iTween.Hash("position", targetPosition, "time", 0.45f, "oncomplete", "onCardConsumed", "oncompletetarget", gameObject, "oncompleteparams", card)); }
public void ActivateCardPair(GameObject firstCard, GameObject secondCard) { PlayingCardController card1 = firstCard.GetComponent <PlayingCardController>(); PlayingCardController card2 = secondCard.GetComponent <PlayingCardController>(); Debug.Log("Combining cards: " + firstCard.name + " + " + secondCard.name); PlayAudio(AudioCategory.CardPlay); mPlayer.ActOnCardPair(card1, card2); ConsumeCard(card1); ConsumeCard(card2, false); DiscardHand(); }
private GameObject MakeCard(CardType type, int power = -1) { // Random for now GameObject result = Instantiate(PREFAB_CARD); PlayingCardController card = result.GetComponent <PlayingCardController>(); card.cardType = type; card.cardPower = power; card.LoadAsset(); Debug.Log("New card created: " + card.cardType + ", " + card.cardPower); result.name = string.Format("card_{0}_{1}", card.cardType, card.cardPower); return(result); }
public void onCardConsumed(PlayingCardController card) { mDiscardPile.AddToDiscard(card.gameObject); }