Hejka.
Teraz uskuteczniam sobie pewną grę w Unity jednak mam problem. Mam Listę zawierająca w sobie listę i listę tymczasowa tak aby dodawać do niej pewne liczby.
Działą to tak.
Do listy tymczasowej dodaje liczby (1,2,3,4) potem tę listę dodaje z jej wartościami do do listy list. Czyszczę listę tymczasową i wrzucam do niej inne liczby. Znowu dodaje na przechowanie do listy list i czyszczę (te tymczasową). Efekt jest taki że lista list jest wielkości 2 czyli tak jak by powinno ale listy wewnątrz tej listy są puste.
List<List<int>> _listOfPosibleActions = new List<List<int>> ();
List<int> _tmpList = new List<int> ();
//List < int > _listOfPosibleActions = new List<int>();
//int mytmpvariable;
//Debug.Log ("Domniemane pozycje:");
if(_startY == (int)this.transform.position.z){
_tmpList.Add ((int)this.transform.position.x);
_tmpList.Add ((int)this.transform.position.z+1);
_tmpList.Add ((int)this.transform.position.x);
_tmpList.Add ((int)this.transform.position.z+2);
Debug.Log (_tmpList.Count);
_listOfPosibleActions.Add(_tmpList);
_tmpList.Clear ();
foreach (List<int> subList in _listOfPosibleActions)
{
foreach (int item in subList)
{
Debug.Log ("Lista: " + item);
}
}
Debug.Log (_tmpList.Count);
_tmpList.Add ((int)this.transform.position.x-1);
_tmpList.Add ((int)this.transform.position.z+1);
_tmpList.Add ((int)this.transform.position.x+1);
_tmpList.Add ((int)this.transform.position.z+1);
_listOfPosibleActions.Add(_tmpList);
_tmpList.Clear ();
//mytmpvariable = (int)this.transform.position.x;
//_listOfPosibleActions.Add(mytmpvariable);
//Debug.Log ("x:" + mytmpvariable);
//mytmpvariable = (int)this.transform.position.z+1;
//_listOfPosibleActions.Add(new List<int> { (int)this.transform.position.z + 1 });
//_listOfPosibleActions.Add(mytmpvariable);
//Debug.Log ("z:" + mytmpvariable);
//_listOfPosibleActions.Add((int)this.transform.position.x);
//_listOfPosibleActions.Add(new List<int> { (int)this.transform.position.x });
//_listOfPosibleActions.Add(new List<int> { (int)this.transform.position.z + 2 });
//_listOfPosibleActions.Add((int)this.transform.position.z+2);
//_listOfPosibleActions.Add((int)this.transform.position.x);
//_listOfPosibleActions.Add((int)this.transform.position.y);
}