IEnumerator TransitionFire(FireSize fs, bool stoked) { float time = 6f * (GameController.Instance.SpeedMode ? .001f : 1); float t = 0.0f; var fd = fireDict[fs]; var startRange = light.range; var startIntensity = light.intensity; var startFlameParticles = flameParticleSystem.maxParticles; var startSparkParticles = stoked ? fd.SparkMaxParticles * 5 : sparkParticleSystem.maxParticles; Color color; while (t < 1.0f) { t += Time.deltaTime * (Time.timeScale / time); var smoothT = Mathf.SmoothStep(0.0f, 1.0f, t); currentLightRange = Mathf.Lerp(startRange, fd.LightRange, smoothT); currentLightIntensity = Mathf.Lerp(startIntensity, fd.LightIntensity, smoothT); flameParticleSystem.maxParticles = Mathf.RoundToInt(Mathf.Lerp(startFlameParticles, fd.FlameMaxParticles, smoothT)); sparkParticleSystem.maxParticles = Mathf.RoundToInt(Sinerp(startSparkParticles, fd.SparkMaxParticles, t)); color = flameParticleSystem.startColor; color.a = fd.FlameTransparency; flameParticleSystem.startColor = color; yield return(0); } }
private void SetFire(FireSize size) { switch (size) { case FireSize.Big: { FireImage.texture = Big; IsOnFire = true; break; } case FireSize.Medium: { FireImage.texture = Medium; IsOnFire = true; break; } case FireSize.Small: { FireImage.texture = Small; IsOnFire = true; break; } case FireSize.None: { FireImage.texture = null; IsOnFire = false; WhackAFireMinigame.FireExtinguished(); break; } } Col.enabled = IsOnFire; FireImage.color = IsOnFire ? Color.white : Transparent; Size = size; }
// Use this for initialization private void Awake() { gameManager = FindObjectOfType <FireGameManager>(); fireFade = gameObject.GetComponent <FireFade>(); fireSize = gameObject.GetComponent <FireSize>(); }
public void ChangeFire(FireSize size) { currentFireSize = size; StartCoroutine(TransitionFire(size, false)); }