// Use this for initialization void Start() { opacity = 0.0f; image = this.GetComponent <Image> (); state = FlameState.idle; image.color = new Color(1, 1, 1, opacity); }
public void Activate() { flamePivot.SetActive(true); shineGO.SetActive(true); glowGO.SetActive(true); flame.gameObject.SetActive(true); state = FlameState.LIGHT_DOWN; }
void Awake() { currTemperatureOrBurnTime = 0; flameState = FlameState.NONE; lastCheck_S = 0; lastTemp = 0; fireSim = Terrain.activeTerrain.GetComponent <FireSimulation>(); fireCache = new List <IFlamable>(); pos = new Vector2(transform.position.x, transform.position.z); fireSim.AddTree(this); enabled = false; }
IEnumerator Simulate() { while (true) { if (!enabled) { yield return(null); continue; } for (int i = 0; i < activeFire.Count; i++) { IFlamable fire = activeFire[i]; List <IFlamable> fireCache = fire.GetCacheList(); if (fireCache.Count == 0) { continue; } Vector2 position = fire.GetPosition(); ArrangeRect(ref fireRect, ref position, ref windVector); bool atLeastOneHeating = false; for (int j = 0; j < fireCache.Count; j++) { IFlamable flammable = fireCache[j]; FlameState flameState = flammable.GetFlameState(); //keep out invalid if (flammable == null || flameState == FlameState.BURNED_OUT || flameState == FlameState.BURNING) { continue; } atLeastOneHeating = true; if (flammable.GetFlameState() != FlameState.HEATING) { flammable.SetFlameState(FlameState.HEATING); } flammable.AddTemperature(Random.value + 0.5f); } if (!atLeastOneHeating) { fireCache.Clear(); } } yield return(null); } }
// Update is called once per frame void Update() { if (state == FlameState.idle) { } if (state == FlameState.lightingUp) { opacity += opacitySpeed * Time.deltaTime; if (opacity > 1.0f) { opacity = 1.0f; state = FlameState.litUp; } image.color = new Color(1, 1, 1, opacity); } if (state == FlameState.litUp) { } }
public void SetFlameState(FlameState state) { if (state == flameState) { return; } switch (state) { case FlameState.NONE: ResetFire(); break; case FlameState.HEATING: SetHeating(); break; case FlameState.BURNED_OUT: SetBurnedOut(); break; case FlameState.BURNING: SetBurning(); fireSim.AddFire(this); break; case FlameState.COOLING: SetCooling(); break; default: break; } if (flameState == FlameState.BURNING && state != FlameState.BURNING) { fireSim.RemoveFire(this); } flameState = state; }
public void SetFlameState(FlameState state) { throw new System.NotImplementedException(); }
public void lightUp() { state = FlameState.lightingUp; }