Problems with array "shuffle bag"

Hi guys, so… I’m trying to create an array (dialogArray) to store random values (randomDialog) BUT only once for each value, that way the random value never repeat itself.
What should come out of it is a value to be used on another part of the script to choose a dialogue (actualDialog).

But it seems that the random values are never stored (dialogArray.Add(randomDialog):wink: and so the code keeps running the same numbers as if they were never picked before.

Thanks!

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class init : MonoBehaviour {

	private int randomDialog;
	public List<int> dialogArray;
	private int actualDialog = 0;

	void Awake()
	{
		Dialoguer.Initialize();
	}

	// Use this for initialization
	void Start () 
	{

	}
	void getRandomDialog()
	{
		randomDialog = Random.Range(0,11);
	}

	// Update is called once per frame
	void Update ()
	{
		dialogArray.Add(40);
		if(Input.GetKeyDown("space"))
		{
			getRandomDialog();
			Debug.Log(randomDialog);
			for( int i=1; i < 8; i++)
			{
				if(randomDialog == dialogArray*)*
  •  		{*
    
  •  			Debug.Log("equal");*
    
  •  			return;*
    
  •  		}*
    

_ else if(randomDialog != dialogArray*)_
_
{_
_
break;_
_
}_
_
}_
_
dialogArray.Add(randomDialog);*_

* Debug.Log(“Pass”);*
* actualDialog = randomDialog;*
* Debug.Log(actualDialog);*
* }*

* }*

So,try this one:

void Randomize_Cannons()
    {
        var current_Cannons = Cannons;
        List<GameObject> randominzed_Cannons = new List<GameObject>();
        while(current_Cannons.Count > 0)
        {
            var _ind = Random.Range(0, current_Cannons.Count);
            randominzed_Cannons.Add(current_Cannons[_ind]);
            current_Cannons.RemoveAt(_ind);
        }
        Cannons = randominzed_Cannons;
    }

Why you don’t try to reset your logic after some time? Or some ‘event’, ‘trigger’ inside the game?