Exemple #1
0
        public void ApplyEnvironmentPresetIsApplied(int presetRowIndex)
        {
            EnvironmentPreset preset = NwGameTables.EnvironmentPresetTable.GetRow(presetRowIndex);

            NwArea area = NwModule.Instance.StartingLocation.Area !;

            area.ApplyEnvironmentPreset(preset);

            Assert.That(area.DayNightMode, Is.EqualTo(preset.DayNightMode));
            Assert.That(area.SunAmbientColor, Is.EqualTo(preset.SunAmbientColor));
            Assert.That(area.SunDiffuseColor, Is.EqualTo(preset.SunDiffuseColor));
            Assert.That(area.SunFogColor, Is.EqualTo(preset.SunFogColor));
            Assert.That(area.SunFogAmount, Is.EqualTo(preset.SunFogAmount));
            Assert.That(area.SunShadows, Is.EqualTo(preset.SunShadows));
            Assert.That(area.MoonAmbientColor, Is.EqualTo(preset.MoonAmbientColor));
            Assert.That(area.MoonDiffuseColor, Is.EqualTo(preset.MoonDiffuseColor));
            Assert.That(area.MoonFogColor, Is.EqualTo(preset.MoonFogColor));
            Assert.That(area.MoonFogAmount, Is.EqualTo(preset.MoonFogAmount));
            Assert.That(area.MoonShadows, Is.EqualTo(preset.MoonShadows));
            Assert.That(area.WindPower, Is.EqualTo(preset.WindPower));
            Assert.That(area.SnowChance, Is.EqualTo(preset.SnowChance));
            Assert.That(area.RainChance, Is.EqualTo(preset.RainChance));
            Assert.That(area.LightningChance, Is.EqualTo(preset.LightningChance));
            Assert.That(area.FogClipDistance, Is.EqualTo(preset.FogClipDistance));
            Assert.That(area.ShadowOpacity, Is.EqualTo(preset.ShadowAlpha * 10));
        }
 public static Environment GetLerpedEnvironment(EnvironmentPreset a, EnvironmentPreset b, float val)
 {
     if (a == EnvironmentPreset.Custom)
     {
         if (b == EnvironmentPreset.Custom)
         {
             return(defaultEnvironment);
         }
         else
         {
             return(GetEnvironment(b));
         }
     }
     else
     {
         if (b == EnvironmentPreset.Custom)
         {
             return(GetEnvironment(a));
         }
         else
         {
             return(GetEnvironment(a).Lerp(b, val));
         }
     }
 }
    public static Environment Load(System.IO.Stream fs)
    {
        EnvironmentPreset ep = (EnvironmentPreset)fs.ReadByte();

        if (ep != EnvironmentPreset.Custom)
        {
            return(GetEnvironment(ep));
        }
        else
        {
            return(new Environment(fs));
        }
    }
 public static Environment GetEnvironment(EnvironmentPreset ep)
 {
     if (presets.ContainsKey(ep))
     {
         return(presets[ep]);
     }
     else
     {
         var e = new Environment(ep);
         presets.Add(ep, e);
         return(e);
     }
 }
Exemple #5
0
        public void EnvironmentTableReturnsValidData(int rowIndex, string label, uint strRef, DayNightMode dayNight, byte lightAmbRed,
                                                     byte lightAmbGreen, byte lightAmbBlue, byte lightDiffRed, byte lightDiffGreen, byte lightDiffBlue, bool lightShadows,
                                                     byte darkAmbRed, byte darkAmbGreen, byte darkAmbBlue, byte darkDiffRed, byte darkDiffGreen, byte darkDiffBlue, bool darkShadows,
                                                     byte lightFogRed, byte lightFogGreen, byte lightFogBlue, byte darkFogRed, byte darkFogGreen, byte darkFogBlue, byte lightFog, byte darkFog,
                                                     int main1Color1, int main1Color2, int main1Color3, int main1Color4, int main2Color1, int main2Color2, int main2Color3, int main2Color4,
                                                     int secondaryColor1, int secondaryColor2, int secondaryColor3, int secondaryColor4, byte wind, byte snow, byte rain, byte lightning, float shadowAlpha)
        {
            TwoDimArray <EnvironmentPreset> table = NwGameTables.EnvironmentPresetTable;
            EnvironmentPreset row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.StrRef, Is.EqualTo(new StrRef(strRef)));
            Assert.That(row.DayNightMode, Is.EqualTo(dayNight));
            Assert.That(row.SunAmbientColor, Is.EqualTo(new Color(lightAmbRed, lightAmbGreen, lightAmbBlue)));
            Assert.That(row.SunDiffuseColor, Is.EqualTo(new Color(lightDiffRed, lightDiffGreen, lightDiffBlue)));
            Assert.That(row.SunShadows, Is.EqualTo(lightShadows));
            Assert.That(row.MoonAmbientColor, Is.EqualTo(new Color(darkAmbRed, darkAmbGreen, darkAmbBlue)));
            Assert.That(row.MoonDiffuseColor, Is.EqualTo(new Color(darkDiffRed, darkDiffGreen, darkDiffBlue)));
            Assert.That(row.MoonShadows, Is.EqualTo(darkShadows));
            Assert.That(row.SunFogColor, Is.EqualTo(new Color(lightFogRed, lightFogGreen, lightFogBlue)));
            Assert.That(row.MoonFogColor, Is.EqualTo(new Color(darkFogRed, darkFogGreen, darkFogBlue)));
            Assert.That(row.SunFogAmount, Is.EqualTo(lightFog));
            Assert.That(row.MoonFogAmount, Is.EqualTo(darkFog));
            Assert.That(row.Main1Color1, Is.EqualTo(main1Color1));
            Assert.That(row.Main1Color2, Is.EqualTo(main1Color2));
            Assert.That(row.Main1Color3, Is.EqualTo(main1Color3));
            Assert.That(row.Main1Color4, Is.EqualTo(main1Color4));
            Assert.That(row.Main2Color1, Is.EqualTo(main2Color1));
            Assert.That(row.Main2Color2, Is.EqualTo(main2Color2));
            Assert.That(row.Main2Color3, Is.EqualTo(main2Color3));
            Assert.That(row.Main2Color4, Is.EqualTo(main2Color4));
            Assert.That(row.SecondaryColor1, Is.EqualTo(secondaryColor1));
            Assert.That(row.SecondaryColor2, Is.EqualTo(secondaryColor2));
            Assert.That(row.SecondaryColor3, Is.EqualTo(secondaryColor3));
            Assert.That(row.SecondaryColor4, Is.EqualTo(secondaryColor4));
            Assert.That(row.WindPower, Is.EqualTo(wind));
            Assert.That(row.SnowChance, Is.EqualTo(snow));
            Assert.That(row.RainChance, Is.EqualTo(rain));
            Assert.That(row.LightningChance, Is.EqualTo(lightning));
            Assert.That(row.ShadowAlpha, Is.EqualTo(shadowAlpha));
        }
Exemple #6
0
 public static Environment GetEnvironment(EnvironmentPreset ep)
 {
     if (elist != null)
     {
         if (elist.ContainsKey(ep))
         {
             return(elist[ep]);
         }
         else
         {
             var e = new Environment(ep);
             elist.Add(ep, e);
             return(e);
         }
     }
     else
     {
         var e = new Environment(ep);
         elist = new Dictionary <EnvironmentPreset, Environment>();
         elist.Add(ep, e);
         return(e);
     }
 }
    public Environment Lerp(EnvironmentPreset target, float val)
    {
        if (target == EnvironmentPreset.Custom)
        {
            return(this);
        }
        else
        {
            if (presetType != EnvironmentPreset.Custom)
            {
                return(this.GetCustomCopy().Lerp(target, val));
            }
            else
            {
                var t = GetEnvironment(target);
                conditions       = Mathf.Lerp(conditions, t.conditions, val);
                richness         = Mathf.Lerp(richness, t.richness, val);
                lifepowerSupport = Mathf.MoveTowards(lifepowerSupport, t.lifepowerSupport, val);
                stability        = Mathf.MoveTowards(stability, t.stability, val);

                return(this);
            }
        }
    }
Exemple #8
0
    private Environment(EnvironmentPreset ep)
    {
        presetType = ep;
        switch (ep)
        {
        case EnvironmentPreset.Desert:
            conditions               = 0.3f;
            lifepowerSupport         = 0.1f;
            lightIntensityMultiplier = 1.1f;
            stability    = 0.4f;
            skyColor     = new Color(1f, 0.74f, 0.65f);
            bottomColor  = new Color(1f, 0.95f, 0.74f);
            horizonColor = Color.white;
            break;

        case EnvironmentPreset.WhiteSpace:
            conditions               = 1f;
            lifepowerSupport         = 0.01f;
            lightIntensityMultiplier = 1.5f;
            stability    = 0f;
            skyColor     = Color.white;
            bottomColor  = skyColor;
            horizonColor = skyColor;
            break;

        case EnvironmentPreset.Pipe:
            conditions               = DEFAULT_CONDITIONS;
            lifepowerSupport         = DEFAULT_LP_SUPPORT / 2f;
            stability                = 0.98f;
            lightIntensityMultiplier = 0.25f;
            skyColor     = new Color(0.58f, 1f, 0.75f);
            bottomColor  = new Color(0f, 0.65f, 0.4f);
            horizonColor = new Color(0.22f, 0.46f, 0.29f);
            break;

        case EnvironmentPreset.Ice:
            conditions               = 0.25f;
            lifepowerSupport         = 0.2f;
            stability                = 0.55f;
            lightIntensityMultiplier = 0.7f;
            skyColor     = new Color(0.588f, 0.853f, 0.952f);
            bottomColor  = Color.blue;
            horizonColor = Color.white;
            break;

        case EnvironmentPreset.Pollen:
            conditions               = 0.4f;
            lifepowerSupport         = 0.6f;
            stability                = 0.3f;
            lightIntensityMultiplier = 0.8f;
            skyColor     = new Color(1f, 0.99f, 0.86f);
            bottomColor  = new Color(0.58f, 0.58f, 0.52f);
            horizonColor = new Color(0.96f, 0.79f, 0.4f);
            break;

        case EnvironmentPreset.Forest:
            conditions               = 0.89f;
            lifepowerSupport         = 0.8f;
            stability                = DEFAULT_STABILITY;
            lightIntensityMultiplier = 1f;
            skyColor     = new Color(1f, 0.96f, 0.74f);
            bottomColor  = new Color(0.57f, 0.84f, 0.57f);
            horizonColor = new Color(0.07f, 0.43f, 0.07f);
            break;

        case EnvironmentPreset.Ruins:
            conditions               = 0.4f;
            lifepowerSupport         = 0.3f;
            stability                = 0.6f;
            lightIntensityMultiplier = 0.9f;
            skyColor     = new Color(0.6f, 0.6f, 0.2f);
            bottomColor  = new Color(0.82f, 0.83f, 0.17f);
            horizonColor = new Color(0.25f, 0.25f, 0.15f);
            break;

        case EnvironmentPreset.Crystal:
            conditions               = 0.5f;
            lifepowerSupport         = 0.1f;
            stability                = 0.85f;
            lightIntensityMultiplier = 0.85f;
            skyColor     = new Color(0.27f, 0.83f, 0.85f);
            bottomColor  = new Color(0.73f, 0.83f, 0.83f);
            horizonColor = new Color(0.04f, 0.91f, 0.95f);
            break;

        case EnvironmentPreset.Meadows:
            conditions               = DEFAULT_CONDITIONS * 1.1f;
            lifepowerSupport         = DEFAULT_LP_SUPPORT * 1.2f;
            stability                = DEFAULT_STABILITY;
            lightIntensityMultiplier = 1f;
            skyColor     = new Color(1f, 0.94f, 0.71f);
            bottomColor  = new Color(0.88f, 0.82f, 0.54f);
            horizonColor = new Color(2f, 0.84f, 0f);
            break;

        case EnvironmentPreset.Space:
            conditions               = 0f;
            lifepowerSupport         = 0f;
            stability                = 0.1f;
            lightIntensityMultiplier = 1f;
            skyColor     = Color.white;
            bottomColor  = Color.black;
            horizonColor = Color.cyan * 0.25f;
            break;

        case EnvironmentPreset.Fire:
            conditions               = 0.2f;
            lifepowerSupport         = 0.1f;
            stability                = 0.33f;
            lightIntensityMultiplier = 1.1f;
            skyColor     = new Color(0.93f, 0.26f, 0.11f);
            bottomColor  = new Color(0.31f, 0.07f, 0.05f);
            horizonColor = Color.yellow;
            break;

        case EnvironmentPreset.Ocean:
            conditions               = DEFAULT_CONDITIONS * 0.9f;
            lifepowerSupport         = DEFAULT_LP_SUPPORT * 0.75f;
            stability                = 0.8f;
            lightIntensityMultiplier = 0.5f;
            skyColor     = new Color(0.61f, 0.99f, 0.94f);
            bottomColor  = new Color(0f, 0.62f, 1f);
            horizonColor = new Color(0f, 0f, 0.65f);
            break;

        default:
            presetType               = EnvironmentPreset.Default;
            conditions               = DEFAULT_CONDITIONS;
            lifepowerSupport         = DEFAULT_LP_SUPPORT;
            stability                = DEFAULT_STABILITY;
            lightIntensityMultiplier = 1f;
            bottomColor              = Color.white;
            skyColor     = Color.white;
            horizonColor = Color.cyan * 0.5f;
            break;
        }
    }
    private Environment(EnvironmentPreset ep)
    {
        presetType = ep;
        switch (ep)
        {
        case EnvironmentPreset.Desert:
            conditions       = 0.3f;
            lifepowerSupport = 0.1f;
            stability        = 0.4f;
            lightSettings    = new SceneAmbientSettings(new Color(1f, 0.74f, 0.65f), Color.white, new Color(1f, 0.95f, 0.74f), 1.1f);
            break;

        case EnvironmentPreset.WhiteSpace:
            conditions       = 1f;
            lifepowerSupport = 0.01f;
            stability        = 0f;
            var wc = Color.white;
            lightSettings = new SceneAmbientSettings(wc, wc, wc, 1.5f);
            break;

        case EnvironmentPreset.Pipe:
            conditions       = DEFAULT_CONDITIONS;
            lifepowerSupport = DEFAULT_LP_SUPPORT / 2f;
            stability        = 0.98f;
            lightSettings    = new SceneAmbientSettings(
                new Color(0.58f, 1f, 0.75f),
                new Color(0.22f, 0.46f, 0.29f),
                new Color(0f, 0.65f, 0.4f),
                0.25f);
            break;

        case EnvironmentPreset.Ice:
            conditions       = 0.25f;
            lifepowerSupport = 0.2f;
            stability        = 0.55f;
            lightSettings    = new SceneAmbientSettings(
                new Color(0.588f, 0.853f, 0.952f),
                Color.white,
                Color.blue,
                0.7f);
            break;

        case EnvironmentPreset.Pollen:
            conditions       = 0.4f;
            lifepowerSupport = 0.6f;
            stability        = 0.3f;
            lightSettings    = new SceneAmbientSettings(
                new Color(1f, 0.99f, 0.86f),
                new Color(0.96f, 0.79f, 0.4f),
                new Color(0.58f, 0.58f, 0.52f),
                0.8f);
            break;

        case EnvironmentPreset.Forest:
            conditions       = 0.89f;
            lifepowerSupport = 0.8f;
            stability        = DEFAULT_STABILITY;
            lightSettings    = new SceneAmbientSettings(
                new Color(1f, 0.96f, 0.74f),
                new Color(0.07f, 0.43f, 0.07f),
                new Color(0.57f, 0.84f, 0.57f),
                1f);
            break;

        case EnvironmentPreset.Ruins:
            conditions       = 0.4f;
            lifepowerSupport = 0.3f;
            stability        = 0.6f;
            lightSettings    = new SceneAmbientSettings(
                new Color(0.6f, 0.6f, 0.2f),
                new Color(0.25f, 0.25f, 0.15f),
                new Color(0.82f, 0.83f, 0.17f),
                0.9f);
            break;

        case EnvironmentPreset.Crystal:
            conditions       = 0.5f;
            lifepowerSupport = 0.1f;
            stability        = 0.85f;
            lightSettings    = new SceneAmbientSettings(
                new Color(0.27f, 0.83f, 0.85f),
                new Color(0.04f, 0.91f, 0.95f),
                new Color(0.73f, 0.83f, 0.83f),
                0.85f);
            break;

        case EnvironmentPreset.Meadows:
            conditions       = DEFAULT_CONDITIONS * 1.1f;
            lifepowerSupport = DEFAULT_LP_SUPPORT * 1.2f;
            stability        = DEFAULT_STABILITY;
            lightSettings    = new SceneAmbientSettings(
                new Color(1f, 0.94f, 0.71f),
                new Color(2f, 0.84f, 0f),
                new Color(0.88f, 0.82f, 0.54f),
                1f);
            break;

        case EnvironmentPreset.Space:
            conditions       = 0f;
            lifepowerSupport = 0f;
            stability        = 0.1f;
            lightSettings    = new SceneAmbientSettings(
                Color.white,
                Color.cyan * 0.25f,
                Color.black,
                1f);
            break;

        case EnvironmentPreset.Fire:
            conditions       = 0.2f;
            lifepowerSupport = 0.1f;
            stability        = 0.33f;
            lightSettings    = new SceneAmbientSettings(
                new Color(0.93f, 0.26f, 0.11f),
                Color.yellow,
                new Color(0.31f, 0.07f, 0.05f),
                1.1f);
            break;

        case EnvironmentPreset.Ocean:
            conditions       = DEFAULT_CONDITIONS * 0.9f;
            lifepowerSupport = DEFAULT_LP_SUPPORT * 0.75f;
            stability        = 0.8f;
            lightSettings    = new SceneAmbientSettings(
                new Color(0.61f, 0.99f, 0.94f),
                new Color(0.61f, 0.99f, 0.94f),
                new Color(0f, 0f, 0.65f),
                0.5f);
            break;

        case EnvironmentPreset.FoundationSkies:
            presetType       = EnvironmentPreset.FoundationSkies;
            conditions       = DEFAULT_CONDITIONS * 1.1f;
            lifepowerSupport = DEFAULT_LP_SUPPORT;
            stability        = 1f;
            lightSettings    = new SceneAmbientSettings(
                new Color(0.1647059f, 0.6964906f, 1f),
                new Color(0.631052f, 0.7755874f, 0.8207547f),
                new Color(0.7224546f, 0.7693326f, 0.8018868f),
                1f);
            lightSettings.SetAdditionalValues(
                1f, 1f, 1f, 1f, 0f
                );
            break;

        default:
            presetType       = EnvironmentPreset.Default;
            conditions       = DEFAULT_CONDITIONS;
            lifepowerSupport = DEFAULT_LP_SUPPORT;
            stability        = DEFAULT_STABILITY;
            lightSettings    = new SceneAmbientSettings(
                Color.black,
                Color.cyan * 0.75f,
                Color.white,
                0.72f);   // на планшетах смотрится тусклее
            break;
        }
    }