public override void Spawn(List <Vector2Int> region, LevelGenerator levelGenerator) { int spikeNum = 0; bool uniform = (Random.Range(0, 2) == 0); float direction = (Random.Range(0, 2) == 0 ? 1 : -1); // Generate the trap, making sure we're not generating out of turn for (int posIdx = 0; posIdx < region.Count; ++posIdx) { Vector2Int pos = region[posIdx]; if (levelGenerator.collisionMap.SpaceMarking(pos.x, pos.y) == 0) { GameObject trapObj = levelGenerator.PlaceMapPrefab("SpikeTrap", pos.x, pos.y); SpikeTrap spikes = trapObj.GetComponent <SpikeTrap>(); levelGenerator.ClearFloorDecorations(pos); if (!uniform) { spikes.timeOffset = 0.25f * spikeNum * direction; } ++spikeNum; } } }
public override void Spawn(List <Vector2Int> region, LevelGenerator levelGenerator) { // Generate the trap, always leaving at least one space as a hole int hole = Random.Range(0, region.Count); for (int posIdx = 0; posIdx < region.Count; ++posIdx) { if (posIdx == hole) { continue; } Vector2Int pos = region[posIdx]; if (levelGenerator.collisionMap.SpaceMarking(pos.x, pos.y) == 0) { GameObject trapObj = levelGenerator.PlaceMapPrefab("LavaTrap", pos.x, pos.y); LavaTrap razers = trapObj.GetComponent <LavaTrap>(); levelGenerator.ClearFloorDecorations(pos); } } }