private void Awake() { DontDestroyOnLoad(gameObject); _config = GameConfiguration.Get(); _config.OnBackgroundMusicVolumeChange += ChangeBackgroundMusicVolume; _config.OnSoundEffectVolumeChange += ChangeSoundEffectVolume; BackgroundMusic.volume = _config.BackgroundMusicVolume; if (GameObject.FindGameObjectsWithTag(Tag.Audio).Length > 1) { DestroyImmediate(gameObject); } _soundEffAudioSources = new List <AudioSource>(); _audioClips = new Dictionary <AudioClipType, AudioClip>(); foreach (var labelAudioClip in LabelAudioClips.Where( labelAudioClip => !_audioClips.ContainsKey(labelAudioClip.Label) && labelAudioClip.AudioClip != null)) { _audioClips.Add(labelAudioClip.Label, labelAudioClip.AudioClip); } }
private void Awake() { _config = GameConfiguration.Get(); _resolutions = Screen.resolutions; _audioControl = GameObject.FindGameObjectWithTag(Tag.Audio).GetComponent <AudioControl>(); Resolution.AddOptions(_resolutions.Select(res => res.ToString().Split('@')[0]).ToList()); GraphicQuality.AddOptions(QualitySettings.names.ToList()); Load(); BgmSlider.onValueChanged.AddListener(value => { _audioControl.BackgroundMusic.volume = value; _valueChanged = true; }); SoundEffectSlider.onValueChanged.AddListener(value => { _audioControl.PlayAudioClip(AudioClipType.Greetings, value); _valueChanged = true; }); Resolution.onValueChanged.AddListener( index => { Screen.SetResolution(_resolutions[index].width, _resolutions[index].height, Screen.fullScreen); _valueChanged = true; }); NumberOfShip.onValueChanged.AddListener( index => { _valueChanged = true; }); GraphicQuality.onValueChanged.AddListener(level => { QualitySettings.SetQualityLevel(level, true); _valueChanged = true; }); ChangeApplyWindow.YesButton.onClick.AddListener(() => { Leave(); ChangeApplyWindow.gameObject.SetActive(false); }); ChangeApplyWindow.NoButton.onClick.AddListener(() => { ChangeApplyWindow.gameObject.SetActive(false); }); }
protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration) { int num = configuration.Get <int>("FlatBeachPadding"); progress.Message = Lang.gen[0].Value; TerrainFeatureType terrainFeatureType = TerrainFeatureType.Plateau; int num2 = 0; double num3 = (double)Main.maxTilesY * 0.3; num3 *= (double)GenBase._random.Next(90, 110) * 0.005; double num4 = num3 + (double)Main.maxTilesY * 0.2; num4 *= (double)GenBase._random.Next(90, 110) * 0.01; double num5 = num3; double num6 = num3; double num7 = num4; double num8 = num4; double num9 = (double)Main.maxTilesY * 0.23; SurfaceHistory surfaceHistory = new SurfaceHistory(500); num2 = LeftBeachSize + num; for (int i = 0; i < Main.maxTilesX; i++) { progress.Set((float)i / (float)Main.maxTilesX); num5 = Math.Min(num3, num5); num6 = Math.Max(num3, num6); num7 = Math.Min(num4, num7); num8 = Math.Max(num4, num8); if (num2 <= 0) { terrainFeatureType = (TerrainFeatureType)GenBase._random.Next(0, 5); num2 = GenBase._random.Next(5, 40); if (terrainFeatureType == TerrainFeatureType.Plateau) { num2 *= (int)((double)GenBase._random.Next(5, 30) * 0.2); } } num2--; if ((double)i > (double)Main.maxTilesX * 0.45 && (double)i < (double)Main.maxTilesX * 0.55 && (terrainFeatureType == TerrainFeatureType.Mountain || terrainFeatureType == TerrainFeatureType.Valley)) { terrainFeatureType = (TerrainFeatureType)GenBase._random.Next(3); } if ((double)i > (double)Main.maxTilesX * 0.48 && (double)i < (double)Main.maxTilesX * 0.52) { terrainFeatureType = TerrainFeatureType.Plateau; } num3 += GenerateWorldSurfaceOffset(terrainFeatureType); float num10 = 0.17f; float num11 = 0.26f; if (WorldGen.drunkWorldGen) { num10 = 0.15f; num11 = 0.28f; } if (i < LeftBeachSize + num || i > Main.maxTilesX - RightBeachSize - num) { num3 = Utils.Clamp(num3, (double)Main.maxTilesY * 0.17, num9); } else if (num3 < (double)((float)Main.maxTilesY * num10)) { num3 = (float)Main.maxTilesY * num10; num2 = 0; } else if (num3 > (double)((float)Main.maxTilesY * num11)) { num3 = (float)Main.maxTilesY * num11; num2 = 0; } while (GenBase._random.Next(0, 3) == 0) { num4 += (double)GenBase._random.Next(-2, 3); } if (num4 < num3 + (double)Main.maxTilesY * 0.06) { num4 += 1.0; } if (num4 > num3 + (double)Main.maxTilesY * 0.35) { num4 -= 1.0; } surfaceHistory.Record(num3); FillColumn(i, num3, num4); if (i == Main.maxTilesX - RightBeachSize - num) { if (num3 > num9) { RetargetSurfaceHistory(surfaceHistory, i, num9); } terrainFeatureType = TerrainFeatureType.Plateau; num2 = Main.maxTilesX - i; } } Main.worldSurface = (int)(num6 + 25.0); Main.rockLayer = num8; double num12 = (int)((Main.rockLayer - Main.worldSurface) / 6.0) * 6; Main.rockLayer = (int)(Main.worldSurface + num12); int num13 = (int)(Main.rockLayer + (double)Main.maxTilesY) / 2; num13 += GenBase._random.Next(-100, 20); int lavaLine = num13 + GenBase._random.Next(50, 80); int num14 = 20; if (num7 < num6 + (double)num14) { double num15 = (num7 + num6) / 2.0; double num16 = Math.Abs(num7 - num6); if (num16 < (double)num14) { num16 = num14; } num7 = num15 + num16 / 2.0; num6 = num15 - num16 / 2.0; } RockLayer = num4; RockLayerHigh = num8; RockLayerLow = num7; WorldSurface = num3; WorldSurfaceHigh = num6; WorldSurfaceLow = num5; WaterLine = num13; LavaLine = lavaLine; }
protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration) { int num1 = configuration.Get <int>("FlatBeachPadding"); progress.Message = Lang.gen[0].Value; TerrainPass.TerrainFeatureType featureType = TerrainPass.TerrainFeatureType.Plateau; double num2 = (double)Main.maxTilesY * 0.3 * ((double)GenBase._random.Next(90, 110) * 0.005); double num3 = (num2 + (double)Main.maxTilesY * 0.2) * ((double)GenBase._random.Next(90, 110) * 0.01); double val2_1 = num2; double val2_2 = num2; double val2_3 = num3; double val2_4 = num3; double num4 = (double)Main.maxTilesY * 0.23; TerrainPass.SurfaceHistory history = new TerrainPass.SurfaceHistory(500); int num5 = this.LeftBeachSize + num1; for (int index = 0; index < Main.maxTilesX; ++index) { progress.Set((float)index / (float)Main.maxTilesX); val2_1 = Math.Min(num2, val2_1); val2_2 = Math.Max(num2, val2_2); val2_3 = Math.Min(num3, val2_3); val2_4 = Math.Max(num3, val2_4); if (num5 <= 0) { featureType = (TerrainPass.TerrainFeatureType)GenBase._random.Next(0, 5); num5 = GenBase._random.Next(5, 40); if (featureType == TerrainPass.TerrainFeatureType.Plateau) { num5 *= (int)((double)GenBase._random.Next(5, 30) * 0.2); } } --num5; if ((double)index > (double)Main.maxTilesX * 0.45 && (double)index < (double)Main.maxTilesX * 0.55 && (featureType == TerrainPass.TerrainFeatureType.Mountain || featureType == TerrainPass.TerrainFeatureType.Valley)) { featureType = (TerrainPass.TerrainFeatureType)GenBase._random.Next(3); } if ((double)index > (double)Main.maxTilesX * 0.48 && (double)index < (double)Main.maxTilesX * 0.52) { featureType = TerrainPass.TerrainFeatureType.Plateau; } num2 += TerrainPass.GenerateWorldSurfaceOffset(featureType); float num6 = 0.17f; float num7 = 0.26f; if (WorldGen.drunkWorldGen) { num6 = 0.15f; num7 = 0.28f; } if (index < this.LeftBeachSize + num1 || index > Main.maxTilesX - this.RightBeachSize - num1) { num2 = Utils.Clamp <double>(num2, (double)Main.maxTilesY * 0.17, num4); } else if (num2 < (double)Main.maxTilesY * (double)num6) { num2 = (double)Main.maxTilesY * (double)num6; num5 = 0; } else if (num2 > (double)Main.maxTilesY * (double)num7) { num2 = (double)Main.maxTilesY * (double)num7; num5 = 0; } while (GenBase._random.Next(0, 3) == 0) { num3 += (double)GenBase._random.Next(-2, 3); } if (num3 < num2 + (double)Main.maxTilesY * 0.06) { ++num3; } if (num3 > num2 + (double)Main.maxTilesY * 0.35) { --num3; } history.Record(num2); TerrainPass.FillColumn(index, num2, num3); if (index == Main.maxTilesX - this.RightBeachSize - num1) { if (num2 > num4) { TerrainPass.RetargetSurfaceHistory(history, index, num4); } featureType = TerrainPass.TerrainFeatureType.Plateau; num5 = Main.maxTilesX - index; } } Main.worldSurface = (double)(int)(val2_2 + 25.0); Main.rockLayer = val2_4; double num8 = (double)((int)((Main.rockLayer - Main.worldSurface) / 6.0) * 6); Main.rockLayer = (double)(int)(Main.worldSurface + num8); int num9 = (int)(Main.rockLayer + (double)Main.maxTilesY) / 2 + GenBase._random.Next(-100, 20); int num10 = num9 + GenBase._random.Next(50, 80); int num11 = 20; if (val2_3 < val2_2 + (double)num11) { double num6 = (val2_3 + val2_2) / 2.0; double num7 = Math.Abs(val2_3 - val2_2); if (num7 < (double)num11) { num7 = (double)num11; } val2_3 = num6 + num7 / 2.0; val2_2 = num6 - num7 / 2.0; } this.RockLayer = num3; this.RockLayerHigh = val2_4; this.RockLayerLow = val2_3; this.WorldSurface = num2; this.WorldSurfaceHigh = val2_2; this.WorldSurfaceLow = val2_1; this.WaterLine = num9; this.LavaLine = num10; }
private void Start() { ShipCount = GameConfiguration.Get().NumberOfShip; _targetList = GetComponent <TargetList>(); }