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 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); } } } } }
public uint getStartMonthOfPhase(TypeFase phase) { if (phase == TypeFase.NONE) { return(0); } return(_startPhaseMonth[(int)phase]); }
public uint getStartDayOfPhase(TypeFase phase) { if (phase == TypeFase.NONE) { return(0); } return(_startPhaseDay[(int)phase]); }
// prepara el terreno y crea un tile donde plantar arroz public void createRiceChunk(uint row, uint col, bool flooded) { int chunkID = chunkNextID++; Debug.Log("Building Chunk #" + chunkID); chunkTilesPos[chunkID] = new List <Pair <uint, uint> > (); for (uint i = row - RICE_CHUNK_SEPARATION; i < row + RICE_CHUNK_H + RICE_CHUNK_SEPARATION; ++i) { for (uint j = col - RICE_CHUNK_SEPARATION; j < col + RICE_CHUNK_W + RICE_CHUNK_SEPARATION; ++j) { if (i < row || i >= row + RICE_CHUNK_H || j < col || j >= col + RICE_CHUNK_W) { if (worldTerrainType [i, j] != TileTerrainType.CANAL) { worldTerrainType [i, j] = TileTerrainType.SEPARATOR; } } else { chunkTilesPos[chunkID].Add(new Pair <uint, uint>(i, j)); worldTerrainType [i, j] = TileTerrainType.RICE_TERRAIN; riceTerrains [i, j] = new RiceTerrainTile(i, j, flooded); riceTerrains [i, j].setChunkNumber(chunkID); riceTerrains[i, j].setLocalID(chunkTilesPos[chunkID].Count - 1); Vegetation veg = getTileVegetation(i, j); if (veg != null) { veg.delete(); } if (canalManager.tileHasCanal(i, j)) { canalManager.deleteCanal(i, j); } } updateTileRepresentation(i, j); } } canalManager.addRiceChunk(chunkID, row, col, RICE_CHUNK_W, RICE_CHUNK_H); canalManager.updateCanals(); m_chunkChangedListener(); m_chunkAddedListener(chunkID); _weedFactory.addChunkID(chunkID); PenalizationManager.GetInstance().checkActionsTillCurrentPhase(); TypeFase phase = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager> ().getCurrentPhase(); if (phase != TypeFase.PREWORK_I && phase != TypeFase.NONE) { disableChunk(chunkID); } }
public void load(PhaseManagerData phaseManagerData) { Debug.Log("Loading... PhaseManager"); _timeManager = GetComponent <TimeManager>(); _timeManager._onTimeStateChange += handleOnTimeStateChange; _phaseActions = JSONLoader.readPhaseActions(); m_phasesInfo = JSONLoader.readPhaseInfo(); _currentPhase = phaseManagerData.CurrentPhase; _lastPhase = phaseManagerData.LastPhase; }
private TypeFase DeterminePreviousPhase(TypeFase _currentPhase) { if (_currentPhase != TypeFase.NONE) { uint day = _startPhaseDay [(int)_currentPhase]; uint month = _startPhaseMonth[(int)_currentPhase]; --day; if (day == 0) { --month; if (month == 0) { return(TypeFase.NONE); } else { day = _timeManager.getDaysOfAMonth(month); } } return(DeterminePhaseByDate(day, month)); } else { uint currentDay = _timeManager.getCurrentDay(); uint currentMonth = _timeManager.getCurrentMonth(); int i = 0; bool phaseFound = false; while (currentMonth >= _startPhaseMonth [i]) { if (currentMonth == _startPhaseMonth[i] && currentDay > _endPhaseDay[i]) { break; } else { phaseFound = true; ++i; } } if (phaseFound) { //var phases = Enum.GetValues (typeof(TypeFase)); int j = 0; foreach (TypeFase phase in Enum.GetValues(typeof(TypeFase))) { if (j == i) { return(phase); } ++j; } } return(TypeFase.NONE); } }
public void handleOnTimeStateChange() { TypeFase newPhase = (TypeFase)determinePhase(); if (_currentPhase != newPhase) { _lastPhase = _currentPhase; _currentPhase = newPhase; _onPhaseChange(); } }
void Start() { if (!PlayerPrefs.HasKey("LoadData") || PlayerPrefs.GetInt("LoadData") == 0) { _phaseActions = JSONLoader.readPhaseActions(); m_phasesInfo = JSONLoader.readPhaseInfo(); _currentPhase = (TypeFase)determinePhase(); if (_currentPhase != TypeFase.PREWORK_I) { _lastPhase = (TypeFase)DeterminePreviousPhase(_currentPhase); } } }
private TypeFase DeterminePreviousUsefulPhase(TypeFase _currentPhase) { TypeFase lastPhase = TypeFase.NONE; foreach (TypeFase phase in Enum.GetValues(typeof(TypeFase))) { if (phase == _currentPhase) { break; } else { lastPhase = phase; } } return(lastPhase); }
private void updateCalendar() { if (m_remainingDays != null) { TypeFase currentPhase = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>().getCurrentPhase(); if (currentPhase != TypeFase.NONE) { m_remainingDays.gameObject.SetActive(true); m_calendar.gameObject.SetActive(true); int remainingDays = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>().getRemainingDaysOfCurrentPhase(); m_remainingDays.text = Dictionary.getString("WILL_TAKE") + " " + ((ChunkAction)m_actions[m_currentAction]).duration / 24 + " " + Dictionary.getString("DAYS") + "." + Dictionary.getString("HAVE_LEFT") + " " + remainingDays.ToString() + " " + Dictionary.getString("DAYS_TO_DO_IT"); } else { m_remainingDays.gameObject.SetActive(false); m_calendar.gameObject.SetActive(false); } } }
public List <int> GetActionsTillLastUsefulPhase() { List <int> actions = new List <int> (); TypeFase lastUsefulPhase = DeterminePreviousUsefulPhase(_currentPhase); if (lastUsefulPhase != TypeFase.NONE) { foreach (TypeFase phase in Enum.GetValues(typeof(TypeFase))) { if (phase == _currentPhase) { break; } else { List <int> actionsThisPhase = _phaseActions [(int)_lastPhase]; actions.AddRange(actionsThisPhase); } } } return(actions); }
public void AdvanceTillPhase(TypeFase phase, bool makeActions = true) { TimeManager tm = GameObject.FindGameObjectWithTag("Logic").GetComponent <TimeManager>(); PhaseManager pm = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>(); int oldMonth = (int)tm.getCurrentMonth(); uint newDay = pm.getStartDayOfPhase(phase); uint newMonth = pm.getStartMonthOfPhase(phase); uint year = tm.getCurrentYear(); tm.setDate(newDay, newMonth, year); pm.setCurrentPhase(phase); for (int i = 0; i < (newMonth - oldMonth + 12) % 12; ++i) { WorkerManager.GetInstance().payWorkers(); } if (makeActions) { MakeActionsTillPhase(phase); } }
public List <int> getActionsInPhase(TypeFase phase) { return(_phaseActions[(int)phase]); }
public void setCurrentPhase(TypeFase phase) { _currentPhase = phase; }