/// <summary> /// Creation of new pool and adding this to our local pools, then saving manager /// </summary> void CreateNewPoolPressed() { string newName = "GeneratedPool"; string addingPrefix = ""; int j = 0; int i = 0; bool founded = true; while (founded) { founded = false; for (i = 0; i < pools.Count; i++) { if (pools[i].poolName == newName + addingPrefix) { founded = true; j++; addingPrefix = j.ToString(); break; } } } F3DPoolContainer newCont = new F3DPoolContainer(); newCont.poolName = newName + addingPrefix; currentPoolName = newName + addingPrefix; pools.Add(newCont); string[] poolNamesTemp = new string[poolNames.Length + 1]; int n = 0; for (n = 0; n < poolNamesTemp.Length - 1; n++) { poolNamesTemp[n] = poolNames[n]; } poolNamesTemp[n] = newName + addingPrefix; poolNames = poolNamesTemp; SaveManager(); if (pools.Count == 1) { index = 0; } else { index = pools.Count - 1; } LoadAllVariables(); }
/// <summary> /// Checking length of pool's arrays /// </summary> /// <param name="pool">Selected pool</param> void CheckForArraysLength(F3DPoolContainer pool) { int i; if (pool.templates.Length != pool.poolLength.Length) { int[] newArray = new int[pool.templates.Length]; for (i = 0; i < pool.templates.Length; i++) { if (i < pool.poolLength.Length) { newArray[i] = pool.poolLength[i]; } else { newArray[i] = 0; } } pool.poolLength = newArray; currentBaseCount = newArray; } if (pool.templates.Length != pool.poolLengthMax.Length) { int[] newArray = new int[pool.templates.Length]; for (i = 0; i < pool.templates.Length; i++) { if (i < pool.poolLengthMax.Length) { newArray[i] = pool.poolLengthMax[i]; if (newArray[i] < pool.poolLength[i]) { newArray[i] = pool.poolLength[i]; } } else { newArray[i] = pool.poolLength[i]; } } pool.poolLengthMax = newArray; currentMaxCount = pool.poolLengthMax; } }
/// <summary> /// Setting templates count in pool. /// </summary> /// <param name="pool">Selected pool</param> /// <param name="count">New count</param> void SetItemsCount(F3DPoolContainer pool, int count) { int i; if (pool == null) { pool = new F3DPoolContainer(); } Transform[] newTemplates = new Transform[count]; for (i = 0; i < count; i++) { if (i < pool.templates.Length) { newTemplates[i] = pool.templates[i]; } else { newTemplates[i] = null; } } pool.templates = newTemplates; CheckForArraysLength(pool); }
/// <summary> /// Checking inputed data of local pools /// </summary> /// <param name="pool">Selected pool</param> void CheckForArraysData(F3DPoolContainer pool) { int i; int[] newArray1 = new int[pool.templates.Length]; for (i = 0; i < pool.templates.Length; i++) { if (i < pool.poolLength.Length) { newArray1[i] = pool.poolLength[i]; } else { newArray1[i] = 0; } } int[] newArray2 = new int[pool.templates.Length]; for (i = 0; i < pool.templates.Length; i++) { if (i < pool.poolLengthMax.Length) { newArray2[i] = pool.poolLengthMax[i]; if (newArray2[i] < pool.poolLength[i]) { newArray2[i] = pool.poolLength[i]; } } else { newArray2[i] = pool.poolLength[i]; } } pool.poolLengthMax = newArray2; currentMaxCount = pool.poolLengthMax; }