public void addNewObject(GroundBlock obj) { spawnedObjects.Add(obj); if (spawnedObjects.Count > maxPoolObjects) { GameObject.Destroy(spawnedObjects[0].gameObject); spawnedObjects.RemoveAt(0); } }
private void spawnNewMapSegment() { Vector2 spawnPos = getNextSpawnPos(); GroundBlock temp = Instantiate(blocks.getNewBlock(), spawnPos, Quaternion.identity).GetComponent <GroundBlock>(); groundSegmentPool.addNewObject(temp); currentMapEnd = spawnPos.x + temp.width; }
private void addCoordinates(GroundBlock ground, ref char[][] snapshot, Vector3 basePos) { Vector2 blockOffset = ground.transform.position - basePos; foreach (Vector2 localCoord in ground.getCoordList()) { Vector2 coord = blockOffset + localCoord; if (coordIsOutOfRange(coord)) { continue; } int xGrid = Mathf.RoundToInt(coord.x / GameConstants.PlayerSight.SIZE); int yGrid = Mathf.RoundToInt(coord.y / GameConstants.PlayerSight.SIZE); if (xGrid >= GameConstants.PlayerSight.COLS || yGrid >= GameConstants.PlayerSight.ROWS) { continue; } snapshot[GameConstants.PlayerSight.ROWS - yGrid - 1][xGrid] = GameConstants.PlayerSight.GROUND_SIGN; } }