void Awake() { parser = new iniParser(); if (!parser.DoesExist("WormballSettings")) { parser.Set("MatchLength", ScoreManager.instance.totalGameTime.ToString()); parser.save("WormballSettings"); } else { parser.load("WormballSettings"); float parseVal = 5f; if (float.TryParse(parser.Get("MatchLength"), out parseVal)) { ScoreManager.instance.totalGameTime = float.Parse(parser.Get("MatchLength")); } else { ScoreManager.instance.totalGameTime = 45f; } } gameState = GameState.Menu; prevState = gameState; StartCoroutine(UpdateState()); #if UNITY_EDITOR AssetDatabase.Refresh(); #endif }
public void load(iniParser config) { string resolution = config.Get("g_resolution"); int posx = resolution.IndexOf("x"); int rW = int.Parse(resolution.Substring(0, (posx))); int rH = int.Parse(resolution.Substring(posx + 1)); bool rWM = bool.Parse(config.Get("g_windowed")); Screen.SetResolution(rW, rH, !rWM); }
void AdjustHorizontal() { if (bool.Parse(parser.Get("input_controller"))) { hRotation += -Input.GetAxis("win R horizontal") * horizontal.mouseSensitivity; } else { hRotation += Input.GetAxis("Mouse X") * horizontal.mouseSensitivity; } hRotation = AngleClamp(hRotation, horizontal.minimumAngle, horizontal.maximumAngle); rotationObject.transform.localEulerAngles = new Vector3(rotationObject.transform.localEulerAngles.x, hRotation, rotationObject.transform.localEulerAngles.z); }
// Use this for initialization void Start() { if (mode == DisplayMode.Colors) { background = new Texture2D(1, 1); background.SetPixel(1, 1, colors.background); background.wrapMode = TextureWrapMode.Repeat; background.Apply(); foreground = new Texture2D(1, 1); foreground.SetPixel(1, 1, colors.foreground); foreground.wrapMode = TextureWrapMode.Repeat; foreground.Apply(); xpShadow = new Texture2D(1, 1); xpShadow.SetPixel(1, 1, colors.xpShadowIncrease); xpShadow.wrapMode = TextureWrapMode.Repeat; xpShadow.Apply(); } else { background = textures.background; foreground = textures.foreground; xpShadow = textures.xpShadowIncrease; } barwidth = Screen.width * screenPer; boxwidth = barwidth / 10; barstrt = Screen.width * ((1.0f - screenPer) / 2); Debug.Log(barstrt + ":" + Screen.width); parser.Load(IniFiles.XP); if (parser.Get("XP").Equals("")) { parser.Set("", "XP", "0"); float curxp = 0; for (int i = 0; i < 200; i++) { if (i != 0) { curxp += 800 + (400 * (i - 1)); } int cp = Mathf.CeilToInt(curxp); parser.Set("Ranks", "level-" + i, curxp.ToString()); } curxp = 9999999; parser.Set("Ranks", "level-200", curxp.ToString()); parser.Save(IniFiles.XP); } localxp = int.Parse(parser.Get("XP")); calc(); }
void Refresh() { parser.Clear(); if (parser.DoesExist(IniFiles.CONFIG)) { parser.Load(IniFiles.CONFIG); } else { gs.Create(); parser.Load(IniFiles.CONFIG); } DepthOfField34 dof = gameObject.GetComponent <DepthOfField34>(); Bloom blf = gameObject.GetComponent <Bloom>(); AmbientObscurance ssao = gameObject.GetComponent <AmbientObscurance>(); SunShafts sunshaft = gameObject.GetComponent <SunShafts>(); NoiseAndGrain nag = gameObject.GetComponent <NoiseAndGrain>(); EdgeDetectEffectNormals edn = gameObject.GetComponent <EdgeDetectEffectNormals>(); Vignetting vig = gameObject.GetComponent <Vignetting>(); if (bool.Parse(parser.Get("fx_enable"))) { if (bool.Parse(parser.Get("fx_dof"))) { dof.enabled = true; dof.resolution = DofResolution.High; dof.quality = bool.Parse(parser.Get("fx_dof_foreground")) ? Dof34QualitySetting.BackgroundAndForeground : Dof34QualitySetting.OnlyBackground; dof.bokeh = bool.Parse(parser.Get("fx_dof_bokeh")) ? true : false; dof.focalPoint = float.Parse(parser.Get("fx_dof_focaldistance")); dof.smoothness = float.Parse(parser.Get("fx_dof_smoothness")); dof.focalSize = float.Parse(parser.Get("fx_dof_focalSize")); dof.visualize = bool.Parse(parser.Get("fx_dof_visualizeFocus")); switch (parser.Get("fx_dof_blurriness")) { case "0": dof.bluriness = DofBlurriness.Low; break; case "1": dof.bluriness = DofBlurriness.High; break; case "2": dof.bluriness = DofBlurriness.VeryHigh; break; default: dof.bluriness = DofBlurriness.High; break; } dof.maxBlurSpread = float.Parse(parser.Get("fx_dof_blurSpread")); dof.foregroundBlurExtrude = float.Parse(parser.Get("fx_dof_foregroundSize")); switch (parser.Get("fx_dof_bokeh_destination")) { case "0": dof.bokehDestination = BokehDestination.Background; break; case "1": dof.bokehDestination = BokehDestination.BackgroundAndForeground; break; case "2": dof.bokehDestination = BokehDestination.Foreground; break; default: dof.bokehDestination = BokehDestination.Background; break; } dof.bokehIntensity = float.Parse(parser.Get("fx_dof_bokeh_intensity")); dof.bokehThreshholdLuminance = float.Parse(parser.Get("fx_dof_bokeh_minLuminance")); dof.bokehThreshholdContrast = float.Parse(parser.Get("fx_dof_bokeh_minContrast")); dof.bokehDownsample = int.Parse(parser.Get("fx_dof_bokeh_DownSample")); dof.bokehScale = float.Parse(parser.Get("fx_dof_bokeh_sizeScale")); } else { dof.enabled = false; } // SSAO if (bool.Parse(parser.Get("fx_SSAO"))) { ssao.enabled = true; ssao.intensity = float.Parse(parser.Get("fx_SSAO_intensity")); ssao.radius = float.Parse(parser.Get("fx_SSAO_radius")); ssao.blurIterations = int.Parse(parser.Get("fx_SSAO_blurIterations")); ssao.blurFilterDistance = float.Parse(parser.Get("fx_SSAO_blurFilterDistance")); ssao.downsample = int.Parse(parser.Get("fx_SSAO_downsample")); } else { ssao.enabled = false; } // NOISE GRAIN nag.enabled = bool.Parse(parser.Get("fx_noisegrain")) ? true : false; nag.intensityMultiplier = float.Parse(parser.Get("fx_noisegrain_intensity")); // BLOOM if (bool.Parse(parser.Get("fx_bloom"))) { blf.enabled = true; switch (parser.Get("fx_bloom_quality")) { case "0": blf.quality = Bloom.BloomQuality.Cheap; break; case "1": blf.quality = Bloom.BloomQuality.High; break; default: blf.quality = Bloom.BloomQuality.High; break; } switch (parser.Get("fx_bloom_mode")) { case "0": blf.tweakMode = Bloom.TweakMode.Basic; break; case "1": blf.tweakMode = Bloom.TweakMode.Complex; break; default: blf.tweakMode = Bloom.TweakMode.Complex; break; } switch (parser.Get("fx_bloom_blendMode")) { case "0": blf.screenBlendMode = Bloom.BloomScreenBlendMode.Screen; break; case "1": blf.screenBlendMode = Bloom.BloomScreenBlendMode.Add; break; default: blf.screenBlendMode = Bloom.BloomScreenBlendMode.Add; break; } blf.hdr = bool.Parse(parser.Get("fx_bloom_hdr")) ? Bloom.HDRBloomMode.On : Bloom.HDRBloomMode.Off; blf.bloomIntensity = float.Parse(parser.Get("fx_bloom_intensity")); blf.bloomThreshhold = float.Parse(parser.Get("fx_bloom_threshhold")); blf.bloomBlurIterations = int.Parse(parser.Get("fx_bloom_blurIterations")); blf.blurWidth = float.Parse(parser.Get("fx_bloom_sampleDistance")); switch (parser.Get("fx_bloom_lensFlareMode")) { case "0": blf.lensflareMode = Bloom.LensFlareStyle.Ghosting; break; case "1": blf.lensflareMode = Bloom.LensFlareStyle.Anamorphic; break; case "2": blf.lensflareMode = Bloom.LensFlareStyle.Combined; break; default: blf.lensflareMode = Bloom.LensFlareStyle.Ghosting; break; } blf.lensflareIntensity = float.Parse(parser.Get("fx_bloom_LFlocalIntensity")); blf.lensflareThreshhold = float.Parse(parser.Get("fx_bloom_LFthreshhold")); } else { blf.enabled = false; } // Sunshafts if (bool.Parse(parser.Get("fx_sunshaft"))) { sunshaft.enabled = true; sunshaft.useDepthTexture = bool.Parse(parser.Get("fx_sunshaft_zBuffer")); switch (parser.Get("fx_sunshaft_resolution")) { case "0": sunshaft.resolution = SunShaftsResolution.Low; break; case "1": sunshaft.resolution = SunShaftsResolution.Normal; break; case "2": sunshaft.resolution = SunShaftsResolution.High; break; default: sunshaft.resolution = SunShaftsResolution.Normal; break; } switch (parser.Get("fx_sunshaft_blendMode")) { case "0": sunshaft.screenBlendMode = ShaftsScreenBlendMode.Add; break; case "1": sunshaft.screenBlendMode = ShaftsScreenBlendMode.Screen; break; default: sunshaft.screenBlendMode = ShaftsScreenBlendMode.Screen; break; } sunshaft.maxRadius = float.Parse(parser.Get("fx_sunshaft_distFalloff")); sunshaft.sunShaftBlurRadius = float.Parse(parser.Get("fx_sunshaft_blurSize")); sunshaft.radialBlurIterations = int.Parse(parser.Get("fx_sunshaft_blurIterations")); sunshaft.sunShaftIntensity = float.Parse(parser.Get("fx_sunshaft_intensity")); sunshaft.useSkyBoxAlpha = float.Parse(parser.Get("fx_sunshaft_alphaMask")); } else { sunshaft.enabled = false; } // Edge detect edn.enabled = bool.Parse(parser.Get("fx_edgeDetect")) ? true : false; // Vignetting if (bool.Parse(parser.Get("fx_vignetting"))) { vig.enabled = true; vig.intensity = float.Parse(parser.Get("fx_vignetting_intensity")); vig.blurSpread = float.Parse(parser.Get("fx_vignetting_blurredCornors")); vig.chromaticAberration = float.Parse(parser.Get("fx_vignetting_aberration")); } else { vig.enabled = false; } } else { dof.enabled = false; ssao.enabled = false; nag.enabled = false; blf.enabled = false; sunshaft.enabled = false; edn.enabled = false; vig.enabled = false; } }
void loadSettings() { windowed = bool.Parse(parser.Get("g_windowed")); postProccess = bool.Parse(parser.Get("fx_enable")); DoF = bool.Parse(parser.Get("fx_dof")); DoFforeground = bool.Parse(parser.Get("fx_dof_foreground")); DoFbokeh = bool.Parse(parser.Get("fx_dof_bokeh")); noise = bool.Parse(parser.Get("fx_noisegrain")); SSAO = bool.Parse(parser.Get("fx_SSAO")); bloom = bool.Parse(parser.Get("fx_bloom")); HDR = bool.Parse(parser.Get("fx_bloom_hdr")); sunShaft = bool.Parse(parser.Get("fx_sunshaft")); controller = bool.Parse(parser.Get("input_controller")); masterLVL = int.Parse(parser.Get("a_masterlvl")); musicLVL = int.Parse(parser.Get("a_musiclvl")); ambientlvl = int.Parse(parser.Get("a_ambientlvl")); switch (int.Parse(parser.Get("g_antialias"))) { case 1: antialiasSel = 1; break; case 2: antialiasSel = 2; break; case 4: antialiasSel = 3; break; case 8: antialiasSel = 4; break; default: antialiasSel = 0; break; } vsync = int.Parse(parser.Get("g_vsync")); dofFocusRange = float.Parse(parser.Get("fx_dof_focaldistance")); noiseIntensity = float.Parse(parser.Get("fx_noisegrain_intensity")); }
void Refresh() { parser.Load(IniFiles.CONFIG); smoothTime = float.Parse(parser.Get("fx_dof_smoothtime")); addDistance = float.Parse(parser.Get("fx_dof_focaldistance")); }
void UpdateSmoothedMovementDirection() { bool grounded = IsGrounded(); Vector3 forward = cameraTransform.TransformDirection(Vector3.forward); forward.y = 0; forward = forward.normalized; Vector3 right = new Vector3(forward.z, 0, -forward.x); float v = 0, h = 0; if (bool.Parse(parser.Get("input_controller"))) { v = Input.GetAxisRaw("win vertical"); h = Input.GetAxisRaw("win horizontal"); } else { v = Input.GetAxisRaw("Vertical"); h = Input.GetAxisRaw("Horizontal"); } if (v < -0.2) { movingBack = true; } else { movingBack = false; } bool wasMoving = isMoving; isMoving = Mathf.Abs(h) > 0.01f || Mathf.Abs(v) > 0.1f; Vector3 targetDirection = h * right + v * forward; if (grounded) { lockCameraTimer += Time.deltaTime; if (isMoving != wasMoving) { lockCameraTimer = 0.0f; } if (targetDirection != Vector3.zero) { if (moveSpeed < walkSpeed * 0.9 && grounded) { moveDirection = targetDirection.normalized; } else { moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000); moveDirection = moveDirection.normalized; } } float curSmooth = speedSmoothing * Time.deltaTime; float targetSpeed = Mathf.Min(targetDirection.magnitude, 1.0f); characterState = CharacterState.Idle; if (Input.GetKey(KeyCode.LeftShift) || Input.GetButton("L3")) { targetSpeed *= runSpeed; characterState = CharacterState.Running; } else if (Input.GetKey(KeyCode.LeftControl)) { targetSpeed *= sneakSpeed; characterState = CharacterState.Sneaking; } else if (Time.time - trotAfterSeconds > walkTimeStart) { targetSpeed *= trotSpeed; characterState = CharacterState.Trotting; } else { targetSpeed *= walkSpeed; characterState = CharacterState.Walking; } moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth); if (moveSpeed < walkSpeed * 0.3) { walkTimeStart = Time.time; } } else { if (jumping) { lockCameraTimer = 0.0f; } if (isMoving) { inAirVelocity += targetDirection.normalized * Time.deltaTime * inAirControlAcceleration; } } }