private void ClearUDPList(ref List <UnitDisplayBlock> blocks, int?count = null) { if (!count.HasValue) { count = blocks.Count; } if (count.Value < 0) { return; } for (int i = 0; i < count.Value; i++) { UnitDisplayBlock gb = blocks[blocks.Count - 1]; GameObject.Destroy(gb.gameObject); blocks.RemoveAt(blocks.Count - 1); } }
private void GenProgram() { dewllingCells.Clear(); serviceCells.Clear(); foreach (ModuleGrid c in moduleCells) { Vector3 pos = c.Position; Vector3[] vects = c.Vects; Vector3 size = c.Size; Color dewllingColor = new Color(0.8f, 0.6f, 0); if (size[2] < 12) { GenDellingCase1(c, dewllingColor); } else { GenDellingCase2(c, dewllingColor); } } int dif = UDP_wet.Count - dewllingCells.Count; ClearUDPList(ref UDP_wet, dif); for (int i = 0; i < dewllingCells.Count; i++) { ModuleGrid m = dewllingCells[i]; if (i <= UDP_wet.Count) { UnitDisplayBlock udpb = new UnitDisplayBlock(m.Position, m.Size); udpb.Forward = m.Forward; UDP_wet.Add(udpb); } else { UDP_wet[i].Size = m.Size; UDP_wet[i].Position = m.Position; } } }