/// <summary> /// Computes the next weather based on the chances for the given climate and season. /// </summary> /// <param name="climate">Climate index from PlayerGPS</param> /// <param name="season">Current season</param> /// <returns>Next random weather</returns> public WeatherType GetWeather(int climate, DaggerfallDateTime.Seasons season) { var mapClimate = (MapsFile.Climates)climate; switch (mapClimate) { case MapsFile.Climates.Desert: case MapsFile.Climates.Desert2: return(Desert.GetWeather(season)); case MapsFile.Climates.Mountain: case MapsFile.Climates.MountainWoods: return(Mountains.GetWeather(season)); case MapsFile.Climates.Rainforest: return(Jungle.GetWeather(season)); case MapsFile.Climates.Ocean: case MapsFile.Climates.Swamp: return(Swamp.GetWeather(season)); case MapsFile.Climates.Subtropical: return(Subtropical.GetWeather(season)); case MapsFile.Climates.Woodlands: case MapsFile.Climates.HauntedWoodlands: return(Woodlands.GetWeather(season)); } Debug.LogWarning("Unknown climate! " + climate); return(WeatherType.Sunny); }
public override void RestoreSaveData(object dataIn) { if (dataIn == null) { return; } SaveData_v1 data = (SaveData_v1)dataIn; season = data.season; }
/// <summary> /// Adds +75 to maximum spell points when certain conditions are met. /// </summary> void ExtraSpellPoints(DaggerfallEnchantment enchantment) { const int maxIncrease = 75; bool apply = false; ExtraSpellPtTypes type = (ExtraSpellPtTypes)enchantment.param; // Seasonal params are 0-3 if (enchantment.param < 4) { DaggerfallDateTime.Seasons currentSeason = DaggerfallUnity.Instance.WorldTime.Now.SeasonValue; if (type == ExtraSpellPtTypes.DuringWinter && currentSeason == DaggerfallDateTime.Seasons.Winter || type == ExtraSpellPtTypes.DuringSpring && currentSeason == DaggerfallDateTime.Seasons.Spring || type == ExtraSpellPtTypes.DuringSummer && currentSeason == DaggerfallDateTime.Seasons.Summer || type == ExtraSpellPtTypes.DuringFall && currentSeason == DaggerfallDateTime.Seasons.Fall) { apply = true; } } // Moon params are 4-6 if (enchantment.param >= 4 && enchantment.param <= 6) { if (type == ExtraSpellPtTypes.DuringFullMoon && IsFullMoon() || type == ExtraSpellPtTypes.DuringHalfMoon && IsHalfMoon() || type == ExtraSpellPtTypes.DuringNewMoon && IsNewMoon()) { apply = true; } } // Nearby params are 7-10) // Core tracks nearby objects at low frequencies and nearby lookup is only checking a managed list using Linq if (enchantment.param > 6) { if (type == ExtraSpellPtTypes.NearUndead && IsNearUndead() || type == ExtraSpellPtTypes.NearDaedra && IsNearDaedra() || type == ExtraSpellPtTypes.NearHumanoids && IsNearHumanoids() || type == ExtraSpellPtTypes.NearAnimals && IsNearAnimals()) { apply = true; } } // Apply extra spell points when conditions are met if (apply) { entityBehaviour.Entity.ChangeMaxMagickaModifier(maxIncrease); } }
public WeatherType GetWeather(DaggerfallDateTime.Seasons season) { switch (season) { case DaggerfallDateTime.Seasons.Fall: return(Fall.GetWeather()); case DaggerfallDateTime.Seasons.Spring: return(Spring.GetWeather()); case DaggerfallDateTime.Seasons.Summer: return(Summer.GetWeather()); case DaggerfallDateTime.Seasons.Winter: return(Winter.GetWeather()); } Debug.LogWarning("Unknown season! " + season); return(WeatherType.Sunny); }
void Update() { // Do nothing if not ready if (!ReadyCheck()) { return; } // Handle automated texture swaps if (dfUnity.Option_AutomateTextureSwaps) { // Only process if climate, season, day/night, or weather changed if (lastSeason != dfUnity.WorldTime.Now.SeasonValue || lastCityLightsFlag != dfUnity.WorldTime.Now.IsCityLightsOn) { ApplyTimeAndSpace(); lastSeason = dfUnity.WorldTime.Now.SeasonValue; lastCityLightsFlag = dfUnity.WorldTime.Now.IsCityLightsOn; } } }
public static int GetNatureArchive(DFLocation.ClimateTextureSet climateTextureSet, DaggerfallDateTime.Seasons worldSeason) { ClimateNatureSets natureSet = FromAPITextureSet(climateTextureSet); ClimateSeason climateSeason = ClimateSeason.Summer; if (worldSeason == DaggerfallDateTime.Seasons.Winter) { climateSeason = ClimateSeason.Winter; } return(GetNatureArchive(natureSet, climateSeason)); }
/// <summary> /// Adds +75 to maximum spell points when certain conditions are met. /// </summary> public override void ConstantEffect() { base.ConstantEffect(); const int maxIncrease = 75; // Must have a param if (EnchantmentParam == null) { return; } // Get peered entity gameobject DaggerfallEntityBehaviour entityBehaviour = GetPeeredEntityBehaviour(manager); if (!entityBehaviour) { return; } // Seasonal params are 0-3 bool apply = false; Params type = (Params)EnchantmentParam.Value.ClassicParam; if (EnchantmentParam.Value.ClassicParam < 4) { DaggerfallDateTime.Seasons currentSeason = DaggerfallUnity.Instance.WorldTime.Now.SeasonValue; if (type == Params.DuringWinter && currentSeason == DaggerfallDateTime.Seasons.Winter || type == Params.DuringSpring && currentSeason == DaggerfallDateTime.Seasons.Spring || type == Params.DuringSummer && currentSeason == DaggerfallDateTime.Seasons.Summer || type == Params.DuringFall && currentSeason == DaggerfallDateTime.Seasons.Fall) { apply = true; } } // Moon params are 4-6 if (EnchantmentParam.Value.ClassicParam >= 4 && EnchantmentParam.Value.ClassicParam <= 6) { if (type == Params.DuringFullMoon && IsFullMoon() || type == Params.DuringHalfMoon && IsHalfMoon() || type == Params.DuringNewMoon && IsNewMoon()) { apply = true; } } // Nearby params are 7-10) // Core tracks nearby objects at low frequencies and nearby lookup is only checking a managed list using Linq if (EnchantmentParam.Value.ClassicParam > 6) { if (type == Params.NearUndead && IsNearUndead() || type == Params.NearDaedra && IsNearDaedra() || type == Params.NearHumanoids && IsNearHumanoids() || type == Params.NearAnimals && IsNearAnimals()) { apply = true; } } // Apply extra spell points when conditions are met if (apply) { entityBehaviour.Entity.ChangeMaxMagickaModifier(maxIncrease); } }
void FixedUpdate() { // Get player inside flag // Can only do this when PlayerEnterExit is available, otherwise default to true bool playerInside = (playerEnterExit == null) ? true : playerEnterExit.IsPlayerInside; // Change footstep sounds between winter/summer variants or when player enters/exits an interior space if (dfUnity.WorldTime.Now.SeasonValue != currentSeason || isInside != playerInside) { currentSeason = dfUnity.WorldTime.Now.SeasonValue; isInside = playerInside; if (currentSeason == DaggerfallDateTime.Seasons.Winter && !isInside) { currentFootstepSound = FootstepSoundSnow; } else { currentFootstepSound = FootstepSoundNormal; } clip = null; } // Reload clip if needed if (clip == null) { clip = dfAudioSource.GetAudioClip((int)currentFootstepSound); } // Check if player is grounded if (!IsGrounded()) { // Player has lost grounding distance = 0f; lostGrounding = true; return; } else { // Player is grounded but we might need to reset after losing grounding if (lostGrounding) { distance = 0f; lastPosition = GetHorizontalPosition(); lostGrounding = false; return; } } // Get distance player travelled horizontally Vector3 position = GetHorizontalPosition(); distance += Vector3.Distance(position, lastPosition); lastPosition = position; // Get threshold float threshold = WalkStepInterval; if (playerMotor) { threshold = (playerMotor.IsRunning) ? RunStepInterval : WalkStepInterval; } // Play sound if over distance threshold if (distance > threshold && customAudioSource && clip) { // Set a random pitch so footsteps don't sound too mechanical customAudioSource.pitch = Random.Range(1f - PitchVariance, 1f + PitchVariance); customAudioSource.PlayOneShot(clip, FootstepVolumeScale); distance = 0f; } }
protected virtual void Update() { if (!FootstepsEnabled()) { return; } //this condition helps prevent making a nuisance footstep noise when the player first //loads a save, or into an interior or exterior location if (GameManager.Instance.SaveLoadManager.LoadInProgress || GameManager.Instance.StreamingWorld.IsRepositioningPlayer) { ignoreLostGrounding = true; return; } DaggerfallDateTime.Seasons playerSeason = dfUnity.WorldTime.Now.SeasonValue; int climateIndex = GameManager.Instance.PlayerGPS.CurrentClimateIndex; // Get player inside flag // Can only do this when PlayerEnterExit is available, otherwise default to true bool inside = (playerEnterExit == null) ? true : playerEnterExit.IsPlayerInside; bool inBuilding = (playerEnterExit == null) ? false : playerEnterExit.IsPlayerInsideBuilding; // Play splash footsteps whether player is walking on or swimming in exterior water bool onExteriorWater = IsOnExteriorWater(); bool pnExteriorPath = IsOnExteriorPath(); bool onStaticGeometry = IsOnStaticGeometry(); // Change footstep sounds between winter/summer variants, when player enters/exits an interior space, or changes between path, water, or other outdoor ground if (playerSeason != currentSeason || climateIndex != currentClimateIndex || isInside != inside || onExteriorWater != isInOutsideWater || pnExteriorPath != isInOutsidePath || onStaticGeometry != isOnStaticGeometry) { currentSeason = playerSeason; currentClimateIndex = climateIndex; isInside = inside; isInOutsideWater = onExteriorWater; isInOutsidePath = pnExteriorPath; isOnStaticGeometry = onStaticGeometry; if (!isInside && !onStaticGeometry) { if (currentSeason == DaggerfallDateTime.Seasons.Winter && !WeatherManager.IsSnowFreeClimate(currentClimateIndex)) { currentFootstepSoundList = FootstepSoundSnow; } else { currentFootstepSoundList = FootstepSoundOutside; } } else if (inBuilding) { currentFootstepSoundList = FootstepSoundBuilding; } else // in dungeon { currentFootstepSoundList = FootstepSoundDungeon; } } // walking on water tile if (onExteriorWater) { currentFootstepSoundList = FootstepSoundSubmerged; } // walking on path tile if (pnExteriorPath) { currentFootstepSoundList = FootstepSoundDungeon; } // Use water sounds if in dungeon water if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon && playerEnterExit.blockWaterLevel != 10000) { // In water, deep depth if ((currentFootstepSoundList != FootstepSoundSubmerged) && playerEnterExit.IsPlayerSwimming) { currentFootstepSoundList = FootstepSoundSubmerged; } // In water, shallow depth else if ((currentFootstepSoundList != FootstepSoundShallow) && !playerEnterExit.IsPlayerSwimming && (transform.position.y - 0.55f) < (playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale)) { currentFootstepSoundList = FootstepSoundShallow; } } // Not in water, reset footsteps to normal if ((!onExteriorWater) && (currentFootstepSoundList == FootstepSoundSubmerged || currentFootstepSoundList == FootstepSoundShallow) && (playerEnterExit.blockWaterLevel == 10000 || (transform.position.y - 0.95f) >= (playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale))) { currentFootstepSoundList = FootstepSoundDungeon; } // Check whether player is on foot and abort playing footsteps if not. if (IsLevitating() || !transportManager.IsOnFoot && GameManager.Instance.PlayerMotor.OnExteriorWater == PlayerMotor.OnExteriorWaterMethod.None) { distance = 0f; return; } // Check if player is grounded // Note: In classic, submerged "footstep" sound is only played when walking on the floor while in the water, but it sounds like a swimming sound // and when outside is played while swimming at the water's surface, so it seems better to play it all the time while submerged in water. if (!IsSwimming()) { if (!IsGrounded()) { // Player has lost grounding distance = 0f; lostGrounding = true; return; } else { // Player is grounded but we might need to reset after losing grounding if (lostGrounding) { distance = 0f; lastPosition = GetHorizontalPosition(); lostGrounding = false; if (ignoreLostGrounding) { ignoreLostGrounding = false; } else if (customAudioSource && currentFootstepSoundList != null) { PlayFootstep(FootstepVolumeScale * DaggerfallUnity.Settings.SoundVolume); } return; } } } if (IsStandingStill()) { return; } // Get distance player travelled horizontally Vector3 position = GetHorizontalPosition(); distance += Vector3.Distance(position, lastPosition); lastPosition = position; // Get threshold float threshold = IsRunning() ? RunStepInterval : WalkStepInterval; // Play sound if over distance threshold if (distance > threshold && customAudioSource && currentFootstepSoundList != null) { float volumeScale = FootstepVolumeScale; if (IsMovingLessThanHalfSpeed()) { volumeScale *= 0.5f; } PlayFootstep(volumeScale * DaggerfallUnity.Settings.SoundVolume); distance = 0f; } }
void FixedUpdate() { // Get player inside flag // Can only do this when PlayerEnterExit is available, otherwise default to true bool playerInside = (playerEnterExit == null) ? true : playerEnterExit.IsPlayerInside; // Change footstep sounds between winter/summer variants or when player enters/exits an interior space if (dfUnity.WorldTime.Now.SeasonValue != currentSeason || isInside != playerInside) { currentSeason = dfUnity.WorldTime.Now.SeasonValue; isInside = playerInside; if (currentSeason == DaggerfallDateTime.Seasons.Winter && !isInside) currentFootstepSound = FootstepSoundSnow; else currentFootstepSound = FootstepSoundNormal; clip = null; } // Reload clip if needed if (clip == null) { clip = dfAudioSource.GetAudioClip((int)currentFootstepSound); } // Check if player is grounded if (!IsGrounded()) { // Player has lost grounding distance = 0f; lostGrounding = true; return; } else { // Player is grounded but we might need to reset after losing grounding if (lostGrounding) { distance = 0f; lastPosition = GetHorizontalPosition(); lostGrounding = false; return; } } // Get distance player travelled horizontally Vector3 position = GetHorizontalPosition(); distance += Vector3.Distance(position, lastPosition); lastPosition = position; // Get threshold float threshold = WalkStepInterval; if (playerMotor) threshold = (playerMotor.IsRunning) ? RunStepInterval : WalkStepInterval; // Play sound if over distance threshold if (distance > threshold && customAudioSource && clip) { // Set a random pitch so footsteps don't sound too mechanical customAudioSource.pitch = Random.Range(1f - PitchVariance, 1f + PitchVariance); customAudioSource.PlayOneShot(clip, FootstepVolumeScale); distance = 0f; } }
void Update() { // Do nothing if not ready if (!ReadyCheck()) return; // Handle automated texture swaps if (dfUnity.Option_AutomateTextureSwaps) { // Only process if climate, season, day/night, or weather changed if (lastSeason != dfUnity.WorldTime.Now.SeasonValue || lastCityLightsFlag != dfUnity.WorldTime.Now.IsCityLightsOn) { ApplyTimeAndSpace(); lastSeason = dfUnity.WorldTime.Now.SeasonValue; lastCityLightsFlag = dfUnity.WorldTime.Now.IsCityLightsOn; } } }
void FixedUpdate() { DaggerfallDateTime.Seasons playerSeason = dfUnity.WorldTime.Now.SeasonValue; int playerClimateIndex = GameManager.Instance.PlayerGPS.CurrentClimateIndex; // Get player inside flag // Can only do this when PlayerEnterExit is available, otherwise default to true bool playerInside = (playerEnterExit == null) ? true : playerEnterExit.IsPlayerInside; bool playerInBuilding = (playerEnterExit == null) ? false : playerEnterExit.IsPlayerInsideBuilding; // Play splash footsteps whether player is walking on or swimming in exterior water bool playerOnExteriorWater = (GameManager.Instance.PlayerMotor.OnExteriorWater == PlayerMotor.OnExteriorWaterMethod.Swimming || GameManager.Instance.PlayerMotor.OnExteriorWater == PlayerMotor.OnExteriorWaterMethod.WaterWalking); // Change footstep sounds between winter/summer variants or when player enters/exits an interior space if (playerSeason != currentSeason || playerClimateIndex != currentClimateIndex || isInside != playerInside || playerOnExteriorWater != isInOutsideWater) { currentSeason = playerSeason; currentClimateIndex = playerClimateIndex; isInside = playerInside; isInOutsideWater = playerOnExteriorWater; if (!isInside) { if (currentSeason == DaggerfallDateTime.Seasons.Winter && !WeatherManager.IsSnowFreeClimate(currentClimateIndex)) { currentFootstepSound1 = FootstepSoundSnow1; currentFootstepSound2 = FootstepSoundSnow2; } else { currentFootstepSound1 = FootstepSoundOutside1; currentFootstepSound2 = FootstepSoundOutside2; } } else if (playerInBuilding) { currentFootstepSound1 = FootstepSoundBuilding1; currentFootstepSound2 = FootstepSoundBuilding2; } else // in dungeon { currentFootstepSound1 = FootstepSoundDungeon1; currentFootstepSound2 = FootstepSoundDungeon2; } clip1 = null; clip2 = null; } // walking on water tile if (playerOnExteriorWater) { currentFootstepSound1 = FootstepSoundSubmerged; currentFootstepSound2 = FootstepSoundSubmerged; clip1 = null; clip2 = null; } // Use water sounds if in dungeon water if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon && playerEnterExit.blockWaterLevel != 10000) { // In water, deep depth if ((currentFootstepSound1 != FootstepSoundSubmerged) && playerEnterExit.IsPlayerSwimming) { currentFootstepSound1 = FootstepSoundSubmerged; currentFootstepSound2 = FootstepSoundSubmerged; clip1 = null; clip2 = null; } // In water, shallow depth else if ((currentFootstepSound1 != FootstepSoundShallow) && !playerEnterExit.IsPlayerSwimming && (playerMotor.transform.position.y - 0.95f) < (playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale)) { currentFootstepSound1 = FootstepSoundShallow; currentFootstepSound2 = FootstepSoundShallow; clip1 = null; clip2 = null; } } // Not in water, reset footsteps to normal if ((!playerOnExteriorWater) && (currentFootstepSound1 == FootstepSoundSubmerged || currentFootstepSound1 == FootstepSoundShallow) && (playerEnterExit.blockWaterLevel == 10000 || (playerMotor.transform.position.y - 0.95f) >= (playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale))) { currentFootstepSound1 = FootstepSoundDungeon1; currentFootstepSound2 = FootstepSoundDungeon2; clip1 = null; clip2 = null; } // Reload clips if needed if (clip1 == null) { clip1 = dfAudioSource.GetAudioClip((int)currentFootstepSound1); } if (clip2 == null) { clip2 = dfAudioSource.GetAudioClip((int)currentFootstepSound2); } // Check whether player is on foot and abort playing footsteps if not. if (playerMotor.IsLevitating || !transportManager.IsOnFoot && GameManager.Instance.PlayerMotor.OnExteriorWater == PlayerMotor.OnExteriorWaterMethod.None) { distance = 0f; return; } // Check if player is grounded // Note: In classic, submerged "footstep" sound is only played when walking on the floor while in the water, but it sounds like a swimming sound // and when outside is played while swimming at the water's surface, so it seems better to play it all the time while submerged in water. if (currentFootstepSound1 != FootstepSoundSubmerged) { if (!IsGrounded()) { // Player has lost grounding distance = 0f; lostGrounding = true; return; } else { // Player is grounded but we might need to reset after losing grounding if (lostGrounding) { distance = 0f; lastPosition = GetHorizontalPosition(); lostGrounding = false; return; } } } // Get distance player travelled horizontally Vector3 position = GetHorizontalPosition(); distance += Vector3.Distance(position, lastPosition); lastPosition = position; // Get threshold float threshold = WalkStepInterval; if (playerMotor) { threshold = (playerMotor.IsRunning) ? RunStepInterval : WalkStepInterval; } // Play sound if over distance threshold if (distance > threshold && customAudioSource && clip1 && clip2) { float volumeScale = FootstepVolumeScale; if (playerMotor.IsMovingLessThanHalfSpeed) { volumeScale *= 0.5f; } if (!alternateStep) { customAudioSource.PlayOneShot(clip1, volumeScale * DaggerfallUnity.Settings.SoundVolume); } else { customAudioSource.PlayOneShot(clip2, volumeScale * DaggerfallUnity.Settings.SoundVolume); } alternateStep = (!alternateStep); distance = 0f; } }
void Update() { if (!Minimap.MinimapInstance.minimapActive) { return; } //FROST EFFECT\\ //set time for frost to fade in. float frostDuration = frostFadeInTime; int playerClimateIndex = GameManager.Instance.PlayerGPS.CurrentClimateIndex; DaggerfallDateTime.Seasons playerSeason = DaggerfallUnity.Instance.WorldTime.Now.SeasonValue; //cut frost time in half when snowing. if (GameManager.Instance.WeatherManager.IsSnowing) { frostDuration = frostFadeInTime * .5f; } if (!GameManager.Instance.IsPlayerInside) { if (frostTimer < frostFadeInTime) { bool nightTime = DaggerfallUnity.Instance.WorldTime.Now.Hour > DaggerfallDateTime.DuskHour && DaggerfallUnity.Instance.WorldTime.Now.Hour < 8; float frostModifier = 1; if (playerSeason == DaggerfallDateTime.Seasons.Winter) { if (playerClimateIndex == (int)MapsFile.Climates.Mountain || playerClimateIndex == (int)MapsFile.Climates.MountainWoods) { frostTimer += Time.deltaTime * 1.7f; } else if ((playerClimateIndex == (int)MapsFile.Climates.Desert || playerClimateIndex == (int)MapsFile.Climates.Desert2) && nightTime) { frostTimer += Time.deltaTime * 1.35f; } else if (playerClimateIndex == (int)MapsFile.Climates.HauntedWoodlands) { frostTimer += Time.deltaTime * .5f; } else if (GameManager.Instance.WeatherManager.IsSnowing) { frostTimer += Time.deltaTime * 2f; } } else if (playerSeason == DaggerfallDateTime.Seasons.Fall && playerSeason == DaggerfallDateTime.Seasons.Spring) { if (playerClimateIndex == (int)MapsFile.Climates.Mountain && DaggerfallUnity.Instance.WorldTime.Now.Hour > DaggerfallDateTime.DuskHour && DaggerfallUnity.Instance.WorldTime.Now.Hour < 10) { frostTimer += Time.deltaTime * 2; } if (playerClimateIndex == (int)MapsFile.Climates.Mountain && DaggerfallUnity.Instance.WorldTime.Now.Hour > DaggerfallDateTime.DuskHour && DaggerfallUnity.Instance.WorldTime.Now.Hour < 6) { frostTimer += Time.deltaTime * 1.25F; } else if ((playerClimateIndex == (int)MapsFile.Climates.Desert || playerClimateIndex == (int)MapsFile.Climates.Desert2) && nightTime) { frostTimer += Time.deltaTime * 1.5f; } else if (playerClimateIndex == (int)MapsFile.Climates.HauntedWoodlands && nightTime) { frostTimer += Time.deltaTime * .5f; } } else if (playerSeason == DaggerfallDateTime.Seasons.Summer) { if ((playerClimateIndex == (int)MapsFile.Climates.Mountain || playerClimateIndex == (int)MapsFile.Climates.MountainWoods) && nightTime) { frostTimer += Time.deltaTime * 1.5f; } else if (GameManager.Instance.WeatherManager.IsSnowing) { frostTimer += Time.deltaTime; } } } if (!GameManager.Instance.IsPlayerInside && (GameManager.Instance.WeatherManager.IsRaining || GameManager.Instance.WeatherManager.IsStorming)) { frostTimer = 0; } if (effectRawImage.color.a < lastFrostChange + .01f) { lastFrostChange = effectRawImage.color.a; effectRawImage.color = new Color(1, 1, 1, Mathf.Lerp(0, .9f, frostTimer / frostDuration)); } } else if (GameManager.Instance.IsPlayerInside) { if (frostTimer > 0) { frostTimer -= Time.deltaTime * 2; } if (effectRawImage.color.a > lastFrostChange - .01f) { lastFrostChange = effectRawImage.color.a; effectRawImage.color = new Color(1, 1, 1, Mathf.Lerp(0, .9f, frostTimer / frostDuration)); } } if (Minimap.MinimapInstance.currentEquippedCompass.ConditionPercentage > 40) { siblingIndex = Minimap.MinimapInstance.publicCompassGlass.transform.GetSiblingIndex() + 1; } else { siblingIndex = Minimap.MinimapInstance.publicCompassGlass.transform.GetSiblingIndex() - 1; } if (lastSiblingIndex != siblingIndex) { newEffect.transform.SetSiblingIndex(siblingIndex); lastSiblingIndex = siblingIndex; } }
// Add Grass private void AddGrass(DaggerfallTerrain daggerTerrain, TerrainData terrainData) { // Used to check performance // Stopwatch stopwatch = new Stopwatch(); // stopwatch.Start(); details = new int[256, 256]; //Get the current season currentSeason = DaggerfallUnity.Instance.WorldTime.Now.SeasonValue; //Proceed if it's NOT winter, and if the worldClimate contains grass, which is everything above 225, with the exception of 229 if (currentSeason != DaggerfallDateTime.Seasons.Winter && (daggerTerrain.MapData.worldClimate > 225 && daggerTerrain.MapData.worldClimate != 229)) { //Switch the grass texture based on the climate if (daggerTerrain.MapData.worldClimate == 226 || daggerTerrain.MapData.worldClimate == 227 || daggerTerrain.MapData.worldClimate == 228 || daggerTerrain.MapData.worldClimate == 230) detailPrototype[0].prototypeTexture = brownGrass; else detailPrototype[0].prototypeTexture = greenGrass; tilemap = daggerTerrain.TileMap; terrainData.detailPrototypes = detailPrototype; terrainData.wavingGrassTint = Color.gray; terrainData.SetDetailResolution(256, 8); int colorValue; //Check all the tiles, Daggerfall uses the red color value to draw tiles for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { colorValue = tilemap[(i * 128) + j].r; //For easier checking switch (colorValue) { //Four corner tiles case 8: case 9: case 10: case 11: details[i * 2, j * 2] = Random.Range(thickLower, thickHigher); details[i * 2, (j * 2) + 1] = Random.Range(thickLower, thickHigher); details[(i * 2) + 1, j * 2] = Random.Range(thickLower, thickHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thickLower, thickHigher); break; //Upper left corner case 40: case 224: case 164: case 176: case 181: details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); break; //Lower left corner case 41: case 221: case 165: case 177: case 182: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); break; //Lower right corner case 42: case 222: case 166: case 178: case 183: details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Upper right corner case 43: case 223: case 167: case 179: case 180: details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Left side case 44: case 66: case 84: case 160: case 168: details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); break; //lower side case 45: case 67: case 85: case 161: case 169: details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); break; //right side case 46: case 64: case 86: case 162: case 170: details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //upper side case 47: case 65: case 87: case 163: case 171: details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); break; //All expect lower right case 48: case 62: case 88: case 156: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //All expect upper right case 49: case 63: case 89: case 157: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); break; //All expect upper left case 50: case 60: case 90: case 158: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //All expect lower left case 51: case 61: case 91: case 159: details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Left to right case 204: case 206: case 214: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Right to left case 205: case 207: case 213: details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; } } } } terrainData.SetDetailLayer(0, 0, 0, details); // stopwatch.Stop(); // // Write result // UnityEngine.Debug.Log("Time elapsed: " + // stopwatch.Elapsed); }
// Add Grass private void AddGrass(DaggerfallTerrain daggerTerrain, TerrainData terrainData) { // Used to check performance // Stopwatch stopwatch = new Stopwatch(); // stopwatch.Start(); details = new int[256, 256]; //Get the current season currentSeason = DaggerfallUnity.Instance.WorldTime.Now.SeasonValue; //Proceed if it's NOT winter, and if the worldClimate contains grass, which is everything above 225, with the exception of 229 if (currentSeason != DaggerfallDateTime.Seasons.Winter && (daggerTerrain.MapData.worldClimate > 225 && daggerTerrain.MapData.worldClimate != 229)) { //Switch the grass texture based on the climate if (daggerTerrain.MapData.worldClimate == 226 || daggerTerrain.MapData.worldClimate == 227 || daggerTerrain.MapData.worldClimate == 228 || daggerTerrain.MapData.worldClimate == 230) { detailPrototype[0].prototypeTexture = brownGrass; } else { detailPrototype[0].prototypeTexture = greenGrass; } tilemap = daggerTerrain.TileMap; terrainData.detailPrototypes = detailPrototype; terrainData.wavingGrassTint = Color.gray; terrainData.SetDetailResolution(256, 8); int colorValue; //Check all the tiles, Daggerfall uses the red color value to draw tiles for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { colorValue = tilemap[(i * 128) + j].r; //For easier checking switch (colorValue) { //Four corner tiles case 8: case 9: case 10: case 11: details[i * 2, j * 2] = Random.Range(thickLower, thickHigher); details[i * 2, (j * 2) + 1] = Random.Range(thickLower, thickHigher); details[(i * 2) + 1, j * 2] = Random.Range(thickLower, thickHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thickLower, thickHigher); break; //Upper left corner case 40: case 224: case 164: case 176: case 181: details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); break; //Lower left corner case 41: case 221: case 165: case 177: case 182: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); break; //Lower right corner case 42: case 222: case 166: case 178: case 183: details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Upper right corner case 43: case 223: case 167: case 179: case 180: details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Left side case 44: case 66: case 84: case 160: case 168: details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); break; //lower side case 45: case 67: case 85: case 161: case 169: details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); break; //right side case 46: case 64: case 86: case 162: case 170: details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //upper side case 47: case 65: case 87: case 163: case 171: details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); break; //All expect lower right case 48: case 62: case 88: case 156: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //All expect upper right case 49: case 63: case 89: case 157: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); break; //All expect upper left case 50: case 60: case 90: case 158: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //All expect lower left case 51: case 61: case 91: case 159: details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Left to right case 204: case 206: case 214: details[i * 2, j * 2] = Random.Range(thinLower, thinHigher); details[(i * 2) + 1, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; //Right to left case 205: case 207: case 213: details[(i * 2) + 1, j * 2] = Random.Range(thinLower, thinHigher); details[i * 2, (j * 2) + 1] = Random.Range(thinLower, thinHigher); break; } } } } terrainData.SetDetailLayer(0, 0, 0, details); // stopwatch.Stop(); // // Write result // UnityEngine.Debug.Log("Time elapsed: " + // stopwatch.Elapsed); }