void InitBlue() { DDBlue.poolOn = new List <DDBlue>(); DDBlue.poolOff = new List <DDBlue>(); int wallsToBuild = 32; while (wallsToBuild >= 0) { int dice = Random.Range(0, 64 * 64); if (!wallsInit[dice]) { wallsToBuild--; int y = dice / 64; int x = dice % 64; DDBlue blue = DDBlue.CreateFromPool(); blue.transform.localPosition = new Vector3(x, y, 0) * 16; walls[y * 64 + x] = true; for (int i = -3; i < 3; ++i) { for (int j = -3; j < 3; ++j) { if (y + j >= 0 && y + j < 64 && x + i >= 0 && x + i < 64) { wallsInit[(y + j) * 64 + (x + i)] = true; } } } } } }
public void FreePools() { DDRed.FreePools(); DDYellow.FreePools(); DDWhite.FreePools(); DDBlue.FreePools(); ExplodeAnim.FreePools(); }
static public DDBlue CreateFromPool() { DDBlue result = null; if (poolOff.Count == 0) { GameObject tmp = Instantiate <GameObject>(DDMapCreator.instance.squareReferences.blueRef.gameObject); tmp.transform.SetParent(DDMapCreator.instance.transform); tmp.transform.localScale = Vector3.one; result = tmp.GetComponent <DDBlue>(); poolOn.Add(result); } else { result = poolOff[0]; poolOn.Add(result); poolOff.RemoveAt(0); } return(result); }