void SetNewOrePatch(int leadX, int leadY, Rock.RockType rType) { // FIX THIS! Making density calculation totally random! int distance = ResourceGrid.Grid.pseudoRandom.Next(0, 21); int density = 0; if (distance >= 15) { // pick a 1 or 2 density int pick = Random.Range(0, 2); density = pick; } else if (distance < 15 && distance > 8) { // pick between 4 or 5 density int pick = Random.Range(2, 4); density = pick; } else { density = 5; } OrePatch patch = new OrePatch(leadX, leadY, density, rType); // Debug.Log("ORE PATCH at lead x " + leadX + " lead Y " + leadY); patch.SetFormation(); ResourceGrid.Grid.PlaceOrePatch(patch, rType); }
void PlaceOrePatch(OrePatch _patch, string typeName) { // place the lead ore if there is no rock already on that tile if (tiles [_patch.leadPositionX, _patch.leadPositionY].tileType == TileData.Types.empty) { if (typeName == "rock"){ tiles [_patch.leadPositionX, _patch.leadPositionY] = new TileData (TileData.Types.rock, 6000, 10000); SpawnDiscoverTile (typeName, new Vector3 (_patch.leadPositionX, _patch.leadPositionY, 0.0F), TileData.Types.rock); }else if (typeName == "mineral"){ tiles [_patch.leadPositionX, _patch.leadPositionY] = new TileData (TileData.Types.mineral, 3000, 10000); SpawnDiscoverTile (typeName, new Vector3 (_patch.leadPositionX, _patch.leadPositionY, 0.0F), TileData.Types.mineral); } } if (_patch.neighborOreTiles != null && _patch.neighborOreTiles.Length > 0) { // place the neighbors in their positions for (int i = 0; i < _patch.neighborOreTiles.Length; i++){ if (CheckIsInMapBounds(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY)){ // Place this rock / mineral if there isn't a rock / mineral already on this tile if (tiles[_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY].tileType == TileData.Types.empty){ if (typeName == "rock"){ tiles [_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY] = new TileData (TileData.Types.rock, 6000, 10000); SpawnDiscoverTile ("rock", new Vector3 (_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, 0.0F), TileData.Types.rock); }else if (typeName == "mineral"){ tiles [_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY] = new TileData (TileData.Types.mineral, 3000, 10000); SpawnDiscoverTile ("mineral", new Vector3 (_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, 0.0F), TileData.Types.mineral); } } } } } }
void SetNewOrePatch(int leadX, int leadY, string typeName) { // first make sure that there is NO WATER tiles around this lead tile if (!CheckForWater (leadX, leadY)) { Debug.Log ("Found tile with no water around it!"); // Calculate the distance from this lead tile to the center of the map, // the closer to the center the DENSER a patch of ore will be float distance = Vector2.Distance (new Vector2 (leadX, leadY), new Vector2 (centerPosX, centerPosY)); int density = 0; if (distance >= 20) { // pick a 1 or 2 density float pick = Random.Range (0, 3); density = (int)pick; } else if (distance < 14 && distance > 8) { // pick between 4 or 5 density float pick = Random.Range (3, 5); density = (int)pick; } else { density = 5; } OrePatch patch = new OrePatch (leadX, leadY, density); patch.SetFormation (); PlaceOrePatch(patch, typeName); } else { Debug.Log("Could not place ore patch because " + leadX + "," + leadY+ " is a shore!"); } }
public void PlaceOrePatch(OrePatch _patch, Rock.RockType rType) { // place the lead ore if there is no rock already on that tile if (tiles[_patch.leadPositionX, _patch.leadPositionY].tileType == TileData.Types.empty) { switch (rType) { case Rock.RockType.sharp: tiles[_patch.leadPositionX, _patch.leadPositionY] = new TileData(_patch.leadPositionX, _patch.leadPositionY, TileData.Types.rock, 6000, 50, 1); SpawnRock("sharp rock", new Vector3(_patch.leadPositionX, _patch.leadPositionY, 0.0F), Rock.RockType.sharp); break; case Rock.RockType.tube: tiles[_patch.leadPositionX, _patch.leadPositionY] = new TileData(_patch.leadPositionX, _patch.leadPositionY, TileData.Types.rock, 6000, 50, 4); SpawnRock("tube rock", new Vector3(_patch.leadPositionX, _patch.leadPositionY, 0.0F), Rock.RockType.tube); break; case Rock.RockType.hex: tiles[_patch.leadPositionX, _patch.leadPositionY] = new TileData(_patch.leadPositionX, _patch.leadPositionY, TileData.Types.rock, 6000, 50, 8); SpawnRock("hex rock", new Vector3(_patch.leadPositionX, _patch.leadPositionY, 0.0F), Rock.RockType.hex); break; default: tiles[_patch.leadPositionX, _patch.leadPositionY] = new TileData(_patch.leadPositionX, _patch.leadPositionY, TileData.Types.rock, 6000, 50, 1); SpawnRock("sharp rock", new Vector3(_patch.leadPositionX, _patch.leadPositionY, 0.0F), Rock.RockType.sharp); break; } CreateUnWalkableBorder(_patch.leadPositionX, _patch.leadPositionY); } // place the neighbors in their positions if (_patch.neighborOreTiles != null && _patch.neighborOreTiles.Length > 0) { for (int i = 0; i < _patch.neighborOreTiles.Length; i++){ if (CheckIsInMapBounds(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY)) { if (tiles[_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY].tileType == TileData.Types.empty) { switch (rType) { case Rock.RockType.sharp: tiles[_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY] = new TileData(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, TileData.Types.rock, 6000, 50, 1); SpawnRock("sharp rock", new Vector3(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, 0.0F), Rock.RockType.sharp); break; case Rock.RockType.tube: tiles[_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY] = new TileData(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, TileData.Types.rock, 6000, 50, 2); SpawnRock("tube rock", new Vector3(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, 0.0F), Rock.RockType.tube); break; case Rock.RockType.hex: tiles[_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY] = new TileData(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, TileData.Types.rock, 6000, 50, 3); SpawnRock("hex rock", new Vector3(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, 0.0F), Rock.RockType.hex); break; default: tiles[_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY] = new TileData(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, TileData.Types.rock, 6000, 50, 1); SpawnRock("sharp rock", new Vector3(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY, 0.0F), Rock.RockType.sharp); break; } CreateUnWalkableBorder(_patch.neighborOreTiles[i].posX, _patch.neighborOreTiles[i].posY); } } } } }