public void CreateCells(int width, int height) { int cellsCount = width * height; NativeArray <Entity> cellsArray = new NativeArray <Entity>(cellsCount, Allocator.Temp); EntityArchetype archetype = HexCellArchetype.GetArchetype(); entityManager.CreateEntity(archetype, cellsArray); for (int z = 0, i = 0; z < height; z++) { for (int x = 0; x < width; x++) { int elevation = UnityEngine.Random.Range(0, 6); entityManager.SetComponentData( cellsArray[i], CoordinatesService.CreateFromOffset(x, z) ); var pos = GetCellPosition(x, elevation, z); entityManager.SetComponentData( cellsArray[i], new Translation { Value = pos } ); entityManager.SetComponentData( cellsArray[i], new ColorComponent { Value = HexColor.GetRandomColor() } ); entityManager.SetComponentData( cellsArray[i], new Elevation { Value = elevation } ); i++; } } }
public void Get_Random_Color_From_Color_array() { // Set Color[] possibleColors = { Color.white, Color.green, Color.yellow, Color.gray, Color.blue }; // Act Color color = HexColor.GetRandomColor(); // Assert Assert.True( Array.Exists( possibleColors, possibleColor => possibleColor == color ) ); }