public void MoveMap(Vector3 delta) { if (GameController.Singleton.IsMatchRunning) { foreach (var pool in wallSectionPools) { foreach (var wallSection in pool.ActiveItems) { wallSection.transform.position -= delta; if (wallSection.CanDespawn(-playerSeeRadius)) { wallSection.Despawn(); pool.PoolItem(wallSection); } } } while (Mathf.FloorToInt(lastWallSectionSpawned.EndPoint.x) < playerSeeRadius) { WallSection nextWallSection = GetWallSection(Random.value); nextWallSection.Spawn(lastWallSectionSpawned.EndPoint); lastWallSectionSpawned = nextWallSection; } foreach (var scorePoint in scorePointPool.ActiveItemsNonAloc) { scorePoint.transform.position -= delta; } } }
private void BuildMap(float offset, SectionTemplate startSection) { // Start the current at half the length of the start section. Vector2 current = new Vector2(-20f + offset, 0f); WallSection wallSection = wallSectionTemplatePairs[startSection].GetItem(); wallSection.Spawn(current); current = wallSection.EndPoint; lastWallSectionSpawned = wallSection; while (current.x < playerTransform.position.x + playerSeeRadius) { wallSection = wallSectionTemplatePairs[defaultSectionTemplate].GetItem(); wallSection.Spawn(current); current = wallSection.EndPoint; lastWallSectionSpawned = wallSection; } }