public void Launch(LevelConditions conditions, Dictionary<int,CellController> cells, Dictionary<int,WallController> walls) { rooms.Clear(); processed.Clear(); Doors.Clear(); LCache.Clear(); LogicCells.Clear(); Conditions = conditions; // Filling logic walls foreach(WallController w in walls.Values) LogicWalls[w.Position.toInt()] = new LogicWall(w.Position,w.wallSprite.Top, w.wallSprite.Bottom, w.wallSprite.Left, w.wallSprite.Right); // Filling logic cells foreach(CellController cell in cells.Values) { if(LogicCells.ContainsKey(cell.Position.toInt())) continue; LogicCells.Add(cell.Position.toInt(),new LogicCell(cell.Position)); if(cell.SizeX>1 || cell.SizeY>1) { MapRect rect = cell.GetCurCellIndexes(); rect.Foreach((MapPoint p) => { if(!LogicCells.ContainsKey(p.toInt())) LogicCells.Add(p.toInt(),new LogicCell(p)); }); } } // Calculating reaches foreach(LogicCell cell in LogicCells.Values) { WallController w = null; LogicCell c = null; //left c = GetLogicCell(cell.Position.X-1, cell.Position.Y); w = GetWall(cell.Position.X, cell.Position.Y); if(c!=null && (w==null || w.wallSprite.Top==false)) cell.ReachableCells.Add(c); //right c = GetLogicCell(cell.Position.X+1, cell.Position.Y); w = GetWall(cell.Position.X+1, cell.Position.Y+1); if(c!=null && (w==null || w.wallSprite.Bottom==false)) cell.ReachableCells.Add(c); //top c = GetLogicCell(cell.Position.X, cell.Position.Y+1); w = GetWall(cell.Position.X+1, cell.Position.Y+1); if(c!=null && (w==null || w.wallSprite.Left==false)) cell.ReachableCells.Add(c); //bottom c = GetLogicCell(cell.Position.X, cell.Position.Y-1); w = GetWall(cell.Position.X, cell.Position.Y); if(c!=null && (w==null || w.wallSprite.Right==false)) cell.ReachableCells.Add(c); cell.AdjacentWalls+=GetWall(cell.Position.X, cell.Position.Y)==null?0:1; cell.AdjacentWalls+=GetWall(cell.Position.X+1, cell.Position.Y)==null?0:1; cell.AdjacentWalls+=GetWall(cell.Position.X, cell.Position.Y+1)==null?0:1; cell.AdjacentWalls+=GetWall(cell.Position.X+1, cell.Position.Y+1)==null?0:1; } // Finding Rooms curRoom = new Room(this); foreach(LogicCell cell in LogicCells.Values) { if(processed.Contains(cell)) continue; Next (cell); if(curRoom.Size>0) { rooms.Add(curRoom); Debug.Log(string.Format("Found room #{1} with {0} cells",curRoom.Size,curRoom.Number)); curRoom = new Room(this); curRoom.Number = rooms.Count; } } // STEP 2 - Recognize rooms Recognize(); // STEP 3 - Calculate connections Connections(); foreach(Room r in rooms) { M.Overlay.DrawRoom(r); Debug.Log(string.Format("Room #{0} is {1}, {2} objects", r.Number, Enum.GetName(typeof(RoomType),r.TypeOfRoom), r.LogicObjects.Count)); foreach(Door d in r.Doors) { if(d.Rooms.Count==1) { Debug.Log(string.Format(" Room #{0} contains door that leads to nothing",r.Number)); } else if(d.Rooms.Count==2) { Debug.Log(string.Format(" Room #{0} contains door that leads to room #{1}", r.Number, d.GetAnotherRoom(r).Number)); } else { Debug.Log(string.Format(" Buggy room #{0}",r.Number)); } } } evaluator.Launch(); }
public void Launch(LevelConditions conditions, Dictionary <int, CellController> cells, Dictionary <int, WallController> walls) { rooms.Clear(); processed.Clear(); Doors.Clear(); LCache.Clear(); LogicCells.Clear(); Conditions = conditions; // Filling logic walls foreach (WallController w in walls.Values) { LogicWalls[w.Position.toInt()] = new LogicWall(w.Position, w.wallSprite.Top, w.wallSprite.Bottom, w.wallSprite.Left, w.wallSprite.Right); } // Filling logic cells foreach (CellController cell in cells.Values) { if (LogicCells.ContainsKey(cell.Position.toInt())) { continue; } LogicCells.Add(cell.Position.toInt(), new LogicCell(cell.Position)); if (cell.SizeX > 1 || cell.SizeY > 1) { MapRect rect = cell.GetCurCellIndexes(); rect.Foreach((MapPoint p) => { if (!LogicCells.ContainsKey(p.toInt())) { LogicCells.Add(p.toInt(), new LogicCell(p)); } }); } } // Calculating reaches foreach (LogicCell cell in LogicCells.Values) { WallController w = null; LogicCell c = null; //left c = GetLogicCell(cell.Position.X - 1, cell.Position.Y); w = GetWall(cell.Position.X, cell.Position.Y); if (c != null && (w == null || w.wallSprite.Top == false)) { cell.ReachableCells.Add(c); } //right c = GetLogicCell(cell.Position.X + 1, cell.Position.Y); w = GetWall(cell.Position.X + 1, cell.Position.Y + 1); if (c != null && (w == null || w.wallSprite.Bottom == false)) { cell.ReachableCells.Add(c); } //top c = GetLogicCell(cell.Position.X, cell.Position.Y + 1); w = GetWall(cell.Position.X + 1, cell.Position.Y + 1); if (c != null && (w == null || w.wallSprite.Left == false)) { cell.ReachableCells.Add(c); } //bottom c = GetLogicCell(cell.Position.X, cell.Position.Y - 1); w = GetWall(cell.Position.X, cell.Position.Y); if (c != null && (w == null || w.wallSprite.Right == false)) { cell.ReachableCells.Add(c); } cell.AdjacentWalls += GetWall(cell.Position.X, cell.Position.Y) == null?0:1; cell.AdjacentWalls += GetWall(cell.Position.X + 1, cell.Position.Y) == null?0:1; cell.AdjacentWalls += GetWall(cell.Position.X, cell.Position.Y + 1) == null?0:1; cell.AdjacentWalls += GetWall(cell.Position.X + 1, cell.Position.Y + 1) == null?0:1; } // Finding Rooms curRoom = new Room(this); foreach (LogicCell cell in LogicCells.Values) { if (processed.Contains(cell)) { continue; } Next(cell); if (curRoom.Size > 0) { rooms.Add(curRoom); Debug.Log(string.Format("Found room #{1} with {0} cells", curRoom.Size, curRoom.Number)); curRoom = new Room(this); curRoom.Number = rooms.Count; } } // STEP 2 - Recognize rooms Recognize(); // STEP 3 - Calculate connections Connections(); foreach (Room r in rooms) { M.Overlay.DrawRoom(r); Debug.Log(string.Format("Room #{0} is {1}, {2} objects", r.Number, Enum.GetName(typeof(RoomType), r.TypeOfRoom), r.LogicObjects.Count)); foreach (Door d in r.Doors) { if (d.Rooms.Count == 1) { Debug.Log(string.Format(" Room #{0} contains door that leads to nothing", r.Number)); } else if (d.Rooms.Count == 2) { Debug.Log(string.Format(" Room #{0} contains door that leads to room #{1}", r.Number, d.GetAnotherRoom(r).Number)); } else { Debug.Log(string.Format(" Buggy room #{0}", r.Number)); } } } evaluator.Launch(); }
/// <summary> /// Inicia la secuencia al inicio del juego /// </summary> void fillmylevel() { if (!MenuVersion) { //Congela los elementos jubales por ahora FreezeGame(true); //Ajustamos este nivel dependiendo de el sitio en las build settings de su escena level = sProfileManager.ProfileSingleton.newLevelIndex; sProfileManager.ProfileSingleton.ChangingLevel = false; if (sProfileManager.instance != null) { if (level > sProfileManager.instance.levelconditions.Count - 1) { level = 1; } } //Clonamos la configuración de este nivel (LevelConditions) if (sProfileManager.instance != null) { LevelConditions LC = sProfileManager.instance.levelconditions.Find(x => x.Code == sProfileManager.ProfileSingleton.profileLevels[level].code); if (LC != null) { myLevel = ObjectCloner.Clone <LevelConditions>(LC); } if (LC == null) { myLevel = defaultLevel; Debug.LogWarning("Failed to Load Level Conditions"); } } //if sProfiel dues not exist, Bootstrap a TEST level if (sProfileManager.instance == null) { myLevel = defaultLevel; } //GUI Activa el panel de entrada y la GUI detras IntroPanel.SetActive(true); GUIPanel.SetActive(true); //Set Strings MoneyText.text = _money.ToString(); IntroMenuMainLabel.text = "Level " + (level + 1).ToString() + " - Menu"; //Configuramos el MODO de este Nivel //(Actualmente solo existe TimeAttack) //TODO: More LevelModes switch (myLevel.mode) { case LevelMode.TimeAttack: //En esta parte se inician los Listeners para los //distintos eventos que pueden ocurrir durante el juego OnScore += TimeAttackOnScoreListener; OnMoneyGain += TimeAttackOnMoneyGainListener; OnCompeletedQuest += TimeAttackOnCompletedQuestListener; //Se inicializa el Timer (no empieza aún, está Freeze) TimeController.s.SetTimer((float)myLevel.startingTimer, TimeAttackEndGameVictoryCheck, true, 0f, false); TimeController.s.timer.AddAction(10, ActivateLowTimeTimerAnimation); //TimeController.s.timer.AddAction(0, StopLowTimeTimerAnimation); foreach (Quest q in myLevel.quests.FindAll(x => x.winCondition == WinCondition.Time)) { TimeController.s.timer.AddAction((int)((float)myLevel.startingTimer - (float)q.winAmount), () => { q.finished = true; }); } break; default: break; } //CONFIG QUEST FOREACH LOOP (FOR en el futuro) //LINKED QUEST SET UP //--- //Repasamos las Quest de este nivel, creamos la LISTA por referencia //de todas las misiones asociadas a otras misiones //Nota este Foreach vale para otra cosa mas(ver mas abajo) int e = 0; foreach (Quest q in myLevel.quests) { q.completed = false; q.LinkedQuest = new List <Quest>(); if (q.LinkedQuestIndex.Count > 0) { foreach (int i in q.LinkedQuestIndex) { if (i < e) { q.LinkedQuest.Add(myLevel.quests[i]); q.LinkedQuestEnabled = true; } } } e += 1; //--- //Creamos los SLATES apropiados (Para UI y para la INTRO) CreateGUISlate(q, e); CreateIPGUISlate(q, e, false); } //Tras crear Slates se le indica al Grid que se ajuste //(No es automático) GameObject.FindGameObjectWithTag("QuestGUI").GetComponent <UIGrid>().Reposition(); GameObject.FindGameObjectWithTag("IPQuestSlateAnchor").GetComponent <UIGrid>().Reposition(); //El juego comienza en Pause, no se deben ver repetidas las Quest: QuestGrid.SetActive(false); //QuestGrid son las quest principales. IP las del Menú //Ahora se Activa la Intro //(En la Escena viene ya activada por defecto) FailSafe: //Esta lina activa el tutorial (si es false) //O va directo al menú de INTRO (si es true) if (sProfileManager.instance != null) { TutorialController.s.hasTutorial = !sProfileManager.ProfileSingleton.profileLevels[level].TutorialDone; TutorialController.ChangeMyState(sProfileManager.ProfileSingleton.profileLevels[level].TutorialDone); if (!sProfileManager.ProfileSingleton.profileLevels[level].TutorialDone) { TutorialController.s.ResetTutorialAndGo(); } else { TutorialController.s.secondTime = true; } } } else { //En caso de que esto sea el MENU (Menu Versión == true), ponemos musica de menu si es necesario. if (GameConfig.s.MusicState) { if (!MusicStore.s.AliasIsPlaying("Menu")) { MusicStore.s.PlayMusicByAlias("Menu", 0f, GameConfig.s.MusicVolume, true, 5f, true, 1f); } } } //NOTA: //Cuando el jugador indica de empezar a jugar se ejecuta //"LaunchCountdownAnimation()" //y despues del Countdown = "StartGame()" (ver Mas abajo) }
private void Awake() { current = this; DontDestroyOnLoad(this); }