private byte ParseShape(OreTypes ore, MarchingSquaresGrid marchingGrid, OreGrid oreGrid, int x, int y) { byte shape = 0; for (int i = 0; i < 7; i += 2) { if (GetNode(i, x, y, marchingGrid) > 0.5f && oreGrid.GetTileByIndex(i, x, y) == (int)ore) { shape |= (byte)(1 << i); int nextIndex = Mod(i + 2, 8); int prevIndex = Mod(i - 2, 8); int nextIntermediate = Mod(i + 1, 8); int prevIntermediate = Mod(i - 1, 8); //If the next node is a different type, or below the rendering threshold, add the intermediate node if (GetNode(nextIndex, x, y, marchingGrid) < 0.5f || oreGrid.GetTileByIndex(nextIndex, x, y) != (int)ore) { shape |= (byte)(1 << (nextIntermediate)); } if (GetNode(prevIndex, x, y, marchingGrid) < 0.5f || oreGrid.GetTileByIndex(prevIndex, x, y) != (int)ore) { shape |= (byte)(1 << (prevIntermediate)); } } } return(shape); // return (byte) 1 +( 1<< 1) + (1 << 7); }
public Ore(OreTypes ore, int amount) { this.type = ore; this.amount = amount; switch (ore) { case OreTypes.Coal: { mine = MineType.Shaft; break; } case OreTypes.Iron: { mine = MineType.Shaft; break; } case OreTypes.Copper: { mine = MineType.Shaft; break; } case OreTypes.Wood: { mine = MineType.Mill; break; } } }
public Color32 GetOreColor(OreTypes ore) { switch (ore) { case OreTypes.Empty: return(new Color32(0, 0, 0, 255)); case OreTypes.Desert: return(new Color32(255, 0, 0, 255)); case OreTypes.Grass: return(new Color32(0, 255, 0, 255)); case OreTypes.Mud: return(new Color32(230, 173, 113, 255)); case OreTypes.Rock: return(new Color32(100, 100, 100, 255)); case OreTypes.Snow: return(new Color32(250, 250, 250, 255)); case OreTypes.Iron: return(new Color32(200, 200, 200, 255)); default: return(new Color32(0, 255, 255, 255)); } }
public Ore(int id, string hash, OreTypes type, Vector pos, Spacemap map, Vector[] limits) : base(id, pos, map) { Hash = hash; Type = type; Limits = limits; if (Limits == null) { Limits = Spacemap.Limits; } }
public OreData(byte id, OreTypes type, int minY, int maxY, int viens, int abundance, float rarity) { ID = id; Type = type; MinY = minY; MaxY = maxY; Veins = viens; Abundance = abundance; Rarity = rarity; }
public void CreateOre(OreTypes type, Vector pos, Vector[] limits) { var id = GetNextObjectId(); var hash = HashedObjects.Keys.ToList()[id]; var box = new RegularOre(id, hash, type, pos, this, limits); HashedObjects[hash] = box; if (AddObject(box)) { Out.WriteLog("Created Ore[" + type + "] on mapId " + Id); } }
public void CreateOre(OreTypes type, Vector pos, int[] limits) { var id = GetNextObjectId(); var hash = HashedObjects.Keys.ToList()[id]; var box = new PalladiumOre(id, hash, type, pos, this, limits); HashedObjects[hash] = box; if (AddObject(box)) { World.Log.Write("Created Ore[" + type + "] on mapId " + Id); } }
void GiveOre(OreTypes item) { GameObject tempOre = new GameObject(); tempOre.AddComponent <Ore> (); tempOre.GetComponent <Ore> ().itemID = item.oreID; tempOre.GetComponent <Ore> ().itemName = item.oreName; tempOre.GetComponent <Ore> ().itemDesc = item.oreDesc; tempOre.GetComponent <Ore> ().itemIcon = Resources.Load <Sprite> ("Icons/" + item.resourceName); tempOre.GetComponent <Ore> ().maxSkill = item.maxSkill; tempOre.GetComponent <Ore> ().minSkill = item.minSkill; tempOre.GetComponent <Ore> ().oreColor = item.oreColor; tempOre.GetComponent <Ore> ().rarity = Item.ItemRarity.common; tempOre.GetComponent <Ore> ().stackMax = item.stackMax; tempOre.GetComponent <Ore> ().type = Item.ItemType.material; tempOre.GetComponent <Ore> ().skill = Item.SkillUsed.mining; inventory.AddItem(tempOre.GetComponent <Ore>()); Destroy(tempOre); player = GameObject.FindGameObjectWithTag("Player"); player.GetComponent <Player>().GainSkill(tempOre.GetComponent <Ore>().skill.ToString(), tempOre.GetComponent <Ore>().maxSkill); }
public Ore(int id, string hash, OreTypes type, Vector pos, Spacemap map, int[] limits) : base(id, pos, map) { Hash = hash; Type = type; Limits = limits; }
public PalladiumOre(int id, string hash, OreTypes type, Vector pos, Spacemap map, int[] limits) : base(id, hash, type, pos, map, limits) { }
public RegularOre(int id, string hash, OreTypes type, Vector pos, Spacemap map, Vector[] limits) : base(id, hash, type, pos, map, limits) { }
public Ore(Cell cell, OreTypes oreType) : base(cell, Models.Ores[(int)oreType], StructureTypes.Ore) { OreType = oreType; }
private void BuildSquare(int x, int y, MarchingSquaresGrid marchingGrid, OreGrid oreGrid) { float xOffset = (float)x; float yOffset = (float)y; Vector3 vecOffset = new Vector3(xOffset, yOffset, 0f); Color32 borderColor = new Color32(230, 230, 230, 255); Color32 mainColor = new Color32(200, 200, 200, 255); //Build an individual square by going clockwise around the nodes and interpolations in that tile space int numCornerNodes = 0; int numAllTypeNodes = 0; int i = 0; int anchorVert = numVerts; int numShapes = 0; //One shape per unique OreType. for (i = 0; i < 8; i++) { if (i == 0 || i == 2 || i == 4 || i == 6) { if (GetNode(i, x, y, marchingGrid) >= 0.5f) { numCornerNodes++; } } } if (numCornerNodes > 0) { //Parse up to 4 shapes. //Look at each corner. //If the Corner is rendered, set its bit to true. //If the the adjacent corners are different or not rendered, set the adjacent edge bits to true. byte botLeft = 0; byte topRight = 0; byte topLeft = 0; byte botRight = 0; OreTypes ore0 = (OreTypes)oreGrid.GetTile(x, y); OreTypes ore1 = (OreTypes)oreGrid.GetTile(x, y + 1); OreTypes ore2 = (OreTypes)oreGrid.GetTile(x + 1, y + 1); OreTypes ore3 = (OreTypes)oreGrid.GetTile(x + 1, y); bool unique0 = true; bool unique1 = true; bool unique2 = true; bool unique3 = true; int shape0Nodes = 0; int shape1Nodes = 0; int shape2Nodes = 0; int shape3Nodes = 0; //Identify the ore types that appear. if (ore0 == ore1) { unique1 = false; } if (ore0 == ore2) { unique2 = false; } if (ore0 == ore3) { unique3 = false; } if (ore1 == ore2) { unique2 = false; } if (ore1 == ore3) { unique3 = false; } if (ore2 == ore3) { unique3 = false; } //Render the first ore across the entire tile, to prevent gaps bool baseColorRendered = false; //For each unique ore type, loop around the perimeter, flagging raised corners of that type, and edge nodes where the ore is different or the elevation changes. //If a corner is the first instance of an ore type, parse its shape. Redundant ore type corners will be flagged in the first instance as part of this loop. if (unique0) { botLeft = ParseBaseShape(ore0, marchingGrid, oreGrid, x, y); baseColorRendered = true; // botLeft = ParseShape (ore0, marchingGrid, oreGrid, x, y); } if (unique1) { if (baseColorRendered) { topLeft = ParseShape(ore1, marchingGrid, oreGrid, x, y); } else { baseColorRendered = true; topLeft = ParseBaseShape(ore1, marchingGrid, oreGrid, x, y); } } if (unique2) { if (baseColorRendered) { topRight = ParseShape(ore2, marchingGrid, oreGrid, x, y); } else { baseColorRendered = true; topRight = ParseBaseShape(ore2, marchingGrid, oreGrid, x, y); } } if (unique3) { if (baseColorRendered) { botRight = ParseShape(ore3, marchingGrid, oreGrid, x, y); } else { botRight = ParseBaseShape(ore3, marchingGrid, oreGrid, x, y); } } //If a corner is the origin of a shape, render it. if (botLeft > 0) //if bot left needs to be rendered { mainColor = oreGrid.GetOreColor(ore0); for (i = 0; i < 8; i++) { if ((botLeft & ((byte)1 << i)) > 0) { AddFaceVert(GetTileVertPosition(i, x, y, marchingGrid) + vecOffset + new Vector3(0f, 0f, -0.1f), mainColor); shape0Nodes++; } } for (i = 1; i < shape0Nodes - 1; i++) { faceTris.Add(anchorVert); faceTris.Add(anchorVert + i); faceTris.Add(anchorVert + i + 1); numTris++; } anchorVert = numVerts; } if (topLeft > 0) { mainColor = oreGrid.GetOreColor(ore1); for (i = 0; i < 8; i++) { if ((topLeft & ((byte)1 << i)) > 0) { AddFaceVert(GetTileVertPosition(i, x, y, marchingGrid) + vecOffset + new Vector3(0f, 0f, -0.2f), mainColor); shape1Nodes++; } } for (i = 1; i < shape1Nodes - 1; i++) { faceTris.Add(anchorVert); faceTris.Add(anchorVert + i); faceTris.Add(anchorVert + i + 1); numTris++; } anchorVert = numVerts; } if (topRight > 0) { mainColor = oreGrid.GetOreColor(ore2); for (i = 0; i < 8; i++) { if ((topRight & ((byte)1 << i)) > 0) { AddFaceVert(GetTileVertPosition(i, x, y, marchingGrid) + vecOffset + new Vector3(0f, 0f, -0.3f), mainColor); shape2Nodes++; } } for (i = 1; i < shape2Nodes - 1; i++) { faceTris.Add(anchorVert); faceTris.Add(anchorVert + i); faceTris.Add(anchorVert + i + 1); numTris++; } anchorVert = numVerts; } if (botRight > 0) { mainColor = oreGrid.GetOreColor(ore3); for (i = 0; i < 8; i++) { if ((botRight & ((byte)1 << i)) > 0) { AddFaceVert(GetTileVertPosition(i, x, y, marchingGrid) + vecOffset + new Vector3(0f, 0f, -0.4f), mainColor); shape3Nodes++; } } for (i = 1; i < shape3Nodes - 1; i++) { faceTris.Add(anchorVert); faceTris.Add(anchorVert + i); faceTris.Add(anchorVert + i + 1); numTris++; } anchorVert = numVerts; } //Add a lighter colour to the edge of the tile BuildOutline(x, y, marchingGrid, borderColor); } }