public static GroundMap BuildBarMap(GroundMap endingMap) { GroundMap barMap = new GroundMap(); GroundBlockMap barBlock1 = new GroundBlockMap(); barBlock1.size = endingMap.GetLastBlock().size + new IntVector2(Random.Range(10, 20), Random.Range(5, 10)); barBlock1.position = endingMap.GetLastBlock().position + new IntVector2(-Random.Range(5, 10), endingMap.GetLastBlock().size.y); barBlock1.BuildBar(); barBlock1.GrowPines(10); barBlock1.AddSpots(6); barMap.AddBlock(barBlock1); GroundBlockMap barBlock2 = new GroundBlockMap(); barBlock2.size = barBlock1.size + new IntVector2(Random.Range(10, 20), 20); barBlock2.position = barBlock1.position + new IntVector2(-Random.Range(5, 10), barBlock1.size.y); barBlock2.GrowPines(15); barBlock2.AddSpots(10); barMap.AddBlock(barBlock2); return(barMap); }
public static GroundMap GenerateRandom(int blocksCount = 40) { GroundMap newGround = new GroundMap(); while (newGround.count < blocksCount) { GroundBlockMap newBlock = GroundBlockMap.GenerateRandom(); GroundBlockMap lastBlock = newGround.GetLastBlock(); if (lastBlock != null) { int xR = Random.Range(-newBlock.size.x + 3, lastBlock.size.x - 3); newBlock.position = lastBlock.position + new IntVector2(xR, lastBlock.size.y); } newBlock.AddBorder(BorderDirction.South); newGround.AddBlock(newBlock); } return(newGround); }