Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        float angle = transform.rotation.eulerAngles.x;

        angle                = Mathf.Sin(angle * Mathf.PI / 180);
        currentTemp          = Mathf.Lerp(sunriseTemp, noonTemp, angle);
        lightComponent.color = ColorTemperature.Color(currentTemp);
    }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (Quaternion.Angle(prevAngle, transform.rotation) > angleThreshold)
     {
         prevAngle = transform.rotation;
         float angle = transform.rotation.eulerAngles.x;
         angle                = Mathf.Sin(angle * Mathf.PI / 180);
         currentTemp          = Mathf.Lerp(sunriseTemp, noonTemp, angle);
         lightComponent.color = ColorTemperature.Color(currentTemp);
         DynamicGI.UpdateEnvironment();
     }
 }
Beispiel #3
0
    IEnumerator DrawParticles()
    {
        while (true)
        {
            foreach (var item in flowTypes)
            {
                if (!flowParticles.ContainsKey(item.Key))
                {
                    var child = transform.Find(item.Key.ToString());
                    if (child == null)
                    {
                        if (!warningGiven.Contains(item.Key))
                        {
                            Debug.LogError("No particle system for " + item.Key);
                            warningGiven.Add(item.Key);
                        }
                        continue;
                    }
                    var particle = child.GetComponent <ParticleSystem>();
                    if (particle == null)
                    {
                        if (!warningGiven.Contains(item.Key))
                        {
                            Debug.LogError("Malformed particle system for " + item.Key);
                            warningGiven.Add(item.Key);
                        }
                        continue;
                    }
                    flowParticles[item.Key] = particle;
                }
                foreach (var particle in item.Value)
                {
                    if (!GameMap.IsInVisibleArea(particle.pos))
                    {
                        continue;
                    }
                    var emitParams = new ParticleSystem.EmitParams();
                    emitParams.position = GameMap.DFtoUnityTileCenter(particle.pos);
                    Color color = Color.white;
                    switch (item.Key)
                    {
                    case FlowType.Dragonfire:
                        color = ColorTemperature.Color(Mathf.Lerp(dragonColorTempMin, dragonColorTempMax, particle.density / 100.0f));
                        break;

                    case FlowType.Miasma:
                    case FlowType.Steam:
                    case FlowType.Mist:
                    case FlowType.Smoke:
                    case FlowType.MagmaMist:
                    case FlowType.CampFire:
                    case FlowType.Fire:
                    case FlowType.OceanWave:
                    case FlowType.SeaFoam:
                        color = Color.white;
                        break;

                    case FlowType.ItemCloud:
                        color = ContentLoader.GetColor(particle.item, particle.material);
                        flowParticles[item.Key].customData.SetVector(ParticleSystemCustomData.Custom1, 0, new ParticleSystem.MinMaxCurve(ImageManager.Instance.GetItemTile(particle.item)));
                        flowParticles[item.Key].customData.SetVector(ParticleSystemCustomData.Custom1, 1, new ParticleSystem.MinMaxCurve(ContentLoader.GetPatternIndex(particle.material)));
                        break;

                    case FlowType.MaterialGas:
                    case FlowType.MaterialVapor:
                    case FlowType.MaterialDust:
                    case FlowType.Web:
                    default:
                        color = ContentLoader.GetColor(particle.material);
                        break;
                    }
                    if (item.Key == FlowType.ItemCloud)
                    {
                        if (UnityEngine.Random.Range(0, 100) > particle.density)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        color.a = particle.density / 100f;
                    }
                    emitParams.startColor           = color;
                    emitParams.applyShapeToPosition = true;
                    flowParticles[item.Key].Emit(emitParams, 1);
                }
            }
            yield return(new WaitForSeconds(updateRate));
        }
    }