public void newDayCallback() { BuildingsManager.GetInstance().newDayCallback(); WorldTerrain.GetInstance().newDayCallback(); GameObject.Find("Logic").GetComponent <PlagueLogic>().NewDayCallback(); //updateActionPanel (); }
public void updateRepresentation() { if (representation != null) { GameObject.Destroy(representation); } WorldTerrain worldTerrain = WorldTerrain.GetInstance(); Vector3 worldPosition = worldTerrain.getTileWorldPosition(row, col); worldPosition.z = WorldTerrain.TERRAIN_Z_LAYER; if (!confirmed) { worldPosition.z -= 6; } Debug.Assert(resources != null); Debug.Assert(resources.ContainsKey(conexionType), "Resource para Canal no encontrado: " + conexionType.ToString()); representation = (GameObject)GameObject.Instantiate(resources[conexionType], worldPosition, Quaternion.identity); if (!confirmed) { representation.GetComponent <SpriteRenderer> ().color = Color.yellow; } representation.transform.GetChild(0).gameObject.SetActive(!hasWater); }
void executePlague(int id) { plagueHappening = true; activePlague = pm.getPlague(id); plagueInitialDay = tm.getCurrentDay(); remainingChunks = 0; WorldTerrain wt = WorldTerrain.GetInstance(); int tilesPerChunk = wt.getTotalTilesInAChunk(); visitedChunk = new bool[wt.getNumberOfChunks()]; for (int i = 0; i < wt.getNumberOfChunks(); i++) { visitedChunk [i] = true; } for (int i = 0; i < wt.getNumberOfChunks(); i++) { int rnd = Random.Range(1, 3); if ((rnd < 3 || remainingChunks == 0) && wt.isChunkPlanted(i)) { visitedChunk[i] = false; remainingChunks++; uint randomTile = (uint)((UnityEngine.Random.value) * (float)(tilesPerChunk - 1)); wt.updatePlagueStateInTile(i, (int)randomTile, plagueType(activePlague.getID())); } } if (remainingChunks == 0) { cleanPlague(); } else { activePlague.setActive(true); } }
public void actionClicked() { if (!b_haveAllObjectsRequired) { openBuyMenu(); } else if (!b_areEnoughWorkers) { openHireMenu(); } else { const int ID_SEND_HARVEST_TRAD = 17; const int ID_SEND_HARVEST_MODERN = 29; if (m_actions[m_currentAction].id != ID_SEND_HARVEST_MODERN && m_actions[m_currentAction].id != ID_SEND_HARVEST_TRAD) { m_actions[m_currentAction].doMenuAction(); } else { int chunk = ((ChunkAction)m_actions[m_currentAction]).chunk; uint riceInChunk = WorldTerrain.GetInstance().getRiceChunkProduction(chunk); if (!BuildingsManager.GetInstance().isBuilded(BUILDINGS.PLANTA)) { Building_Trill trill = (Building_Trill)BuildingsManager.GetInstance().getBuilding(BUILDINGS.TRILL); uint currentFreeCapacity = trill.getCurrentFreeCapacity(); if (currentFreeCapacity >= riceInChunk) { m_actions[m_currentAction].doMenuAction(); } else { //uint possibleLost = riceInChunk - currentFreeCapacity; GameObject panelTemplate = Resources.Load("Prefabs/RiceOverflowLostFocusLayer") as GameObject; GameObject panelInstance = Instantiate(panelTemplate); GameObject panel = panelInstance.transform.FindChild("RiceOverflowPanel").gameObject; panel.GetComponent <RiceOverflowPanelBehaviour>().init((MenuAction)m_actions[m_currentAction]); } } else { Building_Planta planta = (Building_Planta)BuildingsManager.GetInstance().getBuilding(BUILDINGS.PLANTA); uint currentFreeCapacity = planta.getCurrentFreeCapacity(); if (currentFreeCapacity >= riceInChunk) { m_actions[m_currentAction].doMenuAction(); } else { //uint possibleLost = riceInChunk - currentFreeCapacity; GameObject panelTemplate = Resources.Load("Prefabs/RiceOverflowLostFocusLayer") as GameObject; GameObject panelInstance = Instantiate(panelTemplate); GameObject panel = panelInstance.transform.FindChild("RiceOverflowPanel").gameObject; panel.GetComponent <RiceOverflowPanelBehaviour>().init((MenuAction)m_actions[m_currentAction]); } } } kill(); } }
public uint getMaxPlantes() { uint basicCapacity = (uint)(getCapacity1() * WorldTerrain.GetInstance().getTotalTilesInAChunk()); uint bonusCapacity = basicCapacity * InvestigationManager.GetInstance().getPlanterCapacityBonus() / 100; return(basicCapacity + bonusCapacity); }
public List <MenuAction> getRiceTerrainActions(RiceTerrainTile riceTerrain) { //Debug.Log ("Actions for Terrain=" + riceTerrain.getChunkNumber ()); List <MenuAction> actionsAvailable = new List <MenuAction>(); if (!isActionInProgress(riceTerrain.getChunkNumber())) { List <int> actionsCurrentPhase = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>().getActionsInCurrentPhase(); for (uint i = 0; i < actionsCurrentPhase.Count; ++i) { int currentAction = actionsCurrentPhase[(int)i]; bool areDependenciesOk = riceTerrain.checkDependencies(_action[currentAction]); bool hasBeenInvestigated = InvestigationManager.GetInstance().areInvestigated(_action[currentAction].getInvestigationRequired()); bool hasWater = WorldTerrain.GetInstance().riceChunkHasWater(riceTerrain.getChunkNumber()) || !_action[currentAction].needCanal; bool hasActionDone = riceTerrain.isActionDone(currentAction); if (!hasActionDone && hasBeenInvestigated && areDependenciesOk && hasWater) { ChunkAction newAction = _action[currentAction]; PerformChunkAction callback = this.addActionInProgress; ChunkAction t = newAction.copyWithCallback(callback, riceTerrain.getChunkNumber()); actionsAvailable.Add((MenuAction)t); } //Debug.Log(" Action "+currentAction+" Dep="+areDependenciesOk+" Inv="+hasBeenInvestigated+" Water="+hasWater+" !Done="+!hasActionDone); } } actionsAvailable.Sort((x, y) => x.priority.CompareTo(y.priority)); return(actionsAvailable); }
private void createInstFlamingo(uintPair position) { try { uint row = position.First; uint col = position.Second; Debug.Log(" instantiating Flamingo at " + row + " " + col); GameObject flamingoGameObject = Resources.Load <GameObject>(getRandomFlamingoPath()); WorldTerrain wt = WorldTerrain.GetInstance(); Vector3 worldPosition = wt.getTileWorldPosition(row, col); float map_top = wt.getTileWorldPositionY(wt.getNumTilesY() - 1, 0); float map_h = wt.getTileWorldPositionY(0, wt.getNumTilesX() - 1) - wt.getTileWorldPositionY(wt.getNumTilesY() - 1, 0); Vector3 flamingoSize = flamingoGameObject.GetComponent <SpriteRenderer> ().bounds.size; //worldPosition.x += WorldTerrain.TILE_WIDTH_UNITS/2 - flamingoSize.x / 2; worldPosition.y += flamingoSize.y * 0.3f; worldPosition.z = WorldTerrain.BUILDING_Z_LAYER - (map_top - (worldPosition.y)) / map_h; instancesFlamingos[position] = GameObject.Instantiate(flamingoGameObject, worldPosition, Quaternion.identity); } catch (Exception e) { Debug.LogError("Error trying to instantiate flamingo"); Debug.LogError(e.ToString()); } }
public void MakeActionsTillPhase(TypeFase phase) { WorldTerrain wt = WorldTerrain.GetInstance(); int ID_SIEMBRA_DIRECTA = 6; //List<Pair<uint, uint>> positions = WorldTerrain.GetInstance().getChunkTilesPositions(0); foreach (TypeFase currentPhase in Enum.GetValues(typeof(TypeFase))) { if (currentPhase == phase) { break; } List <int> actionsCurrentPhase = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>().getActionsInPhase(currentPhase); /*foreach (Pair<uint, uint> position in positions) { * RiceTerrainTile tile = WorldTerrain.GetInstance().getRiceTerrain(position.First, position.Second); * tile.performAction() * }*/ foreach (int actionID in actionsCurrentPhase) { if (actionID != ID_SIEMBRA_DIRECTA && ActionManager.GetInstance().hasAnActionToBeAddedAsDone(actionID)) { for (int i = 0; i < wt.getNumberOfChunks(); ++i) { wt.performActionInChunk(actionID, i, new List <int> (), true); } } } } }
private void buildBuilding(BUILDINGS buildingId, uint i, uint j) { BuildingsManager buildingsMan = BuildingsManager.GetInstance(); Building building = buildingsMan.getBuilding(buildingId); buildingsMan.build(buildingId, i, j); WorldTerrain worldTerrain = WorldTerrain.GetInstance(); worldTerrain.createBuilding(i, j, building.getVerticalTiles(), building.getHorizontalTiles()); if (buildingId == BUILDINGS.PLANTA) { Building_Trill trill = (Building_Trill)buildingsMan.getBuilding(BUILDINGS.TRILL); Building_Silo silo = (Building_Silo)buildingsMan.getBuilding(BUILDINGS.SILO); Building_Era era = (Building_Era)buildingsMan.getBuilding(BUILDINGS.ERA); trill.stopProduction(); silo.stopProduction(); era.stopProduction(); uint rice = trill.getAllTheRice(); rice += silo.getAllTheRice(); rice += era.getAllTheRice(); ((Building_Planta)building).sendRice(rice); destroyBuilding(BUILDINGS.TRILL); destroyBuilding(BUILDINGS.SILO); destroyBuilding(BUILDINGS.ERA); } }
public WeedFactory(WorldTerrain parent, uint tilesPerChunk) { _parent = parent; _currentWeed = new Dictionary <int, HashSet <uint> >(); _tilesPerChunk = tilesPerChunk; }
public void constructionBuildingCancel() { if (logicState == LOGIC_STATE.DELETING) { deletingCancel(); } else { BUILDING_INFO.clearRepresentation(); if (BUILDING_INFO.terrainID == TileTerrainType.BUILDING) { Building building = BuildingsManager.GetInstance().getBuilding(BUILDING_INFO.buildingID); UserDataManager.GetInstance().gold.addGold(building.getInitialCost()); } else if (BUILDING_INFO.terrainID == TileTerrainType.RICE_TERRAIN) { UserDataManager.GetInstance().gold.addGold(WorldTerrain.PRICE_RiceChunk); } else if (BUILDING_INFO.terrainID == TileTerrainType.CANAL) { WorldTerrain wt = WorldTerrain.GetInstance(); wt.cancelCanalsTmp(); } } if (_buildingPanel != null) { _buildingPanel.SendMessage("kill"); } logicState = LOGIC_STATE.DEFAULT; }
public void newPhaseCallback() { PhaseManager phaseMan = gameObject.GetComponent <PhaseManager> (); TypeFase typePhase = phaseMan.getCurrentPhase(); Debug.Log("New Phase: " + typePhase.ToString()); //TimeManager timeMan = gameObject.GetComponent<TimeManager> (); WorldTerrain wt = WorldTerrain.GetInstance(); switch (typePhase) { case TypeFase.SOWING: if (Tutorial_Plantell.init == false && !wt.areAllChunksDisabled()) { _tutMan.startTuto(new Tutorial_Plantell()); } break; case TypeFase.HARVEST: if (Tutorial_Buildings.init == false && !wt.areAllChunksDisabled()) { _tutMan.startTuto(new Tutorial_Buildings()); } break; } }
public GameObject instantiateBuildingRepresentation(uint row, uint col) { GameObject buildingGameObject = null; try { buildingGameObject = Resources.Load <GameObject>(this.getCurrentImgPath()); } catch (Exception e) { Debug.LogError(e.ToString()); Debug.LogError("buildingGameObject exception for " + _type.ToString()); Debug.LogError("path to building object " + this.getCurrentImgPath()); } //RiceTerrain terrainRepresentation = GameObject.FindGameObjectWithTag ("Map").GetComponent<RiceTerrain> (); WorldTerrain wt = WorldTerrain.GetInstance(); Vector3 worldPosition = wt.getTileWorldPosition(row, col); float map_top = wt.getTileWorldPositionY(wt.getNumTilesY() - 1, 0); float map_h = wt.getTileWorldPositionY(0, wt.getNumTilesX() - 1) - wt.getTileWorldPositionY(wt.getNumTilesY() - 1, 0); Vector3 buildingSize = buildingGameObject.GetComponent <SpriteRenderer> ().bounds.size; worldPosition.x -= buildingSize.x / 2 + WorldTerrain.TILE_WIDTH_UNITS / 2; worldPosition.y += buildingSize.y / 2; worldPosition.x += WorldTerrain.TILE_WIDTH_UNITS * getHorizontalTiles(); worldPosition.y -= WorldTerrain.TILE_HEIGHT_UNITS / 2 * getVerticalTiles(); worldPosition.z = WorldTerrain.BUILDING_Z_LAYER - (map_top - (worldPosition.y)) / map_h; return((GameObject)GameObject.Instantiate(buildingGameObject, worldPosition, Quaternion.identity)); }
public void constructionBuildingConfirm() { if (logicState == LOGIC_STATE.DELETING) { deletingConfirm(); } else { if (BUILDING_INFO.terrainID == TileTerrainType.BUILDING) { buildBuilding(BUILDING_INFO.buildingID, _tileSelectedPosition [0], _tileSelectedPosition [1]); Building building = BuildingsManager.GetInstance().getBuilding(BUILDING_INFO.buildingID); building.constructAtPos(_tileSelectedPosition [0], _tileSelectedPosition [1]); } else if (BUILDING_INFO.terrainID == TileTerrainType.RICE_TERRAIN) { WorldTerrain.GetInstance().createRiceChunk(_tileSelectedPosition [0], _tileSelectedPosition [1], false); } else if (BUILDING_INFO.terrainID == TileTerrainType.CANAL) { WorldTerrain wt = WorldTerrain.GetInstance(); wt.confirmCanalsTmp(); UserDataManager.GetInstance().gold.espendGold(_buildingPanel.GetComponent <MultipleBuildingPanel> ().getCost()); } BUILDING_INFO.clearRepresentation(); } logicState = LOGIC_STATE.DEFAULT; }
public bool markToDelete(uint i, uint j) { WorldTerrain wt = WorldTerrain.GetInstance(); TileTerrainType type = wt.getTypeTerrainOfTile(i, j); if (type == TileTerrainType.FREE && wt.tileContainsVegetation(i, j)) { wt.getTileVegetation(i, j).markToDelete(); _buildingPanel.GetComponent <MultipleBuildingPanel>().addUnits(+1, +WorldTerrain.PRICE_Clean); return(true); } /* * if (type == TileTerrainType.CANAL) { * wt.canalMarkToDelete(i, j); * _buildingPanel.GetComponent<MultipleBuildingPanel>().addUnits (+1, +WorldTerrain.PRICE_Clean); * return true; * } * if (type == TileTerrainType.RICE_TERRAIN) { * wt.riceChunkMarkToDelete(i, j); * uintPair clickedPos = new uintPair (i, j); * foreach(Pair<uint, uint> pos in wt.getChunkTilesPositions(wt.getRiceTerrain(i,j).getChunkNumber())) { * uintPair terrainPos = new uintPair (pos.First, pos.Second); * if (clickedPos != terrainPos) * tilesToDelete.Add (terrainPos); * _buildingPanel.GetComponent<MultipleBuildingPanel>().addUnits (+1, +WorldTerrain.PRICE_Clean); * * } * return true; * } */ return(false); }
//It's a call back called when a new year happens to be public void happyNewYear() { //Debug.Log("Happy new year!"); /* * if(InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.COOP)) { * CoopManager.GetInstance().happyNewYear(); * } */ WorldTerrain.GetInstance().resetEndOfTheYear(); BuildingsManager.GetInstance().reset(); PenalizationManager.GetInstance().reset(); if (b_firstAutoSave) { GameObject.Find("Logic").GetComponent <LogicManager> ().initAutoSave(); b_firstAutoSave = false; PlayerPrefs.SetInt("FirstAutoSaveDone", 1); } GameObject yearlySumPanel = Resources.Load("Prefabs/YearlySumPanelLostFocusLayer") as GameObject; UnityEngine.Object.Instantiate(yearlySumPanel); FaunaFelizManager.GetInstance().newYearUpdate(); }
public void unmarkToDelete(uint i, uint j) { WorldTerrain wt = WorldTerrain.GetInstance(); TileTerrainType type = wt.getTypeTerrainOfTile(i, j); if (type == TileTerrainType.FREE && wt.tileContainsVegetation(i, j)) { wt.getTileVegetation(i, j).unmarkToDelete(); _buildingPanel.GetComponent <MultipleBuildingPanel>().addUnits(-1, -WorldTerrain.PRICE_Clean); } else if (type == TileTerrainType.CANAL) { wt.canalUnmarkToDelete(i, j); _buildingPanel.GetComponent <MultipleBuildingPanel>().addUnits(-1, -WorldTerrain.PRICE_Clean); } else if (type == TileTerrainType.RICE_TERRAIN) { wt.riceChunkUnmarkToDelete(i, j); uintPair clickedPos = new uintPair(i, j); foreach (Pair <uint, uint> pos in wt.getChunkTilesPositions(wt.getRiceTerrain(i, j).getChunkNumber())) { uintPair terrainPos = new uintPair(pos.First, pos.Second); if (clickedPos != terrainPos) { tilesToDelete.Remove(terrainPos); } _buildingPanel.GetComponent <MultipleBuildingPanel>().addUnits(-1, -WorldTerrain.PRICE_Clean); } } }
public bool init() { //GameObject.FindGameObjectWithTag("Logic").GetComponent<PhaseManager>().readJSON(); _tileSelectedPosition = new uint[2] { 28, 25 }; _hasTileSelected = false; m_monthsInRed = 0; m_monthsSinceIShowedInRedPopup = 0; b_warningInRedPopupShown = false; //_terrainLogic = new RiceTerrainLogic(); ActionManager.GetInstance(); CoopManager.GetInstance(); PenalizationManager.GetInstance(); WorldTerrain.GetInstance().initWorld(); BuildingsManager.GetInstance().init(); UserDataManager.GetInstance().init(); UserDataManager.GetInstance().gold.setGold(6800); RiceObjectsManager.GetInstance(); _cloudSpawner = new CloudSpawner(WorldTerrain.CLOUDS_Z_LAYER); _tutMan.startTuto(new Tutorial_Inicial()); GameSaveDataManager.init(); return(true); }
GameObject SpawnGoal(Vector2 pos, int i) { WorldTerrain w = (Instantiate(defaultGoal, pos, Quaternion.identity) as GameObject).GetComponent <WorldTerrain>(); w.team = i; w.gameObject.name = "Goal (Team " + i + ")"; w.transform.parent = goalContainer; return(w.gameObject); }
private void CheckListOfActions(List <int> actionsToCheck) { List <int> actionsToCheckPartners = new List <int>(); List <int> keys = new List <int>(m_chunkPenalization.Keys); foreach (int chunk in keys) { List <int> actionsDoneInChunk = WorldTerrain.GetInstance().getActionsDoneInAChunk(chunk); if (ActionManager.GetInstance().isActionInProgressInAChunk(chunk)) { int id = ActionManager.GetInstance().getActionInProgressInAChunk(chunk); if (!actionsDoneInChunk.Contains(id)) { actionsDoneInChunk.Add(id); } } for (int i = 0; i < actionsToCheck.Count; ++i) { bool found = false; int j = 0; while (!found && j < actionsDoneInChunk.Count) { found = actionsDoneInChunk[j] == actionsToCheck[i]; ++j; } if (!found) { if (ActionManager.GetInstance().isAnActionRequired(actionsToCheck[i])) { disableChunk(chunk); } else if (ActionManager.GetInstance().hasAnActionPenalization(actionsToCheck[i])) { int k = 0; bool hasPartner = false; while (!hasPartner && k < actionsToCheckPartners.Count) { List <int> partners = ActionManager.GetInstance().getActionPartnersOfAnAction(actionsToCheckPartners[k]); hasPartner = partners.Contains(actionsToCheck[i]); ++k; } if (!hasPartner) { Debug.Log("PenalizationAdd at Chunk=" + chunk + " por Action=" + actionsToCheck [i]); addPenalization(chunk); actionsToCheckPartners.Add(actionsToCheck[i]); } } } } actionsToCheckPartners.Clear(); if (WorldTerrain.GetInstance().areAllChunksDisabled()) { GameObject.Find("Logic").GetComponent <TimeManager>().changeMode(TimeManager.SPEED_MODE.SUPAFAST); } } }
public static WorldTerrain GetInstance() { if (instance == null) { instance = new WorldTerrain(); } return(instance); }
void init() { Text m_riceProductionNumberText = GameObject.Find("RiceProductionNumberText").GetComponent <Text>(); Text m_riceSoldNumberText = GameObject.Find("RiceSoldNumberText").GetComponent <Text>(); Text m_riceLostNumberText = GameObject.Find("RiceLostNumberText").GetComponent <Text>(); Text m_grantEcologyNumberText = GameObject.Find("EcologyGrantNumberText").GetComponent <Text>(); UserDataManager userData = UserDataManager.GetInstance(); uint anualProduction = userData.getRiceProducedThisYear(); m_riceProductionNumberText.text = anualProduction.ToString(); WorldTerrain wt = WorldTerrain.GetInstance(); InvestigationManager invMan = InvestigationManager.GetInstance(); //uint riceOfChunksDisabled = (uint) wt.getNumberOfChunks() * RiceTerrainTile.MAX_RICE_UNITS * WorldTerrain.RICE_CHUNK_W * WorldTerrain.RICE_CHUNK_H; //uint riceLostThisYear = userData.getRiceLostThisYear() + riceOfChunksDisabled; uint riceLostThisYear = (uint)(wt.getNumberOfChunks() * RiceTerrainTile.MAX_RICE_UNITS * WorldTerrain.RICE_CHUNK_W * WorldTerrain.RICE_CHUNK_H * (1 + invMan.getRicePerChunkBonus() * 0.01f) - anualProduction); m_riceLostNumberText.text = riceLostThisYear.ToString(); int anualRiceSold = userData.gold.getRiceGoldAddThisYear(); m_riceSoldNumberText.text = anualRiceSold.ToString(); bool ecoGrant = InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.ECO_SUBVENCION); if (ecoGrant) { int ecoGrantBonus = CoopManager.GetInstance().getCurrentEcologyBonus(); m_grantEcologyNumberText.text = ecoGrantBonus.ToString(); } else { m_grantEcologyNumberText.text = ""; GameObject.Find("EcologyGrantText").GetComponent <Text>().enabled = false; GameObject.Find("EcologyGrantNumberUnits").GetComponent <Image> ().enabled = false; GameObject.Find("EcologyGrantButtonHelp").SetActive(false); } RankingManager.GetInstance().addScore((int)anualProduction); CoopManager.GetInstance().happyNewYear(); UserDataManager.GetInstance().resetYearlyData(); /* * const float TON = 1000000.0f; * if (anualRiceSold < TON) { * m_riceProductionNumberText.text = anualRiceSold.ToString (); * } else { * m_riceProductionNumberText.text = (anualRiceSold / TON).ToString ("0.00"); * m_riceProductionNumberUnitsText = "T"; * } */ GameObject.Find("Logic").GetComponent <TimeManager> ().pauseTime(); }
public void disableChunk(int chunkID) { if (m_chunkDisabled.ContainsKey(chunkID)) { ActionManager.GetInstance().stopActionChunk(chunkID); AnimationManager.GetInstance().removeChunkAnimation(chunkID); m_chunkDisabled[chunkID] = true; WorldTerrain.GetInstance().disableChunk(chunkID); } }
public void agafarPlanta() { Debug.Assert(hasPlantsForAChunk()); _plantes -= (uint)WorldTerrain.GetInstance().getTotalTilesInAChunk(); if (_plantes <= 0) { _sembrat = false; //changeRepresentation } }
private PenalizationManager() { WorldTerrain.GetInstance().addListenerToChunkAdded(addChunk); WorldTerrain.GetInstance().addListenerToChunkRemoved(removeChunk); m_phaseManager = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>(); m_phaseManager.addListenerToPhaseChange(checkActionsLastPhase); TimeManager timeManager = GameObject.FindGameObjectWithTag("Logic").GetComponent <TimeManager>(); timeManager.addListenerToYearChange(reset); }
private void unselectTile() { WorldTerrain worldTerrain = WorldTerrain.GetInstance(); if (_hasTileSelected) { // UNSELECT worldTerrain.unselectTile(_tileSelectedPosition[0], _tileSelectedPosition[1]); } _hasTileSelected = false; }
public void destroyBuilding(BUILDINGS buildingId) { BuildingsManager buildingsMan = BuildingsManager.GetInstance(); Building building = buildingsMan.getBuilding(buildingId); buildingsMan.destroy(buildingId); WorldTerrain worldTerrain = WorldTerrain.GetInstance(); worldTerrain.destroyBuilding(building.getRow(), building.getCol(), building.getVerticalTiles(), building.getHorizontalTiles()); }
public void newHourCallback() { for (int i = 0; i < _actionInProgress.Count; ++i) { _actionInProgress [i].addAnHourWorked(); if (_actionInProgress [i].isFinished) { WorldTerrain.GetInstance().actionFinishedInChunk(_actionInProgress [i].chunk, _actionInProgress [i].id); _actionInProgress.RemoveAt(i); } } }
/* * Creates clouds into the rhombus limited by A, B, D, being A the left-most point an defining the other points CCW * Note that C is not needed to calculate the points of the rhombus http://stackoverflow.com/questions/240778/random-points-inside-a-polygon */ private void createInitialInstances() { _cloudInstance = new List <Cloud> (); WorldTerrain worldTerrain = WorldTerrain.GetInstance(); m_terrainRows = worldTerrain.getNumTilesY(); m_terrainCols = worldTerrain.getNumTilesX(); //Vector3 A = worldTerrain.getTileWorldPosition(0 ,0); //Vector3 B = worldTerrain.getTileWorldPosition(m_terrainRows,0); //Vector3 C = worldTerrain.getTileWorldPosition(m_terrainRows,m_terrainCols); //Vector3 D = worldTerrain.getTileWorldPosition(0 ,m_terrainCols); for (uint i = 0; i < m_terrainCols; ++i) { Vector3 pos = worldTerrain.getTileWorldPosition(m_terrainRows, i); m_terrainBoundaries.Add(pos.x); } //_AB = new Vector2(B.x -A.x, B.y - A.y); //_AC = new Vector2(C.x -A.x, C.y - A.y); //_AD = new Vector2(D.x -A.x, D.y - A.y); //_movementDirection = new Vector2(_AC.x, _AC.y); //_movementDirection.Normalize (); //_A = new Vector2 (A.x, A.y); /*Debug.Log ("A::" + initialPoint.ToString ()); * Debug.Log ("B::" + B.ToString ()); * Debug.Log ("D::" + D.ToString ()); * Debug.Log ("AB::" + AB.ToString ()); * Debug.Log ("AD::" + AD.ToString ());*/ for (uint i = 0; i < NUMBER_OF_INSTANCES; ++i) { GameObject cloud = _cloud[(int)UnityEngine.Random.Range(0.0f, (float)NUMBER_CLOUDS)]; //float u = UnityEngine.Random.value; //float v = UnityEngine.Random.value; //Vector2 randomPoint = _A + u * _AB + v * _AD; uint randomCol = (uint)UnityEngine.Random.Range(0.0f, m_terrainCols); uint randomRow = (uint)UnityEngine.Random.Range(0.0f, m_terrainRows); uint minNumber = Math.Min(randomCol, randomRow); uint firstCol = randomCol - minNumber; uint firstRow = randomRow - minNumber; Vector3 randomPoint = worldTerrain.getTileWorldPosition(randomRow, randomCol); uint minEndPoint = Math.Min(m_terrainRows - firstRow, m_terrainCols - firstCol); Vector3 endPoint = worldTerrain.getTileWorldPosition(firstRow + minEndPoint, firstCol + minEndPoint); //arriba es y = 54 //abajo x = 42 //GameObject instance = ((GameObject)GameObject.Instantiate(cloud, new Vector3(randomPoint.x, randomPoint.y, _defaultZ), Quaternion.identity)); GameObject instance = ((GameObject)GameObject.Instantiate(cloud, new Vector3(randomPoint.x, randomPoint.y, _defaultZ), Quaternion.identity)); _cloudInstance.Add(new Cloud(instance, this, i, endPoint.x)); } }
private GameObject instantiateImg(string path, bool active) { GameObject gameObject = Resources.Load <GameObject>(path); WorldTerrain worldTerrain = WorldTerrain.GetInstance(); Vector3 worldPosition = worldTerrain.getTileWorldPosition(getRow(), getCol()); worldPosition.z = WorldTerrain.BUILDING_Z_LAYER; GameObject instance = (GameObject)GameObject.Instantiate(gameObject, worldPosition, Quaternion.identity); instance.SetActive(active); return(instance); }