,Array Sprite for various images
I want to create a card game. When I press the "q" key, the cards must change their sprite. To do this I created an array that stores the sprites that have already played. The problem is that when I assign the script to each card, and I put play, several arrays with different values are created. How can I unify all the arrays without using several scripts?
     public void RandomCarta()
     {
         spritte = sprites[Random.Range(0, sprites.Length)];
         for ( int i = 0; i < NumJugados.Length; i++) {
             if (NumJugados.Length !=0 &&  spritte == NumJugados[i]) {
                 spritte = sprites[Random.Range(0, sprites.Length)];
                 i = 0;
             };
         };
 
         Invoke ("ExtenderArray", 0);
         int Largo = NumJugados.Length-1    ;
         NumJugados[Largo] = spritte;// ME TRABO TODO ESTO
         imagen.sprite = spritte;
         //Debug.Log(NumJugados[Largo]);
         for(int i = 0; i<=Largo; i++){
             Debug.Log(NumJugados[i]);
         };
     }
 
     public void ExtenderArray()
     {
         int Largo = NumJugados.Length+1 ;
         Sprite[] ArrayExtendido = new Sprite[Largo];
         for ( int i = 0; i < NumJugados.Length; i++){
             ArrayExtendido[i] = NumJugados[i];
             };
         NumJugados = new Sprite[Largo];
         for ( int i = 0; i < ArrayExtendido.Length; i++){
             NumJugados[i] = ArrayExtendido[i];
         };
     }
 
 }
 
               Sorry for my bad English.
               Comment
              
 
               
              Your answer