I have a segment of code that emulates drawing a card and removing it from the deck scriptable object. It used to work as intended but after I removed the script and put it back, it is no longer removing the card from the deck. Any ideas?
void Update () {
if (Input.GetKeyDown (KeyCode.N)) {
//check for deck out
if(playerDeck.deckCard.Count == 0){
Debug.Log("No more cards in the deck!");
}
else{
int deckMax = playerDeck.deckCard.Count;
string cardImage;
int rndSelector;
rndSelector = Random.Range (0,deckMax);
cardImage = playerDeck.deckCard[rndSelector].card_img;
//Create GameObject
GameObject go = new GameObject ("cardManifest" + cardcount);
SpriteRenderer renderer = go.AddComponent<SpriteRenderer> ();
go.AddComponent<BoxCollider2D> ();
go.AddComponent<hand_mouseover>();
//Render Sprite
Sprite cardSprites = Resources.Load<Sprite>("Images/" + cardImage);
renderer.sprite = cardSprites;
Debug.Log ("Drew " + playerDeck.deckCard[rndSelector].card_name);
//Transform and Distribute
go.transform.localScale = new Vector3 (cardScale, cardScale, cardScale);
//go.transform.localPosition = new Vector3 (DistPos, 0.5f, 0f);
cardcount = cardcount + 1;
//distrubte cards with method
distributeCards ();
//add to hand...
Scriptable_CardObject drawnCard = playerDeck.deckCard[rndSelector];
playerHand.Add (drawnCard);
infoText.text= "Drew " + drawnCard.card_name;
//Remove card drawn from the deck array
playerDeck.deckCard.RemoveAt (rndSelector);
}
}
}
Thanks!