void SpawnDiscoverTile(string tileName, Vector3 position, TileData.Types type) { // spawn the half tile from the pool GameObject discoverTile = objPool.GetObjectForType("Half_Tile", false); if (discoverTile != null) { discoverTile.transform.position = position; DiscoverTile dTile = discoverTile.GetComponent <DiscoverTile> (); dTile.objPool = objPool; dTile.TileToDiscover(newTileName: tileName, mapPosX: (int)position.x, mapPosY: (int)position.y, tileHolder: tileHolder, grid: this, tileType: type, playerCapital: playerCapital); } }
public void InitRock(Rock.RockProductionType rock, int ammnt) { totalAmmntOfResource = ammnt; rockProdType = rock; resourceType = TileData.Types.rock; }
// Survival Mission: public Mission(string name, MissionType mType, Blueprint requiredBP, TileData.Types reqResource, int reqAmnt, string desc = "Unknown Signal") { missionName = name; missionType = mType; requiredBlueprint = requiredBP; description = desc; objectiveResource = reqResource; objectiveAmnt = reqAmnt; }
/// <summary> /// Swaps the type of the tile. /// </summary> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> /// <param name="newType">New type.</param> public void SwapTileType(int x, int y, TileData.Types newType) { // MAKE SURE THIS IS NOT A SPAWNED TILE ALREADY!!! // So we don't change the grid tile data where we don't want to! if (spawnedTiles [x, y] == null) { // swap the old type to new type switch (newType) { case TileData.Types.extractor: tiles [x, y] = new TileData("Extractor", newType, 0, 10000, 5, 5, 0, 0, extractorCost[1], extractorCost[0]); break; case TileData.Types.machine_gun: tiles [x, y] = new TileData("Machine Gun", newType, 0, 10000, 30, 5, 5, 0, machineGunCost[1], machineGunCost[0]); break; case TileData.Types.cannons: tiles [x, y] = new TileData("Cannons", newType, 0, 10000, 30, 5, 3, 0, seaWitchCost[1], seaWitchCost[0]); break; case TileData.Types.harpoonHall: tiles [x, y] = new TileData("Harpooner's Hall", newType, 0, 10000, 50, 6, 0, 0, harpoonHCost[1], harpoonHCost[0]); break; case TileData.Types.farm_s: tiles [x, y] = new TileData("Seaweed Farm", newType, 0, 10000, 25, 1, 0, 0, sFarmCost[1], sFarmCost[0]); break; case TileData.Types.storage: tiles [x, y] = new TileData("Storage", newType, 0, 10000, 35, 2, 0, 0, storageCost[1], storageCost[0]); break; case TileData.Types.desalt_s: tiles [x, y] = new TileData("Desalination Pump", newType, 0, 10000, 15, 1, 0, 0, sDesaltCost[1], sDesaltCost[0]); break; case TileData.Types.sniper: tiles [x, y] = new TileData("Sniper Gun", newType, 0, 10000, 0, 0, 0, 0, sniperCost[1], sniperCost[0]); break; case TileData.Types.seaWitch: tiles [x, y] = new TileData("Sea-Witch Crag", newType, 0, 10000, 0, 0, 0, 0, seaWitchCost[1], seaWitchCost[0]); break; case TileData.Types.nutrient: tiles [x, y] = new TileData("Nutrient Generator", newType, 0, 10000, 0, 0, 0, 0, nutriCost[1], nutriCost[0]); break; case TileData.Types.building: tiles [x, y] = new TileData(newType, 0, 10000); break; default: print("No tile changed."); break; } // Discover the tile to display it DiscoverTile(x, y, true); // if tile is a Building with a FOOD COST, apply it to resources if (tiles[x, y].foodCost > 0) { playerResources.totalFoodCost = playerResources.totalFoodCost + tiles[x, y].foodCost; } } else { // if we are swappin an already spawned tile we are MOST LIKELY turning it into an empty tile // BUT if this was any building that has a food cost that must be reflected in Player resources // by subtracting from the total food cost if (tiles[x, y].foodCost > 0) { playerResources.totalFoodCost = playerResources.totalFoodCost - tiles[x, y].foodCost; } // ALSO if it's a Farm we need to subtract its FOOD production and its WATER consumed if (playerResources.foodProducedPerDay > 0) { if (tiles[x, y].tileType == TileData.Types.farm_s || tiles[x, y].tileType == TileData.Types.nutrient) { FoodProduction_Manager foodM = spawnedTiles [x, y].GetComponent <FoodProduction_Manager>(); playerResources.CalculateFoodProduction(foodM.foodProduced, foodM.productionRate, foodM.waterConsumed, true); } } // AND if it's a STORAGE we need to subtract all the ORE and WATER from the resources if (tiles[x, y].tileType == TileData.Types.storage) { Storage storage = spawnedTiles[x, y].GetComponent <Storage>(); // if (storage.oreStored > 0 || storage.waterStored > 0){ // playerResources.ChangeResource("Ore", - storage.oreStored); // playerResources.ChangeResource("Water", -storage.waterStored); // } // remove the storage building from the list playerResources.RemoveStorageBuilding(storage); } // If it's an EXTRACTOR also need to subtract from Ore Produced if (tiles[x, y].tileType == TileData.Types.extractor) { Extractor extra = spawnedTiles [x, y].GetComponent <Extractor>(); playerResources.CalculateOreProduction(extra.extractAmmnt, extra.extractRate, true); } // Same thing for a WATER PUMP if (tiles[x, y].tileType == TileData.Types.desalt_s || tiles[x, y].tileType == TileData.Types.desalt_m || tiles[x, y].tileType == TileData.Types.desalt_l) { DeSalt_Plant pump = spawnedTiles [x, y].GetComponent <DeSalt_Plant>(); playerResources.CalculateWaterProduction(pump.waterPumped, pump.pumpRate, true); } // RETURN 30% OF THE ORE COST TO THE RESOURCES float calc = (float)tiles[x, y].oreCost * 0.3f; playerResources.ore = playerResources.ore + (int)calc; Destroy(spawnedTiles[x, y].gameObject); tiles[x, y] = new TileData(newType, 0, 1); } }
public void TileToDiscover(string newTileName, int mapPosX, int mapPosY, Transform tileHolder, ResourceGrid grid, TileData.Types tileType, GameObject playerCapital) // this is called by Resource grid with the proper tile obj { tileToSpawn = objPool.GetObjectForType(newTileName, false); if (tileToSpawn != null) { tileToSpawn.transform.position = transform.position; tileToSpawn.transform.parent = tileHolder; // Give the Tile position relative to the grid map // TileClick_Handler tc = tileToSpawn.GetComponent<TileClick_Handler> (); // tc.mapPosX = mapPosX; // tc.mapPosY = mapPosY; // tc.resourceGrid = grid; // tc.playerUnit = selectedUnit; // // IF TILE IS NOT A ROCK OR EMPTY, IT'S A BUILDING, // so it will have a Building Click Handler that needs its pos X and pos Y if (tileType != TileData.Types.rock && tileType != TileData.Types.empty) { tileToSpawn.GetComponent <Building_ClickHandler> ().mapPosX = mapPosX; tileToSpawn.GetComponent <Building_ClickHandler> ().mapPosY = mapPosY; tileToSpawn.GetComponent <Building_ClickHandler> ().resourceGrid = grid; } if (tileType == TileData.Types.extractor) { // IF IT'S AN EXTRACTOR it will ALSO need the extractor variables tileToSpawn.GetComponent <Extractor> ().mapPosX = mapPosX; tileToSpawn.GetComponent <Extractor> ().mapPosY = mapPosY; tileToSpawn.GetComponent <Extractor> ().resourceGrid = grid; tileToSpawn.GetComponent <Extractor> ().playerResources = playerCapital.GetComponent <Player_ResourceManager> (); } // ADD this tile to the Grid's spawnedTiles array grid.spawnedTiles [mapPosX, mapPosY] = tileToSpawn; } }
TileData.Types CheckTileType(int x, int y) { TileData.Types type = resourceGrid.tiles [x, y].tileType; return(type); }