public void LoadMap(string path) { bmp = new Bitmap(path); bmp.RotateFlip(RotateFlipType.RotateNoneFlipNone); MapColor ground = new MapColor(0, 255, 0); MapColor water = new MapColor(255, 255, 255); MapPixel waterPixel = new MapPixel(); waterPixel.status = PixelStatus.Water; for (int i = 0; i < bmp.Width; i++) { map.Add(new List <MapPixel>()); for (int j = 0; j < bmp.Height; j++) { System.Drawing.Color c = bmp.GetPixel(i, j); if (water.R == c.R && water.G == c.G && water.B == c.B) { map[i].Add(waterPixel); } else { map[i].Add(new MapPixel()); } } } for (int i = 0; i < bmp.Width; i += 20) { for (int j = 0; j < bmp.Height; j += 20) { detectors.Add(new MapDetectorSquare(new Vector2(i, j))); } } }
public override void WriteData(ESPWriter writer) { if (EditorID != null) { EditorID.WriteBinary(writer); } if (LargeIcon != null) { LargeIcon.WriteBinary(writer); } if (SmallIcon != null) { SmallIcon.WriteBinary(writer); } if (MapColor != null) { MapColor.WriteBinary(writer); } if (Worldspace != null) { Worldspace.WriteBinary(writer); } if (Areas != null) { foreach (var item in Areas) { item.WriteBinary(writer); } } if (DataEntries != null) { foreach (var item in DataEntries) { item.WriteBinary(writer); } } }
public void ResetMapInfo() { this.songName = null; this.songSubName = null; this.songAuthorName = null; this.levelAuthorName = null; this.songCover = null; this.songHash = null; this.levelId = null; this.songBPM = 0f; this.noteJumpSpeed = 0f; this.songTimeOffset = 0; this.length = 0; this.start = 0; this.paused = 0; this.difficulty = null; this.notesCount = 0; this.obstaclesCount = 0; this.maxScore = 0; this.maxRank = "E"; this.environmentName = null; this.colorLeft = null; this.colorRight = null; }
public Line(JSONLine jsonLine, Map map) { Points = new Vector3[jsonLine.points.Length]; float xMult = map.HScale / map.Resolution; float yMult = -map.VScale / map.Resolution; for (int i = 0; i < jsonLine.points.Length; i++) { Points[i] = new Vector3(jsonLine.points[i].x * xMult, 0, jsonLine.points[i].y * yMult) + map.Offset; } switch (jsonLine.color) { case "r": Color = MapColor.Red; break; case "g": Color = MapColor.Green; break; case "b": Color = MapColor.Blue; break; case "k": Color = MapColor.Black; break; default: Color = MapColor.Black; break; } Closed = jsonLine.closed; }
void ColorBiome(MapLoc l) { float r = mapGen.WaterFlux[l.x, l.y]; float t = mapGen.Temperature[l.x, l.y]; float e = mapGen.Elevation[l.x, l.y]; Color orange = MapColor.GetColorLerp(0.5f, Color.red, Color.yellow); Color cr = MapColor.GetColorLerp(r, orange, Color.green); Color ct = MapColor.GetColorLerp(t, Color.black, Color.white); Color c = MapColor.GetColorLerp(0.5f, cr, ct); c = e < mapGen.seaLevel ? Color.blue : c; c = (mapGen.Temperature[l.x, l.y] < mapGen.iceLevel) ? Color.white : c; c = (mapGen.WaterFlux[l.x, l.y] > mapGen.riverLevel) && e > mapGen.seaLevel ? MapColor.GetColorLerp(0.5f, Color.blue, Color.cyan) : c; GameObject go = Tiles[l]; ResetTile(go); go.GetComponent <Renderer>().material.SetColor("_Color", c); }
public static Color[,] ColorMap(int mapWidth, int mapHeight, int seed, float scale, int octaves, float persistance, float lacunarity, Vector2 offset, float WaterLevel, MapColor colors) { float[,] heightMap = new float[mapWidth, mapHeight]; float[,] temparatureMap = new float[mapWidth, mapHeight]; Color[,] writingColorMap = new Color[mapWidth, mapHeight]; heightMap = NoiseGenerator.GenerateNoiseMap(mapWidth, mapHeight, seed, scale, octaves, persistance, lacunarity, offset + new Vector2((colors.LoadedChunk.x + colors.FakePosX) * mapWidth, (colors.LoadedChunk.y + colors.FakePosY) * mapHeight)); temparatureMap = NoiseGenerator.TempMap(mapWidth, mapHeight, heightMap, colors); for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { Color BeachColor = new Color(Mathf.Lerp(colors.TeamperateBeach.r, colors.TopicalBeach.r, 1 - temparatureMap[x, y]), Mathf.Lerp(colors.TeamperateBeach.g, colors.TopicalBeach.g, 1 - temparatureMap[x, y]), Mathf.Lerp(colors.TeamperateBeach.b, colors.TopicalBeach.b, 1 - temparatureMap[x, y])); BeachColor.r = BeachColor.r + heightMap[x, y] - WaterLevel; BeachColor.g = BeachColor.g + heightMap[x, y] - WaterLevel; BeachColor.b = BeachColor.b + heightMap[x, y] - WaterLevel; Color OceanColor = new Color((colors.Ocean.r + heightMap[x, y]) - WaterLevel, (colors.Ocean.g + heightMap[x, y]) - WaterLevel, (colors.Ocean.b + heightMap[x, y]) - WaterLevel); Color SeaColor = new Color((colors.Sea.r + heightMap[x, y]) - WaterLevel, (colors.Sea.g + heightMap[x, y]) - WaterLevel, (colors.Sea.b + heightMap[x, y]) - WaterLevel); Color UnEditedGrass = new Color(Mathf.Lerp(colors.Cold.r, colors.Wet.r, 1 - temparatureMap[x, y]), Mathf.Lerp(colors.Cold.g, colors.Wet.g, 1 - temparatureMap[x, y]), Mathf.Lerp(colors.Cold.b, colors.Wet.b, 1 - temparatureMap[x, y])); if (heightMap[x, y] >= WaterLevel) { if (heightMap[x, y] > colors.DryLevel) { if (heightMap[x, y] > colors.MoutainLevel) { writingColorMap[x, y] = new Color(Mathf.Lerp(colors.WetRock.r, colors.ColdRock.r, heightMap[x, y]) - colors.RockDryness, Mathf.Lerp(colors.WetRock.g, colors.ColdRock.g, heightMap[x, y]) - colors.RockDryness, Mathf.Lerp(colors.WetRock.b, colors.ColdRock.b, heightMap[x, y]) - colors.RockDryness); } else { if (temparatureMap[x, y] < 0.40f) { writingColorMap[x, y] = colors.DrySand; } else { writingColorMap[x, y] = new Color(Mathf.Lerp(UnEditedGrass.r, colors.Dry.r, heightMap[x, y]), Mathf.Lerp(UnEditedGrass.g, colors.Dry.g, heightMap[x, y]), Mathf.Lerp(UnEditedGrass.b, colors.Dry.b, heightMap[x, y])); } } } else { writingColorMap[x, y] = UnEditedGrass; } } else { if (temparatureMap[x, y] > colors.GlobalIceMapping) { writingColorMap[x, y] = colors.Ice; } else { if (heightMap[x, y] > colors.BeachLevel) { writingColorMap[x, y] = NoiseGenerator.ColorLerp(BeachColor, SeaColor, 1 - (heightMap[x, y] - colors.BeachLevel) / (WaterLevel - colors.BeachLevel)); } else { if (heightMap[x, y] > colors.SeaLevel) { writingColorMap[x, y] = NoiseGenerator.ColorLerp(SeaColor, OceanColor, 1 - (heightMap[x, y] - colors.SeaLevel) / (colors.BeachLevel - colors.SeaLevel)); } else { writingColorMap[x, y] = OceanColor; } } } } } } for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { if (temparatureMap[x, y] > colors.GlobalSnowMapping && heightMap[x, y] > WaterLevel) { writingColorMap[x, y] = colors.Snow; } } } return(writingColorMap); }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "ICON": if (LargeIcon == null) { LargeIcon = new SimpleSubrecord <String>(); } LargeIcon.ReadBinary(reader); break; case "MICO": if (SmallIcon == null) { SmallIcon = new SimpleSubrecord <String>(); } SmallIcon.ReadBinary(reader); break; case "RCLR": if (MapColor == null) { MapColor = new SimpleSubrecord <Color>(); } MapColor.ReadBinary(reader); break; case "WNAM": if (Worldspace == null) { Worldspace = new RecordReference(); } Worldspace.ReadBinary(reader); break; case "RPLI": if (Areas == null) { Areas = new List <RegionArea>(); } RegionArea tempRPLI = new RegionArea(); tempRPLI.ReadBinary(reader); Areas.Add(tempRPLI); break; case "RDAT": if (DataEntries == null) { DataEntries = new List <RegionDataEntry>(); } RegionDataEntry tempRDAT = new RegionDataEntry(); tempRDAT.ReadBinary(reader); DataEntries.Add(tempRDAT); break; default: throw new Exception(); } } }
public override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (EditorID != null) { ele.TryPathTo("EditorID", true, out subEle); EditorID.WriteXML(subEle, master); } if (LargeIcon != null) { ele.TryPathTo("Icon/Large", true, out subEle); LargeIcon.WriteXML(subEle, master); } if (SmallIcon != null) { ele.TryPathTo("Icon/Small", true, out subEle); SmallIcon.WriteXML(subEle, master); } if (MapColor != null) { ele.TryPathTo("MapColor", true, out subEle); MapColor.WriteXML(subEle, master); } if (Worldspace != null) { ele.TryPathTo("Worldspace", true, out subEle); Worldspace.WriteXML(subEle, master); } if (Areas != null) { ele.TryPathTo("Areas", true, out subEle); List <string> xmlNames = new List <string> { "Area" }; int i = 0; foreach (var entry in Areas) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } if (DataEntries != null) { ele.TryPathTo("DataEntries", true, out subEle); List <string> xmlNames = new List <string> { "DataEntry" }; int i = 0; foreach (var entry in DataEntries) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } }
public MaterialPortal(MapColor color) : base(color) { base.IsSolid = false; base.BlocksLight = false; base.BlocksMovement = false; }
public MaterialTransparent(MapColor par1MapColor) : base(par1MapColor) { SetGroundCover(); }
public MaterialLeaves(MapColor color) : base(color) { }
public Material(MapColor par1MapColor) { CanHarvest = true; MaterialMapColor = par1MapColor; }
public Material(MapColor color) { // this.materialMapColor = color; }
public MaterialLogic(MapColor par1MapColor) : base(par1MapColor) { }
public Terrain( int id, string name, MapColor color ) { this.id = id; this.name = name; this.color = color; }
Color ColorBasic(float value, float coeff, Color cLower, Color cUpper) { return(MapColor.GetColorLerp(value, cLower, cUpper)); }
Color ColorCutoff(float value, float coeff, Color cLower, Color cUpper) { return(MapColor.GetColorCutoff(value, coeff, cLower, cUpper)); }
public MaterialLogic(MapColor color) : base(color) { this.SetAdventureModeExempt(); }
public ExtraSongData(string levelID, string songPath) { // Utilities.Logging.Log("SongData Ctor"); try { if (!File.Exists(songPath + "/info.dat")) { return; } var infoText = File.ReadAllText(songPath + "/info.dat"); JObject info = JObject.Parse(infoText); JObject infoData; List <Contributor> levelContributors = new List <Contributor>(); //Check if song uses legacy value for full song One Saber mode if (info.ContainsKey("_customData")) { infoData = (JObject)info["_customData"]; if (infoData.ContainsKey("_contributors")) { levelContributors.AddRange(infoData["_contributors"].ToObject <Contributor[]>()); } if (infoData.ContainsKey("_customEnvironment")) { _customEnvironmentName = (string)infoData["_customEnvironment"]; } if (infoData.ContainsKey("_customEnvironmentHash")) { _customEnvironmentHash = (string)infoData["_customEnvironmentHash"]; } } contributors = levelContributors.ToArray(); List <DifficultyData> diffData = new List <DifficultyData>(); JArray diffSets = (JArray)info["_difficultyBeatmapSets"]; foreach (JObject diffSet in diffSets) { string SetCharacteristic = (string)diffSet["_beatmapCharacteristicName"]; JArray diffBeatmaps = (JArray)diffSet["_difficultyBeatmaps"]; foreach (JObject diffBeatmap in diffBeatmaps) { List <string> diffRequirements = new List <string>(); List <string> diffSuggestions = new List <string>(); List <string> diffWarnings = new List <string>(); List <string> diffInfo = new List <string>(); string diffLabel = ""; MapColor diffLeft = null; MapColor diffRight = null; BeatmapDifficulty diffDifficulty = Utilities.Utils.ToEnum((string)diffBeatmap["_difficulty"], BeatmapDifficulty.Normal); JObject beatmapData; if (diffBeatmap.ContainsKey("_customData")) { beatmapData = (JObject)diffBeatmap["_customData"]; if (beatmapData.ContainsKey("_difficultyLabel")) { diffLabel = (string)beatmapData["_difficultyLabel"]; } //Get difficulty json fields if (beatmapData.ContainsKey("_colorLeft")) { if (beatmapData["_colorLeft"].Children().Count() == 3) { diffLeft = new MapColor(0, 0, 0); diffLeft.r = (float)beatmapData["_colorLeft"]["r"]; diffLeft.g = (float)beatmapData["_colorLeft"]["g"]; diffLeft.b = (float)beatmapData["_colorLeft"]["b"]; } } if (beatmapData.ContainsKey("_colorRight")) { if (beatmapData["_colorRight"].Children().Count() == 3) { diffRight = new MapColor(0, 0, 0); diffRight.r = (float)beatmapData["_colorRight"]["r"]; diffRight.g = (float)beatmapData["_colorRight"]["g"]; diffRight.b = (float)beatmapData["_colorRight"]["b"]; } } if (beatmapData.ContainsKey("_warnings")) { diffWarnings.AddRange(((JArray)beatmapData["_warnings"]).Select(c => (string)c)); } if (beatmapData.ContainsKey("_information")) { diffInfo.AddRange(((JArray)beatmapData["_information"]).Select(c => (string)c)); } if (beatmapData.ContainsKey("_suggestions")) { diffSuggestions.AddRange(((JArray)beatmapData["_suggestions"]).Select(c => (string)c)); } if (beatmapData.ContainsKey("_requirements")) { diffRequirements.AddRange(((JArray)beatmapData["_requirements"]).Select(c => (string)c)); } } RequirementData diffReqData = new RequirementData { _requirements = diffRequirements.ToArray(), _suggestions = diffSuggestions.ToArray(), _information = diffInfo.ToArray(), _warnings = diffWarnings.ToArray() }; diffData.Add(new DifficultyData { _beatmapCharacteristicName = SetCharacteristic, _difficulty = diffDifficulty, _difficultyLabel = diffLabel, additionalDifficultyData = diffReqData, _colorLeft = diffLeft, _colorRight = diffRight }); } } _difficulties = diffData.ToArray(); } catch (Exception ex) { Utilities.Logging.Log($"Error in Level {songPath}: \n {ex}", IPA.Logging.Logger.Level.Error); } }
public MaterialTransparent(MapColor color) : base(color) { this.SetReplaceable(); }
public MaterialLiquid(MapColor par1MapColor) : base(par1MapColor) { SetGroundCover(); SetNoPushMobility(); }
public MaterialLiquid(MapColor color) : base(color) { this.SetReplaceable(); this.SetNoPushMobility(); }
public MaterialPortal(MapColor color) : base(color) { }
public Material(MapColor color) { this.MapColor = color; }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("Icon/Large", false, out subEle)) { if (LargeIcon == null) { LargeIcon = new SimpleSubrecord <String>(); } LargeIcon.ReadXML(subEle, master); } if (ele.TryPathTo("Icon/Small", false, out subEle)) { if (SmallIcon == null) { SmallIcon = new SimpleSubrecord <String>(); } SmallIcon.ReadXML(subEle, master); } if (ele.TryPathTo("MapColor", false, out subEle)) { if (MapColor == null) { MapColor = new SimpleSubrecord <Color>(); } MapColor.ReadXML(subEle, master); } if (ele.TryPathTo("Worldspace", false, out subEle)) { if (Worldspace == null) { Worldspace = new RecordReference(); } Worldspace.ReadXML(subEle, master); } if (ele.TryPathTo("Areas", false, out subEle)) { if (Areas == null) { Areas = new List <RegionArea>(); } foreach (XElement e in subEle.Elements()) { RegionArea tempRPLI = new RegionArea(); tempRPLI.ReadXML(e, master); Areas.Add(tempRPLI); } } if (ele.TryPathTo("DataEntries", false, out subEle)) { if (DataEntries == null) { DataEntries = new List <RegionDataEntry>(); } foreach (XElement e in subEle.Elements()) { RegionDataEntry tempRDAT = new RegionDataEntry(); tempRDAT.ReadXML(e, master); DataEntries.Add(tempRDAT); } } }
public MaterialPortal(MapColor par1MapColor) : base(par1MapColor) { }
public MaterialWeb(MapColor par1MapColor) : base(par1MapColor) { }
public ExtraSongData(string levelID, string songPath) { try { if (!File.Exists(Path.Combine(songPath, "info.dat"))) { return; } var infoText = File.ReadAllText(songPath + "/info.dat"); JObject info = JObject.Parse(infoText); JObject infoData; List <Contributor> levelContributors = new List <Contributor>(); //Check if song uses legacy value for full song One Saber mode if (info.TryGetValue("_customData", out var data)) { infoData = (JObject)data; if (infoData.TryGetValue("_contributors", out var contributors)) { levelContributors.AddRange(contributors.ToObject <Contributor[]>()); } if (infoData.TryGetValue("_customEnvironment", out var customEnvironment)) { _customEnvironmentName = (string)customEnvironment; } if (infoData.TryGetValue("_customEnvironmentHash", out var envHash)) { _customEnvironmentHash = (string)envHash; } if (infoData.TryGetValue("_defaultCharacteristic", out var defaultChar)) { _defaultCharacteristic = (string)defaultChar; } } contributors = levelContributors.ToArray(); var diffData = new List <DifficultyData>(); var diffSets = (JArray)info["_difficultyBeatmapSets"]; foreach (var diffSet in diffSets) { var setCharacteristic = (string)diffSet["_beatmapCharacteristicName"]; JArray diffBeatmaps = (JArray)diffSet["_difficultyBeatmaps"]; foreach (JObject diffBeatmap in diffBeatmaps) { var diffRequirements = new List <string>(); var diffSuggestions = new List <string>(); var diffWarnings = new List <string>(); var diffInfo = new List <string>(); var diffLabel = ""; MapColor?diffLeft = null; MapColor?diffRight = null; MapColor?diffEnvLeft = null; MapColor?diffEnvRight = null; MapColor?diffEnvLeftBoost = null; MapColor?diffEnvRightBoost = null; MapColor?diffObstacle = null; var diffDifficulty = Utils.ToEnum((string)diffBeatmap["_difficulty"], BeatmapDifficulty.Normal); if (diffBeatmap.TryGetValue("_customData", out var customData)) { JObject beatmapData = (JObject)customData; if (beatmapData.TryGetValue("_difficultyLabel", out var difficultyLabel)) { diffLabel = (string)difficultyLabel; } //Get difficulty json fields if (beatmapData.TryGetValue("_colorLeft", out var colorLeft)) { if (colorLeft.Children().Count() == 3) { diffLeft = new MapColor( (float)(colorLeft["r"] ?? 0), (float)(colorLeft["g"] ?? 0), (float)(colorLeft["b"] ?? 0)); } } if (beatmapData.TryGetValue("_colorRight", out var colorRight)) { if (colorRight.Children().Count() == 3) { diffRight = new MapColor( (float)(colorRight["r"] ?? 0), (float)(colorRight["g"] ?? 0), (float)(colorRight["b"] ?? 0)); } } if (beatmapData.TryGetValue("_envColorLeft", out var envColorLeft)) { if (envColorLeft.Children().Count() == 3) { diffEnvLeft = new MapColor( (float)(envColorLeft["r"] ?? 0), (float)(envColorLeft["g"] ?? 0), (float)(envColorLeft["b"] ?? 0)); } } if (beatmapData.TryGetValue("_envColorRight", out var envColorRight)) { if (envColorRight.Children().Count() == 3) { diffEnvRight = new MapColor( (float)(envColorRight["r"] ?? 0), (float)(envColorRight["g"] ?? 0), (float)(envColorRight["b"] ?? 0)); } } if (beatmapData.TryGetValue("_envColorLeftBoost", out var envColorLeftBoost)) { if (envColorLeftBoost.Children().Count() == 3) { diffEnvLeftBoost = new MapColor( (float)(envColorLeftBoost["r"] ?? 0), (float)(envColorLeftBoost["g"] ?? 0), (float)(envColorLeftBoost["b"] ?? 0)); } } if (beatmapData.TryGetValue("_envColorRightBoost", out var envColorRightBoost)) { if (envColorRightBoost.Children().Count() == 3) { diffEnvRightBoost = new MapColor( (float)(envColorRightBoost["r"] ?? 0), (float)(envColorRightBoost["g"] ?? 0), (float)(envColorRightBoost["b"] ?? 0)); } } if (beatmapData.TryGetValue("_obstacleColor", out var obColor)) { if (obColor.Children().Count() == 3) { diffObstacle = new MapColor( (float)(obColor["r"] ?? 0), (float)(obColor["g"] ?? 0), (float)(obColor["b"] ?? 0)); } } if (beatmapData.TryGetValue("_warnings", out var warnings)) { diffWarnings.AddRange(((JArray)warnings).Select(c => (string)c)); } if (beatmapData.TryGetValue("_information", out var information)) { diffInfo.AddRange(((JArray)information).Select(c => (string)c)); } if (beatmapData.TryGetValue("_suggestions", out var suggestions)) { diffSuggestions.AddRange(((JArray)suggestions).Select(c => (string)c)); } if (beatmapData.TryGetValue("_requirements", out var requirements)) { diffRequirements.AddRange(((JArray)requirements).Select(c => (string)c)); } } RequirementData diffReqData = new RequirementData { _requirements = diffRequirements.ToArray(), _suggestions = diffSuggestions.ToArray(), _information = diffInfo.ToArray(), _warnings = diffWarnings.ToArray() }; diffData.Add(new DifficultyData { _beatmapCharacteristicName = setCharacteristic, _difficulty = diffDifficulty, _difficultyLabel = diffLabel, additionalDifficultyData = diffReqData, _colorLeft = diffLeft, _colorRight = diffRight, _envColorLeft = diffEnvLeft, _envColorRight = diffEnvRight, _envColorLeftBoost = diffEnvLeftBoost, _envColorRightBoost = diffEnvRightBoost, _obstacleColor = diffObstacle }); } } _difficulties = diffData.ToArray(); } catch (Exception ex) { Logging.Logger.Error($"Error in Level {songPath}:"); Logging.Logger.Error(ex); } }