public void StartNewFlight() { GameState.CoinValue = 1; GameState.DifficultyLevel = 1; Player.State.Refresh(); Player.Revive(); potionEffects.RefreshButtonInteractable(); CanvasCoordinator.SetHudInteractable(true); AudioClipPlayer.FadeFromMenuToInGameMusic(); manaBarConstructor.UpdateManaBarSize(); UnityAction onHudShown = () => { if (PlayerSettings.HasSeenControlsTutorial) { GameState.IsPaused = false; isFlightActive = true; } else { TutorialCoordinator.ActivateTiltTutorial(); } }; CanvasCoordinator.HideMenuesAndShowHud(onHudShown); }
private void GenerateObstacles(WorldSlice newWorldSlice) { // Spawn obstacles on flat ground var content = newWorldSlice.Tiles[newWorldSlice.GroundHeight].Content; if (content != null && (content.name.StartsWith("Flat") && newWorldSlice.Tiles[newWorldSlice.GroundHeight + 1].Content == null)) { // Trees if (DifficultyInfo.SpawnTrees) { worldTilePool.Spawn(newWorldSlice.Tiles[newWorldSlice.GroundHeight + 1], "Tree" + Random.Range(0, 4)); newWorldSlice.Tiles[newWorldSlice.GroundHeight + 1].Content.transform.Rotate( Random.Range(-4f, 4f), Random.Range(0f, 359f), 0f); worldTilePool.Spawn(newWorldSlice.Tiles[newWorldSlice.GroundHeight + 2], "TreeDummy"); } else if (DifficultyInfo.SpawnGraves) { // Graves worldTilePool.Spawn(newWorldSlice.Tiles[newWorldSlice.GroundHeight + 1], "Grave" + Random.Range(0, 3)); newWorldSlice.Tiles[newWorldSlice.GroundHeight + 1].Content.transform.Rotate( Random.Range(-7f, 7f), Random.Range(0f, 359f), 0); } } DecreaseHazardBuffers(); // Spawn Spiderwebs if (DifficultyInfo.SpawnWebs && webBuffer == 0) { webBuffer = DifficultyInfo.HazardBuffer; if (!PlayerSettings.HasSeenWebTutorial) { TutorialCoordinator.ActivateWebTutorial(); } foreach (var tile in newWorldSlice.Tiles.Where(t => t.Content == null)) { worldTilePool.Spawn(tile, tile.TileNum == 6 ? "WebTop" : "Web"); } foreach (var tile in newWorldSlice.Tiles.Where( t => t.Content.name.StartsWith("Ramp") || t.Content.name.StartsWith("Tree") || t.Content.name.StartsWith("Grave") || t.Content.name.StartsWith("Flat"))) { worldTilePool.FillWeb(tile); } } // Spawn coins GenerateCoins(newWorldSlice); // Spawn Ghosts if (DifficultyInfo.SpawnGhosts && ghostBuffer == 0) { ghostBuffer = DifficultyInfo.HazardBuffer; var extraHeight = (newWorldSlice.Tiles[newWorldSlice.GroundHeight].Content == null) ? 1 : 2; var tileIndex = Random.Range(newWorldSlice.GroundHeight + extraHeight, 6); if (newWorldSlice.Tiles[tileIndex].Content == null && newWorldSlice.Tiles[tileIndex + 1].Content == null) { worldTilePool.Spawn(newWorldSlice.Tiles[tileIndex], "Ghost"); worldTilePool.Spawn(newWorldSlice.Tiles[tileIndex + 1], "GhostDummy"); } } // Spawn spiders if (DifficultyInfo.SpawnSpiders && (newWorldSlice.Tiles[6].Content == null) && spiderBuffer == 0) { spiderBuffer = DifficultyInfo.HazardBuffer; worldTilePool.Spawn(newWorldSlice.Tiles[6], "Spider"); if (newWorldSlice.Tiles[6].Content != null) { newWorldSlice.Tiles[6].Content.transform.Rotate(0f, Random.Range(-25f, 25f), 0f); } else { Debug.LogError("Tile content was null!"); } } }