public void EnabledChunk(float _posX, float _posY, bool _enabled) { _posY = Mathf.Abs(_posY) * -1; var chunk = chunkList.Find(x => x.Position.x == _posX && x.Position.y == _posY); if (chunk != null) { chunk.ChunkObject.SetActive(_enabled); } else { chunkList.Add(new Chunk(generator.AddChunk((int)_posX, (int)_posY), new Vector2(_posX, _posY))); } }
private void Start() { chunkList = new List <Chunk>(); generator = GameObject.FindGameObjectWithTag("Core").GetComponent <GenerateLevel>(); chunkList.Add(new Chunk(generator.AddChunk(0, 0), new Vector2(0, 0))); chunkList.Add(new Chunk(generator.AddChunk(0, -1), new Vector2(0, -1))); chunkList.Add(new Chunk(generator.AddChunk(1, 0), new Vector2(1, 0))); chunkList.Add(new Chunk(generator.AddChunk(1, -1), new Vector2(1, -1))); chunkList.Add(new Chunk(generator.AddChunk(-1, 0), new Vector2(-1, 0))); chunkList.Add(new Chunk(generator.AddChunk(-1, -1), new Vector2(-1, -1))); }