Пример #1
0
 void Update()
 {
     // Update weather if context changes
     if (WeatherType != _currentWeatherType ||
         playerEnterExit.IsPlayerInside != isInside ||
         PlayerGps.ClimateSettings.ClimateType != currentClimateType)
     {
         isInside            = playerEnterExit.IsPlayerInside;
         currentClimateType  = PlayerGps.ClimateSettings.ClimateType;
         _currentWeatherType = WeatherType;
         SetWeather();
     }
 }
Пример #2
0
        private void ApplyMaterials(bool force, int[] dungeonTextureTable = null)
        {
            if (Materials == null || Materials.Length == 0)
            {
                return;
            }

            try
            {
                var meshRenderer = GetComponent <MeshRenderer>();
                if (!meshRenderer)
                {
                    Debug.LogErrorFormat("Failed to find MeshRenderer on {0}.", name);
                    return;
                }

                DFLocation.ClimateBaseType climateBaseType = GameManager.Instance.PlayerGPS.ClimateSettings.ClimateType;
                ClimateBases  climate = ClimateSwaps.FromAPIClimateBase(climateBaseType);
                ClimateSeason season  = DaggerfallUnity.Instance.WorldTime.Now.SeasonValue == DaggerfallDateTime.Seasons.Winter ? ClimateSeason.Winter : ClimateSeason.Summer;

                Material[] materials = meshRenderer.sharedMaterials;
                for (int i = 0; i < Materials.Length; i++)
                {
                    int index = Materials[i].Index;

                    if (!force && materials[index])
                    {
                        Debug.LogWarningFormat("A runtime material is being assigned to {0} (index {1}) but current material is not equal to null." +
                                               " Make sure you are not including unnecessary auto-generated materials.", meshRenderer.name, i);
                    }

                    materials[index] = GetMaterial(Materials[i], climateBaseType, climate, season, dungeonTextureTable);
                    if (!materials[index])
                    {
                        Debug.LogErrorFormat("Failed to find material for {0} (index {1}).", meshRenderer.name, i);
                    }
                }
                meshRenderer.sharedMaterials = materials;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            finally
            {
                hasAppliedMaterials = true;
            }
        }
Пример #3
0
        private Material GetMaterial(RuntimeMaterial runtimeMaterial, DFLocation.ClimateBaseType climateBaseType, ClimateBases climate, ClimateSeason season, int[] dungeonTextureTable)
        {
            int archive = runtimeMaterial.Archive;
            int record  = runtimeMaterial.Record;

            if (dungeonTextureTable != null)
            {
                archive = DungeonTextureTables.ApplyTextureTable(archive, dungeonTextureTable, climateBaseType);
            }
            else if (runtimeMaterial.ApplyClimate)
            {
                archive = ClimateSwaps.ApplyClimate(archive, record, climate, season);
            }

            return(DaggerfallUnity.Instance.MaterialReader.GetMaterial(archive, record));
        }
        /// <summary>
        /// Gets filename of texture archive for climate texture set.
        /// </summary>
        /// <param name="Climate">Climate type.</param>
        /// <param name="Set">Texture set type.</param>
        /// <param name="Weather">Weather type.</param>
        /// <returns>Filename of texture archive.</returns>
        static public string GetClimateTextureFileName(DFLocation.ClimateBaseType Climate, DFLocation.ClimateTextureSet Set, DFLocation.ClimateWeather Weather)
        {
            // Get base
            int index = (int)Climate;

            // Adjust for set
            index += (int)Set;

            // TODO: Enforce weather constraints against ClimateSet

            // Adjust for weather
            index += (int)Weather;

            // Return filename
            return(string.Format("TEXTURE.{0:000}", index));
        }
Пример #5
0
        /// <summary>
        /// Convert API climate base over to DaggerfallUnity equivalent.
        /// </summary>
        /// <param name="climate">DFLocation.ClimateBaseType.</param>
        /// <returns>ClimateBases.</returns>
        public static ClimateBases FromAPIClimateBase(DFLocation.ClimateBaseType climate)
        {
            switch (climate)
            {
            case DFLocation.ClimateBaseType.Desert:
                return(ClimateBases.Desert);

            case DFLocation.ClimateBaseType.Mountain:
                return(ClimateBases.Mountain);

            case DFLocation.ClimateBaseType.Temperate:
                return(ClimateBases.Temperate);

            case DFLocation.ClimateBaseType.Swamp:
                return(ClimateBases.Swamp);

            default:
                return(ClimateBases.Temperate);
            }
        }
 void Update()
 {
     // Update weather if context changes
     if (WeatherType != currentWeatherType ||
         playerEnterExit.IsPlayerInside != isInside ||
         playerGPS.ClimateSettings.ClimateType != currentClimateType)
     {
         isInside = playerEnterExit.IsPlayerInside;
         currentClimateType = playerGPS.ClimateSettings.ClimateType;
         currentWeatherType = WeatherType;
         SetWeather();
     }
 }