public void Load(MyCubeSize cubeSize, MyObjectBuilderType typeId, string subTypeId) { CubeList.Clear(); var list = new SortedList <string, ComponentItemModel>(); var contentPath = ToolboxUpdater.GetApplicationContentPath(); var cubeDefinitions = SpaceEngineersCore.Resources.CubeBlockDefinitions.Where(c => c.CubeSize == cubeSize); foreach (var cubeDefinition in cubeDefinitions) { var c = new ComponentItemModel { Name = cubeDefinition.DisplayNameText, TypeId = cubeDefinition.Id.TypeId, TypeIdString = cubeDefinition.Id.TypeId.ToString(), SubtypeId = cubeDefinition.Id.SubtypeName, TextureFile = (cubeDefinition.Icons == null || cubeDefinition.Icons.First() == null) ? null : SpaceEngineersCore.GetDataPathOrDefault(cubeDefinition.Icons.First(), Path.Combine(contentPath, cubeDefinition.Icons.First())), Time = TimeSpan.FromSeconds(cubeDefinition.MaxIntegrity / cubeDefinition.IntegrityPointsPerSec), Accessible = cubeDefinition.Public, Mass = SpaceEngineersApi.FetchCubeBlockMass(cubeDefinition.Id.TypeId, cubeDefinition.CubeSize, cubeDefinition.Id.SubtypeName), CubeSize = cubeDefinition.CubeSize, Size = new BindableSize3DIModel(cubeDefinition.Size), }; list.Add(c.FriendlyName + c.TypeIdString + c.SubtypeId, c); } foreach (var kvp in list) { CubeList.Add(kvp.Value); } CubeItem = CubeList.FirstOrDefault(c => c.TypeId == typeId && c.SubtypeId == subTypeId); }
public void UpdateCube(GameObject cubeToUpdate) { int index = CubeList.IndexOf(cubeToUpdate); int j = index % Size; int i = (index - j) / Size; Spaces[i][j].Populated = true; CubeList[index].GetComponent <Renderer>().material.color = GetColorForState(true); }
void ClearLists() { foreach (GameObject cube in CubeList) { GameObject.Destroy(cube); } Spaces.Clear(); CubeList.Clear(); }
public static CubeList TriangularShape(int size) { var hexes = new CubeList(); foreach (int k in Enumerable.Range(0, size + 1)) { foreach (int i in Enumerable.Range(0, k + 1)) { hexes.Add(new Cube(i, -k, k - i)); } } return(hexes); }
// These functions generate various shapes of hex maps public static CubeList TrapezoidalShape(int minQ, int maxQ, int minR, int maxR, ToCube toCube) { var hexes = new CubeList(); foreach (int q in Enumerable.Range(minQ, minQ + maxQ + 1)) { foreach (int r in Enumerable.Range(minR, minR + maxR + 1)) { hexes.Add(toCube(new HexField(q, r))); } } return(hexes); }
public static CubeList HexagonalShape(int size) { var hexes = new CubeList(); foreach (int x in Enumerable.Range(-size, 2 * size + 1)) { foreach (int y in Enumerable.Range(-size, 2 * size + 1)) { var z = -x - y; if (Math.Abs(x) <= size && Math.Abs(y) <= size && Math.Abs(z) <= size) { hexes.Add(new Cube(x, y, z)); } } } return(hexes); }
public void CreateGameField() { int count = 1; foreach (List <Space> spaceRow in Spaces) { foreach (Space space in spaceRow) { GameObject go = GameObject.Instantiate(Cube, GameFieldTransform); go.transform.position = space.Position; go.GetComponent <Renderer>().material.color = GetColorForState(space.Populated); go.name = "cube" + count.ToString(); count++; CubeList.Add(go); } } }
public HexGrid(CubeList hexes) { this.hexes = hexes; }
public static CubeList TriangularShape(int size) { var hexes = new CubeList(); foreach (int k in Enumerable.Range(0, size + 1)) { foreach (int i in Enumerable.Range(0, k + 1)) { hexes.Add(new Cube(i, -k, k - i)); } } return hexes; }
// These functions generate various shapes of hex maps public static CubeList TrapezoidalShape(int minQ, int maxQ, int minR, int maxR, ToCube toCube) { var hexes = new CubeList(); foreach (int q in Enumerable.Range(minQ, minQ + maxQ + 1)) { foreach (int r in Enumerable.Range(minR, minR + maxR + 1)) { hexes.Add(toCube(new HexField(q, r))); } } return hexes; }
public static CubeList HexagonalShape(int size) { var hexes = new CubeList(); foreach (int x in Enumerable.Range(-size, 2 * size + 1)) { foreach (int y in Enumerable.Range(-size, 2 * size + 1)) { var z = -x - y; if (Math.Abs(x) <= size && Math.Abs(y) <= size && Math.Abs(z) <= size) { hexes.Add(new Cube(x, y, z)); } } } return hexes; }
public HexGrid(CubeList hexes) { this.hexes = hexes; }