public override void Update(DrawerController drawer) { //调整位置和粒子的颜色 position.y += bouyancy * Time.deltaTime; //判断粒子当前的“年龄”,毕竟各个阶段的火焰颜色不同嘛 float t = (Time.time - startTime) / lifeTime; //根据他的年龄,给他上色 color = Color.Lerp(MakeFireInInspector.instance.fireStartColor, MakeFireInInspector.instance.fireEndColor, t); if (t > 1) { DieClear(); //大限已到,节哀 } //时不时生一个活的火焰 if (UnityEngine.Random.Range(0, 100) < 10) { pos.Set(x, y - 1); drawer.CreateLivePixel <Fire>(pos, brush).startTime = startTime - .3f; } //如果碰到了木头,那就把他烧成灰烬人(生点余烬粒子),还有足够时间的着火才有几率点燃噢 Color c = drawer.GetPixel(x, y, false); if (MakeFireInInspector.instance.IsFlammable(c) && UnityEngine.Random.Range(0, 100) < 2) { pos.Set(x, y); drawer.CreateLivePixel <Ember>(pos, attach); } //如果碰到雪了。。 if (c.IsGrayscale()) { drawer.SetPixel(x, y, Color.clear); } //碰到雨了 if (c.IsBluescale()) { drawer.SetPixel(x, y, Color.clear); } }
float dieTime; //啥时候死掉 public override void Start(DrawerController drawer) { //初始化 dieTime = Time.time + UnityEngine.Random.Range(.1f, 2f); color.r = 1f; color.g = UnityEngine.Random.Range(0f, .5f); color.b = 0; drawer.SetPixel(x, y, Color.black); nextFireTime = Time.time + UnityEngine.Random.Range(0, .4f); }
public override void Update(DrawerController drawer) { //已经到了下次着火时间 if (Time.time > nextFireTime) { Fire.CreateFlameAt(drawer, position + UnityEngine.Random.insideUnitCircle * 2f); nextFireTime += .4f; } //大限已到 if (Time.time > dieTime) { drawer.SetPixel(x, y, Color.clear); //木头已经被成灰烬人了。。 DieClear(); } }