private void GenerateIsland(int count, int max) { float percentageToMiddle = Random.Range(0.2f, 0.8f); float radVariance = (360f / max) / 180; float rad = Random.Range(count * radVariance, (1 + count) * radVariance) + radOffset; float xDiff = Mathf.Cos(Mathf.PI * rad) * seaScale.x * percentageToMiddle; float zDiff = Mathf.Sin(Mathf.PI * rad) * seaScale.y * percentageToMiddle; IslandPlace islandPlace = new IslandPlace(); islandPlace.position = new Vector2(xDiff, zDiff); int xVar = Rand.Variance(0, islandSizeVariance); int xSize = islandSize + xVar; int zSize = Rand.Variance(islandSize + xVar / 4, (int)(islandSizeVariance / 1.5)); islandPlace.scale = new Vector2(xSize, zSize); Transform newIsland = Instantiate(island).transform; TreasureIsland treasureIsland = newIsland.GetComponent<TreasureIsland>(); treasureIsland.terrainWidth = xSize; treasureIsland.terrainLength = zSize; treasureIsland.treasureCount = Rand.Variance(treasuresOnIsland, treasureVariance); newIsland.parent = parent; newIsland.position = new Vector3(xDiff, -0.5f, zDiff); placedIslands.Add(islandPlace); }
public void Test1() { int[,] input = { { 1, 0, 0, }, { 1, 0, 0, }, { 1, 9, 1, } }; var result = new TreasureIsland().removeObstacle(0, 0, input); Assert.AreEqual(3, result); }
public void Test3() { int[,] input = { { 1, 1, 0, 1 }, { 0, 0, 0, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 9 } }; var result = new TreasureIsland().removeObstacle(0, 0, input); Assert.AreEqual(-1, result); }
public void BeforeEach() { TreasureIsland = new TreasureIsland(); }