void FinishChapterTrigger(Chapter c, bool firstChapter) { string s = "Prepare the following tiles:\r\n\r\n"; foreach (HexTile ht in c.tileObserver) { s += ht.idNumber + ", "; } s = s.Substring(0, s.Length - 2); FindObjectOfType <InteractionManager>().GetNewTextPanel().ShowOkContinue(s, ButtonIcon.Continue, () => { //TileGroup tg = FindObjectOfType<TileManager>().CreateGroupFromChapter( c ); TileGroup tg = c.tileGroup; if (tg == null) { Debug.Log("FinishChapterTrigger::WARNING::Chapter has no tiles: " + c.dataName); return; } tg.ActivateTiles(); FindObjectOfType <Engine>().RemoveFog(tg.GetChapter().dataName); //attempt to attach this tg, but only if it IS dynamic //fall back to using random tg if it doesn't fit if (c.isDynamic) { StartCoroutine(AttachTile(tg)); ////get ALL explored tilegroups in play //var tilegroups = ( from ch in chapterList // where ch.tileGroup.isExplored // select ch.tileGroup ).ToList(); //bool success = false; //if ( previousGroup != null ) //{ // success = tg.AttachTo( previousGroup ); // //remove so not attempted again below // tilegroups.Remove( previousGroup ); //} //else //{ // int randIdx = GlowEngine.GenerateRandomNumbers( tilegroups.Count )[0]; // TileGroup randGroup = tilegroups[randIdx]; // success = tg.AttachTo( randGroup ); // //remove so not attempted again below // tilegroups.RemoveAt( randIdx ); //} //if ( !success ) //{ // Debug.Log( "***SEARCHING for random tilegroup to attach to..." ); // foreach ( TileGroup _tg in tilegroups ) // { // success = tg.AttachTo( _tg ); // if ( success ) // break; // } //} } tg.AnimateTileUp(c); previousGroup = tg; if (firstChapter && c.isPreExplored) { tg.Colorize(); tg.isExplored = true; } FindObjectOfType <CamControl>().MoveTo(tg.groupCenter); //check triggered token queue var foo = from tname in tokenTriggerQueue from tile in tg.tileList.Where(x => x.HasTriggeredToken(tname)) select new { tile, tname }; //if ( foo.Count() > 0 ) //Debug.Log( "FinishChapterTrigger::" + foo.Count() ); foreach (var item in foo) { item.tile.EnqueueTokenTrigger(item.tname); //tokenTriggerQueue.Remove( item.tname ); } if (tg.startPosition.x != -1000) { GlowTimer.SetTimer(1, () => { startMarker.Spawn(tg.startPosition); if (firstChapter && !c.isPreExplored) { tg.Colorize(true); tg.isExplored = true; } }); FindObjectOfType <InteractionManager>().GetNewTextPanel().ShowOkContinue("Place your Heroes in the indicated position.", ButtonIcon.Continue); } }); }