private static float GetFlatParamFromFactor(float factor, int x, int y, RandomMapType firstType = RandomMapType.GrassLand) { float flatFactor = factor * factor * factor; float flatParam; if (flatFactor < 0) { flatParam = flatMin + (flatMid - flatMin) * (1 + flatFactor); } else { flatParam = flatMid + (flatMax - flatMid) * flatFactor; } // float flatParam =flatMid; // if(firstType==RandomMapType.Desert) // flatParam*=0.5f; // else if(firstType==RandomMapType.Crater) // flatParam*=1.2f; // else if(firstType == RandomMapType.Mountain) // flatParam*=1.5f; if (flatParam > TownConnectionFlatMin) { float factorValue = GetTownConnectionFactor(x, y, TownConnectionFlatDistance); if (factorValue < 1) { flatParam = TownConnectionFlatMin; } } return(flatParam); }
public static void SetClimateType(ClimateType climate, RandomMapType mapType) { switch (climate) { case ClimateType.CT_Dry: // ClearChance = 80; // PartlyCloudyChance = 10; // MostlyCloudChance = 10; // SprinkleRainChance = 0; PeEnv.SetControlRain(NO_RAIN); break; case ClimateType.CT_Temperate: // ClearChance = 60; // PartlyCloudyChance = 14; // MostlyCloudChance = 12; // SprinkleRainChance = 8; PeEnv.SetControlRain(LESS_RAIN); break; case ClimateType.CT_Wet: // ClearChance = 60; // PartlyCloudyChance = 10; // MostlyCloudChance = 5; // SprinkleRainChance = 1; PeEnv.SetControlRain(FULL_RAIN); break; case ClimateType.CT_Random: switch ((int)Time.time % 3) { case 0: SetClimateType(ClimateType.CT_Dry, mapType); break; case 1: SetClimateType(ClimateType.CT_Temperate, mapType); break; case 2: SetClimateType(ClimateType.CT_Wet, mapType); break; } return; } if (mapType == RandomMapType.Desert) { PeEnv.SetControlRain(NO_RAIN); } WeatherConfig.climate = climate; RandomMapConfig.ScenceClimate = WeatherConfig.climate; }
protected override int GetCurrentBgMusicID() { Vector3 camPos = PETools.PEUtil.MainCamTransform.position; if (AiUtil.CheckPositionInCave(camPos, 128.0f, AiUtil.groundedLayer)) { return(836); } int x = (int)camPos.x; int z = (int)camPos.z; if (x <= Int32.MinValue) { Debug.LogError("x value too small!"); x = Int32.MinValue + 1; } if (z <= Int32.MinValue) { Debug.LogError("z value too small!"); z = Int32.MinValue + 1; } if (VFDataRTGen.IsSea(x, z)) { return(AISpawnDataStory.GetBackGroundMusic(new Color(255.0f / 255.0f, 100.0f / 255.0f, 150.0f / 255.0f, 255 / 255.0f))); } else { RandomMapType mapType = VFDataRTGen.GetXZMapType(x, z); switch (mapType) { case RandomMapType.GrassLand: return(AISpawnDataStory.GetBackGroundMusic(new Color(30.0f / 255.0f, 50.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Forest: return(AISpawnDataStory.GetBackGroundMusic(new Color(70.0f / 255.0f, 70.0f / 255.0f, 70.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Desert: return(AISpawnDataStory.GetBackGroundMusic(new Color(140.0f / 255.0f, 100.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Redstone: return(AISpawnDataStory.GetBackGroundMusic(new Color(170.0f / 255.0f, 70.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Rainforest: return(AISpawnDataStory.GetBackGroundMusic(new Color(90.0f / 255.0f, 90.0f / 255.0f, 90.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Mountain: return(AISpawnDataStory.GetBackGroundMusic(new Color(170.0f / 255.0f, 70.0f / 255.0f, 150.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Swamp: return(AISpawnDataStory.GetBackGroundMusic(new Color(100.0f / 255.0f, 50.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Crater: return(AISpawnDataStory.GetBackGroundMusic(new Color(180.0f / 255.0f, 180.0f / 255.0f, 180.0f / 255.0f, 255 / 255.0f))); default: return(0); } } }
static RandomMapType GetMapTypeAndTerInc(IntVector2 worldPos, out RandomMapType firstType, out RandomMapType secondType, out float diffValue, out float[] terTypeInc) { List <RandomMapTypeDist> rmtdList = new List <RandomMapTypeDist> (); for (int i = 0; i < BiomaDistList.Count; i++) { rmtdList.Add(new RandomMapTypeDist(BiomaDistList[i].type, BiomaDistList[i].GetDistance(worldPos))); } rmtdList.Sort(); firstType = rmtdList[0].type; secondType = rmtdList[1].type; diffValue = rmtdList[1].distance - rmtdList[0].distance; //compute TerTypeInc List <float[]> terTypeList = new List <float[]>(); List <float> distList = new List <float> (); for (int i = 0; i < rmtdList.Count; i++) { if (rmtdList[i].distance - rmtdList[0].distance < terTypeChangeDist) { terTypeList.Add(terTypeChanceIncList[(int)rmtdList[i].type - 1]); distList.Add(rmtdList[i].distance - rmtdList[0].distance); } } terTypeInc = GetTerTypeInc(terTypeList, distList); float scaledX = worldPos.x * s_detailScale; float scaledZ = worldPos.y * s_detailScale; if (diffValue < changeBiomaDiff) { //from large to small, when diff gets larger, type[0] more possible float chance = (float)myBiomaNoise[ChangeIndex].Noise(scaledX * changeMapTypeFrequency, scaledZ * changeMapTypeFrequency); chance = chance * 0.5f + 0.5f; float chance2 = (1 - diffValue / changeBiomaDiff) / 2; if ((int)firstType < (int)secondType) { return((chance < chance2) ? secondType : firstType); } else { return((chance < 1 - chance2) ? firstType : secondType); } } else { return(firstType); } //return firstType; }
internal override int GetMapID(Vector3 position) { RandomMapType map = VFDataRTGen.GetXZMapType((int)position.x, (int)position.z); switch (map) { case RandomMapType.GrassLand: return(2); case RandomMapType.Forest: return(8); case RandomMapType.Desert: return(13); case RandomMapType.Redstone: return(18); case RandomMapType.Rainforest: return(10); default: return(0); } }
public bool IsTerrainAvailable(IntVector2 GenPos, out Vector3 pos, out int boxId) { //--to do: 1.random the data int height = VFDataRTGen.GetPosHeight(GenPos.x, GenPos.y, true); bool inWater = VFDataRTGen.IsSea(height); bool inCave = false; pos = new Vector3(GenPos.x, height - 2, GenPos.y); RaycastHit hitTest; if (Physics.Raycast(pos, Vector3.down, out hitTest, 512, 1 << Pathea.Layer.VFVoxelTerrain)) { inCave = true; } RandomMapType type = VFDataRTGen.GetXZMapType(GenPos.x, GenPos.x); IntVector2 tileIndex = new IntVector2(GenPos.x >> VoxelTerrainConstants._shift, GenPos.y >> VoxelTerrainConstants._shift); VArtifactTown vaTown = null; if (VArtifactTownManager.Instance != null) { for (int i = -4; i < 5; i++) { for (int j = -4; j < 5; j++) { vaTown = VArtifactTownManager.Instance.GetTileTown(new IntVector2(tileIndex.x + i, tileIndex.y + j)); if (vaTown != null) { break; } } if (vaTown != null) { break; } } } List <int> genCondition = new List <int>(); if (vaTown != null) { if (vaTown.type == VArtifactType.NpcTown) { genCondition.Add(BoxMapTypeInt.NEAR_TOWN); } else { genCondition.Add(BoxMapTypeInt.NEAR_CAMP); } } switch (type) { case RandomMapType.Desert: genCondition.Add(BoxMapTypeInt.DESERT); break; case RandomMapType.Redstone: genCondition.Add(BoxMapTypeInt.REDSTONE); break; default: genCondition.Add(BoxMapTypeInt.GRASSLAND); break; } if (inWater) { genCondition.Add(BoxMapTypeInt.IN_WATER); } if (inCave) { genCondition.Add(BoxMapTypeInt.IN_CAVE); } boxId = -1; List <RandomItemBoxInfo> boxInfoList = RandomItemDataMgr.GetBoxIdByCondition(genCondition, height); if (boxInfoList == null || boxInfoList.Count == 0) { return(false); } List <RandomItemBoxInfo> boxInfoAvailable = new List <RandomItemBoxInfo> (); foreach (RandomItemBoxInfo rib in boxInfoList) { if (IsBoxNumAvailable(rib.boxId, rib.boxAmount)) { boxInfoAvailable.Add(rib); } } if (boxInfoAvailable.Count == 0) { return(false); } RandomItemBoxInfo boxInfo = boxInfoAvailable[new System.Random((int)System.DateTime.UtcNow.Ticks).Next(boxInfoAvailable.Count)]; boxId = boxInfo.boxId; float deep = boxInfo.boxDepth; //2.check with boxId if (deep <= 0) { deep = -3; } else if (deep < 2) { deep = 2; } pos = new Vector3(GenPos.x, height - deep, GenPos.y); if (pos.y < 0) { pos.y = 0; } else { RaycastHit hit; if (Physics.Raycast(pos, Vector3.down, out hit, 512, 1 << Pathea.Layer.VFVoxelTerrain)) { pos.y = hit.point.y - boxInfo.boxDepth; } } if (pos.y < 0) { return(false); } return(true); }
private void GeneralMineral(byte[] yVoxels, float voxelX, float[] voxelYs, float voxelZ, float mineChanceFactor, float ftertype, RandomMapType maptype) { MineChanceArrayCLS[] regionMinePercentDesc = regionArray[(int)maptype - 1].MineChanceArrayValues; float regionMineChance = regionArray[(int)maptype - 1].mineChance; int nChance = regionMinePercentDesc.Length; int maxY = yVoxels.Length >> VFVoxel.c_shift; //start from coal for (int j = 0; j < nChance; j++) { float SecondChance = regionMineChance * mineGenChanceFactor; //int i = j; int i = j; int noiseIndex = i + MineStartNoiseIndex; //float mineChance = (float)myNoise[noiseIndex].Noise(voxelX * minePerturbanceFrequency0, voxelY * minePerturbanceFrequency0, voxelZ * minePerturbanceFrequency0);//��Ĵ�ŷֲ���״ float mineChance = (float)myMineNoise[noiseIndex].Noise(voxelX * minePerturbanceFrequency0, voxelZ * minePerturbanceFrequency0);//��Ĵ�ŷֲ���״ float chance; if (mineChance < 0) { chance = -mineChance; } else { chance = mineChance; } if (chance < SecondChance) { float metalReduce = 1.0f; // if (metalReduceSwitch) // { // if (j >= 2 && Mathf.Abs(voxelX / s_detailScale) < metalReduceArea && Mathf.Abs(voxelZ / s_detailScale) < metalReduceArea) // { // metalReduce = 1 - ((metalReduceArea - Mathf.Abs(voxelX / s_detailScale)) * (metalReduceArea - Mathf.Abs(voxelZ / s_detailScale))) / (metalReduceArea * metalReduceArea); // } // } float mineChance2 = (float)myMineNoise[noiseIndex + nChance].Noise(voxelX * minePerturbanceFrequency1, voxelZ * minePerturbanceFrequency1);// float chance2 = mineChance2 * 100; if (mineChance2 < 0) { chance2 *= -1; } //chance2 = chance2 * chance; float genPercent = regionMinePercentDesc[i].perc; // if(maptype==RandomMapType.Desert && i==oilIndex){ // genPercent +=5; // } // if((maptype == RandomMapType.Forest||maptype==RandomMapType.Rainforest)&& i ==coalIndex){ // genPercent +=5; // } float newChance = genPercent * metalReduce; //float newChance = 1.2f*terMinePercentDesc[nTerType][i].perc * agglomeration; if (chance2 < newChance) { float heightFactor = (float)myMineNoise[HEIGHT_INDEX].Noise(voxelX * mineHeightFrequency, voxelZ * mineHeightFrequency); float thicknessFactor = (float)myMineNoise[THICKNESS_INDEX].Noise(voxelX * mineThicknessFrequency, voxelZ * mineThicknessFrequency); float quantityFactor = (float)myMineNoise[QUANTITY_INDEX].Noise(voxelX * mineQuantityFrequency, voxelZ * mineQuantityFrequency); float chanceFactor = (SecondChance - chance) / SecondChance * (newChance - chance2) / newChance * mineChanceFactor; int midVy = Mathf.RoundToInt((MineStartHeightList[i] * PlainMax(PlainThickness) / (s_seaDepth + 40)) + heightFactor * HeightOffsetMax + HeightOffsetTer * ftertype * ftertype); float thickness = MineThickness + ThicknessOffsetMax * thicknessFactor; float quantity = 1 / ((quantityFactor + 1) * 0.3f);//(0,1)->(1,NaN) float chanceDecrease; if (chanceFactor > 0.3f) { chanceDecrease = 1; } else { //chanceDecrease= Mathf.Pow(chanceFactor/0.3f,0.5f); chanceDecrease = Mathf.Sqrt(chanceFactor / 0.3f); } thickness *= chanceDecrease; int startVy = Mathf.Clamp(Mathf.RoundToInt(midVy - thickness / 2), 0, 511); int endVy = startVy + (int)(thickness / 2) + 1; if (endVy > maxY) { endVy = maxY; } float vyValue = startVy; for (int vy = startVy; vy < endVy;) { int vy2 = vy * VFVoxel.c_VTSize; if (yVoxels[vy2] > 127.5f) { yVoxels[vy2 + 1] = (byte)(regionMinePercentDesc[i].type); } vyValue += quantity; vy = Mathf.RoundToInt(vyValue); } break; } } } }
public static int MapTypeToRegionId(RandomMapType type) { return((int)type - 1); }
static RandomMapType GetMapType(float scaledX, float scaledZ, out RandomMapType firstType, out RandomMapType secondType, out float diffValue) { IntVector2 worldPos = new IntVector2(Mathf.RoundToInt(scaledX / s_detailScale), Mathf.RoundToInt(scaledZ / s_detailScale)); return(GetMapTypeNew(worldPos, out firstType, out secondType, out diffValue)); }
public static float GetOriginalFterType(IntVector2 worldXZ, out float fTerTypeBridge, out bool caveEnable, out bool riverArea, out bool lakeArea, out float riverValue, out float bridgeValue, out float bridge2dFactor, out RandomMapType mapType, out float[] terTypeInc) { float scaledX = worldXZ.x * s_detailScale; float scaledZ = worldXZ.y * s_detailScale; mapType = GetMapTypeAndTerInc(scaledX, scaledZ, out terTypeInc); float fNoise12D1ten = GetfNoise12D1ten(scaledX, scaledZ); float continentBound = GetContinentValue(worldXZ.x, worldXZ.y); //int nTerType = 0; float fTerType = fNoise12D1ten / 100; //[0,1] fTerType = BlendContinentBound(fTerType, continentBound, terTypeInc); if (fTerType < 0) { fTerType = 0; } caveEnable = true; riverArea = false; lakeArea = false; riverValue = GetRiverValue(worldXZ.x, worldXZ.y, ref fTerType, ref caveEnable, ref lakeArea, out bridgeValue, out bridge2dFactor, terTypeInc); if (riverValue < 0.85f) { riverArea = true; } float fTerTypeRiver = fTerType * riverValue; fTerTypeBridge = -1; if (bridgeValue != -1) { fTerTypeBridge = fTerType * bridgeValue; } return(fTerTypeRiver); }
public static float GetFinalFterType(IntVector2 worldXZ, out float fTerTypeBridge, out bool caveEnable, out bool riverArea, out bool lakeArea, out float riverValue, out float bridgeValue, out float bridge2dFactor, out RandomMapType mapType, out float[] terTypeInc) { float finalFTerType = GetOriginalFterType(worldXZ, out fTerTypeBridge, out caveEnable, out riverArea, out lakeArea, out riverValue, out bridgeValue, out bridge2dFactor, out mapType, out terTypeInc); // finalFTerType= GetTownAreaValue(finalFTerType,worldXZ); return(finalFTerType); }
public RandomMapTypeDist(RandomMapType type, float dist) { this.type = type; distance = dist; }
public RandomMapTypePoint(RandomMapType type, IntVector2 pos) { this.type = type; posList.Add(pos); }
public RandomMapTypePoint(RandomMapType type) { this.type = type; }
public static void Update() { if (Nova != null) { if (Pathea.SingleGameStory.curType == Pathea.SingleGameStory.StoryScene.PajaShip) { Nova.LocalTime = 0; } else { Nova.LocalTime = GameTime.Timer.Second; } if (Pathea.PeGameMgr.IsMulti) { if (PlayerNetwork.mainPlayer != null && PlayerNetwork.mainPlayer._curSceneId == (int)Pathea.SingleGameStory.StoryScene.PajaShip) { Nova.LocalTime = 0; } } Nova.Settings.TimeElapseSpeed = GameTime.Timer.ElapseSpeed; Nova.Settings.SoundVolume = SystemSettingData.Instance.SoundVolume * SystemSettingData.Instance.EffectVolume; Nova.WetCoef = (float)System.Math.Pow(System.Math.Max((s_envNoise.Noise(Nova.LocalDay * 1.2) + s_envNoise.Noise(Nova.LocalDay * 2.4) * 0.5 + s_envNoise.Noise(Nova.LocalDay * 4.8) * 0.25 + s_envNoise.Noise(Nova.LocalDay * 9.6) * 0.125) * 0.38 + 0.45, 0), 3); // 小雨多一点.. if (Nova.WetCoef > 0.55f) { Nova.WetCoef -= 0.55f; Nova.WetCoef *= 2.2f; Nova.WetCoef = (float)System.Math.Pow(Nova.WetCoef, 2f); Nova.WetCoef /= 2.2f; Nova.WetCoef += 0.55f; } Nova.WetCoef = (Mathf.Clamp01(Nova.WetCoef) * ControlRain + BaseRain) * rainSwitch; Debug.DrawLine(new Vector3((float)Nova.LocalDay, (float)Nova.WetCoef, 0), new Vector3((float)Nova.LocalDay + 0.01f, (float)Nova.WetCoef, 0), Color.white, 1000); bool water_opt1 = SystemSettingData.Instance.WaterDepth; bool water_opt2 = SystemSettingData.Instance.WaterRefraction; int water_opt_ = 0; if (water_opt1 && water_opt2) { water_opt_ = 3; } else if (water_opt1 || water_opt2) { water_opt_ = 2; } else { water_opt_ = 1; } if (water_opt != water_opt_) { Material water_mat = null; switch (water_opt_) { case 3: water_mat = Resources.Load <Material>("PEWater_High"); break; case 2: water_mat = Resources.Load <Material>("PEWater_Medium"); break; case 1: water_mat = Resources.Load <Material>("PEWater_Low"); break; default: break; } if (VFVoxelWater.self != null && PEWaveSystem.Self != null) { Material new_water_mat = Material.Instantiate(water_mat) as Material; VFVoxelWater.self.WaterMat = new_water_mat; NovaSettings.WaterMaterial = new_water_mat; water_opt = water_opt_; } } RenderSettings.fog = !VCEditor.s_Ready; if (Pathea.PeGameMgr.sceneMode == Pathea.PeGameMgr.ESceneMode.Story) { if (PeMappingMgr.inited) { switch (PeMappingMgr.Instance.Biome) { case GraphMapping.EBiome.Sea: Nova.BiomoIndex = 0; break; case GraphMapping.EBiome.Marsh: Nova.BiomoIndex = 4; break; case GraphMapping.EBiome.Jungle: Nova.BiomoIndex = 2; break; case GraphMapping.EBiome.Forest: Nova.BiomoIndex = 1; break; case GraphMapping.EBiome.Desert: Nova.BiomoIndex = 0; break; case GraphMapping.EBiome.Canyon: Nova.BiomoIndex = 0; break; case GraphMapping.EBiome.Volcano: Nova.BiomoIndex = 6; break; case GraphMapping.EBiome.Grassland: Nova.BiomoIndex = 0; break; case GraphMapping.EBiome.Mountainous: Nova.BiomoIndex = 3; break; default: Nova.BiomoIndex = 0; break; } float mul_target = 1f; float ofs_target = 0f; switch (PeMappingMgr.Instance.Biome) { case GraphMapping.EBiome.Desert: mul_target = 0.3f; ofs_target = 0.0f; break; case GraphMapping.EBiome.Volcano: mul_target = 0.3f; ofs_target = 0.45f; break; default: mul_target = 1f; ofs_target = 0f; break; } wetcoef_multiplier = Mathf.Lerp(wetcoef_multiplier, mul_target, 0.01f); wetcoef_offset = Mathf.Lerp(wetcoef_offset, ofs_target, 0.01f); Nova.WetCoef *= wetcoef_multiplier; Nova.WetCoef += wetcoef_offset; } else { Nova.BiomoIndex = 0; } } else { Nova.BiomoIndex = 0; } if (RandomDungenMgrData.InDungeon) { Nova.BiomoIndex = 5; } else { if (Pathea.PeGameMgr.IsAdventure || Pathea.PeGameMgr.IsBuild) { if (Pathea.PeCreature.Instance.mainPlayer != null) { RandomMapType rmt = VFDataRTGen.GetXZMapType(Mathf.RoundToInt(Pathea.PeCreature.Instance.mainPlayer.position.x), Mathf.RoundToInt(Pathea.PeCreature.Instance.mainPlayer.position.z)); switch (rmt) { case RandomMapType.Swamp: Nova.BiomoIndex = 4; break; case RandomMapType.Rainforest: Nova.BiomoIndex = 2; break; case RandomMapType.Forest: Nova.BiomoIndex = 1; break; case RandomMapType.Desert: Nova.BiomoIndex = 0; break; case RandomMapType.Redstone: Nova.BiomoIndex = 0; break; case RandomMapType.Crater: Nova.BiomoIndex = 6; break; case RandomMapType.GrassLand: Nova.BiomoIndex = 0; break; case RandomMapType.Mountain: Nova.BiomoIndex = 3; break; default: Nova.BiomoIndex = 0; break; } } } } if (Pathea.PeGameMgr.sceneMode == Pathea.PeGameMgr.ESceneMode.Story || Pathea.PeGameMgr.sceneMode == Pathea.PeGameMgr.ESceneMode.Custom) { switch (SystemSettingData.Instance.TerrainLevel) { //lz-2016.06.17 由(0=128M,1=256M,2=512M,3=1KM)改为(0=256M,1=512M,2=1KM),因此这里改为这样 case 0: Nova.Settings.MaxFogEndDistance = 200; break; case 1: Nova.Settings.MaxFogEndDistance = 340; break; case 2: Nova.Settings.MaxFogEndDistance = 700; break; case 3: Nova.Settings.MaxFogEndDistance = 1300; break; } } else { Nova.Settings.MaxFogEndDistance = 550; } // 靠近海洋才打开水的反射效果,远离海洋则关闭, //if (Input.GetKeyDown(KeyCode.I)){ AlterNearSea(false); } //if (Input.GetKeyDown(KeyCode.O)){ AlterNearSea(true); } AlterNearSea(WaterReflection.ReqRefl()); if (Mathf.Abs(_nearSeaTarget - _nearSeaCurrent) > 0.0001f) { _nearSeaCurrent = Mathf.Lerp(_nearSeaCurrent, _nearSeaTarget, 0.04f); // About 3s } if (_nearSeaCurrent < 0.001f) { WaterReflection.DisableRefl(); } else { WaterReflection.EnableRefl(); } Nova.WaterReflectionMasterBlend = _nearSeaCurrent; } // End Nova != null }