// Affects whole hand ------------------------------------------------------------------------- public void InitHand() { // Find the first card reference that isn't null, if any exists, and make currently selected for (var i = 0; i < _cards.Count; i++) { if (_cards[i] != null) { _selected = _cards[i]; _selectedIndex = i; break; } } // TODO - any other initialization stuffs. }
public void SetCurrentSelect(CardSO newSelection, int newIndex) { _selected = newSelection; _selectedIndex = newIndex; // Update the player visuals to reflect equipment changes if (PlayerVisuals != null) { PlayerVisuals.RaiseEvent(); } if (UICurrentCardChange != null) { UICurrentCardChange.RaiseEvent(_selectedIndex); } }
public void PrevCard() { _selectedIndex = (_selectedIndex - 1 + _cards.Count) % _cards.Count; _selected = _cards[_selectedIndex]; // Update the player visuals to reflect equipment changes if (PlayerVisuals != null) { PlayerVisuals.RaiseEvent(); } if (UICurrentCardChange != null) { UICurrentCardChange.RaiseEvent(_selectedIndex); } }
void ChooseFollowUpCard(bool left) { //if left = true then we choose from the left follow up cards //if left = false then we choose from the right follow up cards if (left) { int randFollowUpCardIndex = Random.Range(0, currentlySelectedCard.leftFollowUpCards.Length); currentlySelectedCard = currentlySelectedCard.leftFollowUpCards[randFollowUpCardIndex]; } else { int randFollowUpCardIndex = Random.Range(0, currentlySelectedCard.rightFollowUpCards.Length); currentlySelectedCard = currentlySelectedCard.rightFollowUpCards[randFollowUpCardIndex]; } }
void Update() { if (Input.GetKeyDown(KeyCode.T)) { card = cardList.cards[0]; } else if (Input.GetKeyDown(KeyCode.Y)) { card = cardList.cards[1]; } if (Input.GetKeyDown(KeyCode.Space)) { cardImage.sprite = card.cardImage; cardName.text = card.cardName; } }
public void PickCard(CardSO card) { if (card.cardType == CardSO.CardType.attack) { weaponSlot = card; } if (card.cardType == CardSO.CardType.defense) { armorSlot = card; } if (card.cardType == CardSO.CardType.special) { specialSlot = card; } }
void ChooseNonFollowUpCard() { int randCardIndex = Random.Range(0, cards.Length); CardSO nextCard = cards[randCardIndex]; if (currentlySelectedCard != null) { //Loop to ensure that the same card cannot appear again while (nextCard == currentlySelectedCard) { randCardIndex = Random.Range(0, cards.Length); nextCard = cards[randCardIndex]; } } currentlySelectedCard = nextCard; }
/// <summary> Resets this hand by clearing card data. Warning! Will set CurrentlySelected to null. </summary> public void ResetHand() { for (int i = 0; i < _cards.Count; i++) { _cards[i] = null; } _selected = _cards[0]; _selectedIndex = 0; // Update the player visuals to reflect equipment changes if (PlayerVisuals != null) { PlayerVisuals.RaiseEvent(); } if (UICurrentCardChange != null) { UICurrentCardChange.RaiseEvent(_selectedIndex); } }
// void Update() {} // void FixedUpdate() {} #endregion #region Class Methods private void UpdateCardData(CardSO cardData, int idToCheck) { if (cardData == null) { return; } if (idToCheck != gameObject.GetInstanceID()) { return; } _cardData = cardData; if (cardName != null) { gameObject.name = "Card - " + _cardData.name; cardName.text = _cardData.name; } }
public void CardPicked(CardSO card) { if (card.cardType == CardSO.CardType.attack) { offensiveCard.image.sprite = card.image; ofCardSelected = true; } if (card.cardType == CardSO.CardType.defense) { defensiveCard.image.sprite = card.image; defCardSelected = true; } if (card.cardType == CardSO.CardType.special) { specialCard.image.sprite = card.image; spCardSelected = true; } anim.SetBool("isSelectingCards", false); }
private void GenerateCards() { int cardCount = gameDatas.rows * gameDatas.columns; for (int i = 0; i < cardCount; i++) { GameObject card = Instantiate(cardPrefab, this.transform); card.transform.name = "Card (" + i.ToString() + ")"; cardControllers.Add(card.GetComponent <CardController>()); } for (int i = 0; i < cardCount / 2; i++) { CardSO randomCard = cardGridGenerator.GetRandomAvailableCardSO(); SetRandomCardToGrid(randomCard); CardSO randomCardPair = cardGridGenerator.GetCardPairSO(randomCard.cardName); SetRandomCardToGrid(randomCardPair); } }
public void Setup(CardSO cardData) { graphic.sprite = cardData.graphic; description.text = cardData.description; cardName.text = cardData.name; value.text = cardData.value.ToString(); cost.text = cardData.cost.ToString(); switch (cardData.type) { case CardType.Attack: cardMold.sprite = cardColoredMold[0]; break; case CardType.Defense: cardMold.sprite = cardColoredMold[1]; break; case CardType.Support: cardMold.sprite = cardColoredMold[2]; break; } }
private void FillRandomly(List <CardGrid> cardGridList) { int[] test = new int[cardGridList.Count]; List <CardSO> cardList = GameManager.i.listOfAssets.AllCards; List <CardSO> tweenCards = new List <CardSO>(); for (int i = 0; i < test.Length; i++) { test[i] = i; } int[] testRand = Subkiro.GetRandomArray(test.Length, test.Length); for (int i = 0; i < test.Length / 2; i++) { CardSO random = cardList[Random.Range(0, cardList.Count - 1)]; tweenCards.Add(random); tweenCards.Add(random); } //Debug.Log("TweenCount -->" + tweenCards.Count); // Debug.Log("CardlistCount -->" + cardGridList.Count); // Debug.Log("int Aerray with randoms -->" + test.Length); for (int i = 0; i < test.Length; i++) { int x = cardGridList[testRand[i]].x; int y = cardGridList[testRand[i]].y; GameObject card = tweenCards[i].CreateCard(grid, x, y); card.transform.parent = this.transform; card.transform.position = grid.GetWorldPosition(x, y) + new Vector3(cardSize, cardSize) * .5f; grid.GetGridObject(x, y).SetValue(card.GetComponent <Card>()); } }
void OnCardChosen(CardSO card) { // here is where we apply the new settings if (currentPlayer == Players.A) { // normal way around for player A applyEffectToPlayer(ref gunStateA, card.positiveType, card.positiveValue, true); applyEffectToPlayer(ref gunStateA, card.negativeType, card.negativeValue, false); // opposite way around for player B applyEffectToPlayer(ref gunStateB, card.positiveType, card.positiveValue, false); applyEffectToPlayer(ref gunStateB, card.negativeType, card.negativeValue, true); } else { // normal way around for player B applyEffectToPlayer(ref gunStateB, card.positiveType, card.positiveValue, true); applyEffectToPlayer(ref gunStateB, card.negativeType, card.negativeValue, false); // opposite way around for player A applyEffectToPlayer(ref gunStateA, card.positiveType, card.positiveValue, false); applyEffectToPlayer(ref gunStateA, card.negativeType, card.negativeValue, true); } sm.ChangeState(GameStates.Ready); }
private void Start() { cardList = Resources.Load <CardListSO>(typeof(CardListSO).Name); card = cardList.cards[0]; }
public void SetCard(CardSO scriptable) { cardSO = Instantiate(scriptable); rend.sprite = cardSO.cardSprite; cardName = rend.sprite.name; }
public static void ApplyCardIcon(this Image image, CardSO cardSO) { image.sprite = cardSO.Icon; }