public PracticeReplacer(Th06Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = CharaParser.Parse(match.Groups[2].Value); var stage = StageParser.Parse(match.Groups[3].Value); if (level == Level.Extra) { return(match.ToString()); } if (stage == Stage.Extra) { return(match.ToString()); } var key = new CharaLevelPair(chara, level); if (parent.allScoreData.PracticeScores.ContainsKey(key)) { var scores = parent.allScoreData.PracticeScores[key]; return(scores.ContainsKey(stage) ? Utils.ToNumberString(scores[stage].HighScore) : "0"); } else { return("0"); } }); }
public CardReplacer(Th095Converter parent, bool hideUntriedCards) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var scene = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture); var type = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture); var key = new LevelScenePair(level, scene); if (!SpellCards.ContainsKey(key)) { return(match.ToString()); } if (hideUntriedCards) { var score = parent.allScoreData.Scores.Find( elem => (elem != null) && elem.LevelScene.Equals(key)); if (score == null) { return("??????????"); } } return((type == 1) ? SpellCards[key].Enemy.ToLongName() : SpellCards[key].Card); }); }
private void LoadLevel(String file) { World.Clear(); GoodCellList.Clear(); VirusList.Clear(); _level = _levelParser.Parse(Texture2D.FromStream(Game1.graphics.GraphicsDevice, new FileStream(file, FileMode.Open))); _wallList = _level.GetWalls(); foreach (var item in _level.GetFriendlies()) { GoodCellList.Add((GoodCell)item); } foreach (var item in _level.GetEnemies()) { VirusList.Add((Virus)item); } _objectList = _level.GetFriendlies(); _objectList.AddRange(_level.GetEnemies()); _player = _level.Player; }
public ScoreReplacer(Th09Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = CharaParser.Parse(match.Groups[2].Value); var rank = Utils.ToZeroBased( int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture)); var type = int.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture); var score = parent.allScoreData.Rankings[new CharaLevelPair(chara, level)][rank]; var date = string.Empty; switch (type) { case 1: // name return(Encoding.Default.GetString(score.Name).Split('\0')[0]); case 2: // score return(Utils.ToNumberString((score.Score * 10) + score.ContinueCount)); case 3: // date date = Encoding.Default.GetString(score.Date).Split('\0')[0]; return((date != "--/--") ? date : "--/--/--"); default: // unreachable return(match.ToString()); } }); }
public ClearReplacer(Th09Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = CharaParser.Parse(match.Groups[2].Value); var type = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture); var count = parent.allScoreData.PlayStatus.ClearCounts[chara].Counts[level]; if (type == 1) { return(Utils.ToNumberString(count)); } else { if (count > 0) { return("Cleared"); } else { var score = parent.allScoreData.Rankings[new CharaLevelPair(chara, level)][0]; var date = Encoding.Default.GetString(score.Date).TrimEnd('\0'); return((date != "--/--") ? "Not Cleared" : "-------"); } } }); }
public PracticeReplacer(Th10Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = (CharaWithTotal)CharaParser.Parse(match.Groups[2].Value); var stage = StageParser.Parse(match.Groups[3].Value); if (level == Level.Extra) { return(match.ToString()); } if (stage == Stage.Extra) { return(match.ToString()); } if (parent.allScoreData.ClearData.ContainsKey(chara)) { var key = new LevelStagePair(level, stage); var practices = parent.allScoreData.ClearData[chara].Practices; return(practices.ContainsKey(key) ? Utils.ToNumberString(practices[key].Score * 10) : "0"); } else { return("0"); } }); }
public ClearReplacer(Th06Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = CharaParser.Parse(match.Groups[2].Value); var key = new CharaLevelPair(chara, level); if (parent.allScoreData.Rankings.ContainsKey(key)) { var stageProgress = parent.allScoreData.Rankings[key].Max(rank => rank.StageProgress); if (stageProgress == StageProgress.Extra) { return("Not Clear"); } else { return(stageProgress.ToShortName()); } } else { return(StageProgress.None.ToShortName()); } }); }
public ScoreReplacer(Th06Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = CharaParser.Parse(match.Groups[2].Value); var rank = Utils.ToZeroBased( int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture)); var type = int.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture); var key = new CharaLevelPair(chara, level); var score = parent.allScoreData.Rankings.ContainsKey(key) ? parent.allScoreData.Rankings[key][rank] : InitialRanking[rank]; switch (type) { case 1: // name return(Encoding.Default.GetString(score.Name).Split('\0')[0]); case 2: // score return(Utils.ToNumberString(score.Score)); case 3: // stage return(score.StageProgress.ToShortName()); default: // unreachable return(match.ToString()); } }); }
public void TestParse6() { var parser = new LevelParser(); int length; parser.Parse("FATAL", 0, out length).Should().Be(LevelFlags.Fatal); length.Should().Be(5); }
public void TestParse5() { var parser = new LevelParser(); int length; parser.Parse("ERROR", 0, out length).Should().Be(LevelFlags.Error); length.Should().Be(5); }
public void TestParse4() { var parser = new LevelParser(); int length; parser.Parse("WARNING", 0, out length).Should().Be(LevelFlags.Warning); length.Should().Be(7); }
public void TestParse3() { var parser = new LevelParser(); int length; parser.Parse("DEBUG INFO", 6, out length).Should().Be(LevelFlags.Info); length.Should().Be(4); }
public void TestParse2() { var parser = new LevelParser(); int length; parser.Parse("DEBUG", 0, out length).Should().Be(LevelFlags.Debug); length.Should().Be(5); }
public void TestParse1() { var parser = new LevelParser(); int length; parser.Parse("TRACE", 0, out length).Should().Be(LevelFlags.Trace); length.Should().Be(5); }
public ScoreReplacer(Th10Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = (CharaWithTotal)CharaParser.Parse(match.Groups[2].Value); var rank = Utils.ToZeroBased( int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture)); var type = int.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture); var ranking = parent.allScoreData.ClearData[chara].Rankings[level][rank]; switch (type) { case 1: // name return(Encoding.Default.GetString(ranking.Name).Split('\0')[0]); case 2: // score return(Utils.ToNumberString((ranking.Score * 10) + ranking.ContinueCount)); case 3: // stage if (ranking.DateTime > 0) { return((ranking.StageProgress == StageProgress.Extra) ? "Not Clear" : ranking.StageProgress.ToShortName()); } else { return(StageProgress.None.ToShortName()); } case 4: // date & time if (ranking.DateTime > 0) { return(new DateTime(1970, 1, 1).AddSeconds(ranking.DateTime).ToLocalTime() .ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.CurrentCulture)); } else { return("----/--/-- --:--:--"); } case 5: // slow if (ranking.DateTime > 0) { return(Utils.Format("{0:F3}%", ranking.SlowRate)); } else { return("-----%"); } default: // unreachable return(match.ToString()); } }); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); Bound = new Texture2D(GraphicsDevice, 1, 1); _controller = new GameController(this); TileFactory.Instance.LoadSheet(Content); AvatarFactory.Instance.LoadSheet(Content); World = LevelParser.Parse(this, "./Content/level.json"); }
public override LevelBlueprint Process(LevelPackage input, ContentProcessorContext context) { var parser = new LevelParser(input.Content, x => input.Includes.FirstOrDefault(p => LevelBlueprint.IsIncludeMatch(p.Key, x)).Value); var lf = parser.Parse(); BlueprintPreprocessor.ProcessLevel(lf); Console.WriteLine("Parsing file with " + lf.BlueprintCannons.Count + " cannon definitions"); Console.WriteLine("Parsing file with " + lf.BlueprintVoidWalls.Count + " voidwall definitions"); return(lf); }
public static LevelBlueprint ParseLevelFromString(string text, Func <string, string> includesFunc, bool sim) { var fp = new LevelParser(text, includesFunc); var lf = fp.Parse(); LastParsedIncludedSources = fp.IncludedSources; if (sim) { BlueprintPreprocessor.ProcessLevel(lf); } return(lf); }
public ClearReplacer(Th10Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = (CharaWithTotal)CharaParser.Parse(match.Groups[2].Value); var rankings = parent.allScoreData.ClearData[chara].Rankings[level] .Where(ranking => ranking.DateTime > 0); var stageProgress = (rankings.Count() > 0) ? rankings.Max(ranking => ranking.StageProgress) : StageProgress.None; return((stageProgress == StageProgress.Extra) ? "Not Clear" : stageProgress.ToShortName()); }); }
public static LevelBlueprint ParseLevelFromFile(string path, bool sim) { var folder = Path.GetDirectoryName(path) ?? ""; var includes = Directory.EnumerateFiles(folder, "*.gsheader").ToDictionary(p => Path.GetFileName(p) ?? p, p => File.ReadAllText(p, Encoding.UTF8)); Func <string, string> includesFunc = x => includes.FirstOrDefault(p => LevelBlueprint.IsIncludeMatch(p.Key, x)).Value; var fp = new LevelParser(File.ReadAllText(path), includesFunc); var lf = fp.Parse(Path.GetFileName(path)); LastParsedIncludedSources = fp.IncludedSources; if (sim) { BlueprintPreprocessor.ProcessLevel(lf); } return(lf); }
void Awake() { tileMap = levelParser.Parse(pelletTransforms, boxTiles); rows = levelParser.Rows; cols = levelParser.Cols; boxDoorEntranceCoordinates = levelParser.BoxDoorEntranceCoordinates; tileMapHalfWidth = levelParser.TileMapHalfWidth; entitiesTargetTileCoordinates = new Dictionary <EntityId, Vector2Int>(); var entityIds = (EntityId[])Enum.GetValues(typeof(EntityId)); foreach (var entityId in entityIds) { entitiesTargetTileCoordinates.Add(entityId, Vector2Int.zero); } InitializeEntitiesProperties(); }
public ClearRankReplacer(Th155Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = StoryCharaParser.Parse(match.Groups[2].Value); LevelFlag toLevelFlag(Level lv) { switch (lv) { case Level.Easy: return(LevelFlag.Easy); case Level.Normal: return(LevelFlag.Normal); case Level.Hard: return(LevelFlag.Hard); case Level.Lunatic: return(LevelFlag.Lunatic); case Level.OverDrive: return(LevelFlag.OverDrive); default: return(LevelFlag.None); } } if (parent.allScoreData.StoryDictionary.TryGetValue(chara, out AllScoreData.Story story) && story.available && ((story.ed & toLevelFlag(level)) != LevelFlag.None)) { return("Clear"); } else { return("Not Clear"); } }); }
public ClearReplacer(Th135Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = CharaParser.Parse(match.Groups[2].Value); var cleared = false; var flags = LevelFlag.None; if (parent.allScoreData.StoryClearFlags.TryGetValue((Chara)chara, out flags)) { switch (level) { case Level.Easy: cleared = (flags & LevelFlag.Easy) == LevelFlag.Easy; break; case Level.Normal: cleared = (flags & LevelFlag.Normal) == LevelFlag.Normal; break; case Level.Hard: cleared = (flags & LevelFlag.Hard) == LevelFlag.Hard; break; case Level.Lunatic: cleared = (flags & LevelFlag.Lunatic) == LevelFlag.Lunatic; break; default: // unreachable break; } } return(cleared ? "Clear" : "Not Clear"); }); }
public ShotReplacer(Th095Converter parent, string outputFilePath) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var scene = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture); var key = new LevelScenePair(level, scene); if (!SpellCards.ContainsKey(key)) { return(match.ToString()); } BestShotPair bestshot; if (!string.IsNullOrEmpty(outputFilePath) && parent.bestshots.TryGetValue(key, out bestshot)) { var relativePath = new Uri(outputFilePath) .MakeRelativeUri(new Uri(bestshot.Path)).OriginalString; var alternativeString = Utils.Format( "ClearData: {0}{3}Slow: {1:F6}%{3}SpellName: {2}", Utils.ToNumberString(bestshot.Header.Score), bestshot.Header.SlowRate, Encoding.Default.GetString(bestshot.Header.CardName).TrimEnd('\0'), Environment.NewLine); return(Utils.Format( "<img src=\"{0}\" alt=\"{1}\" title=\"{1}\" border=0>", relativePath, alternativeString)); } else { return(string.Empty); } }); }
public ClearRankReplacer(Th145Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var chara = CharaParser.Parse(match.Groups[2].Value); // FIXME switch (parent.allScoreData.ClearRanks[level][chara]) { case 1: return("Bronze"); case 2: return("Silver"); case 3: return("Gold"); default: return("Not Clear"); } }); }
public ScoreReplacer(Th095Converter parent) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var scene = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture); var type = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture); var key = new LevelScenePair(level, scene); if (!SpellCards.ContainsKey(key)) { return(match.ToString()); } var score = parent.allScoreData.Scores.Find( elem => (elem != null) && elem.LevelScene.Equals(key)); switch (type) { case 1: // high score return((score != null) ? Utils.ToNumberString(score.HighScore) : "0"); case 2: // bestshot score return((score != null) ? Utils.ToNumberString(score.BestshotScore) : "0"); case 3: // num of shots return((score != null) ? Utils.ToNumberString(score.TrialCount) : "0"); case 4: // slow rate return((score != null) ? Utils.Format("{0:F3}%", score.SlowRate2) : "-----%"); default: // unreachable return(match.ToString()); } }); }
public ShotExReplacer(Th095Converter parent, string outputFilePath) { this.evaluator = new MatchEvaluator(match => { var level = LevelParser.Parse(match.Groups[1].Value); var scene = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture); var type = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture); var key = new LevelScenePair(level, scene); if (!SpellCards.ContainsKey(key)) { return(match.ToString()); } BestShotPair bestshot; if (!string.IsNullOrEmpty(outputFilePath) && parent.bestshots.TryGetValue(key, out bestshot)) { switch (type) { case 1: // relative path to the bestshot file return(new Uri(outputFilePath) .MakeRelativeUri(new Uri(bestshot.Path)).OriginalString); case 2: // width return(bestshot.Header.Width.ToString(CultureInfo.InvariantCulture)); case 3: // height return(bestshot.Header.Height.ToString(CultureInfo.InvariantCulture)); case 4: // score return(Utils.ToNumberString(bestshot.Header.Score)); case 5: // slow rate return(Utils.Format("{0:F6}%", bestshot.Header.SlowRate)); case 6: // date & time { var score = parent.allScoreData.Scores.Find( elem => (elem != null) && elem.LevelScene.Equals(key)); if (score != null) { return(new DateTime(1970, 1, 1) .AddSeconds(score.DateTime).ToLocalTime() .ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.CurrentCulture)); } else { return("----/--/-- --:--:--"); } } default: // unreachable return(match.ToString()); } } else { switch (type) { case 1: return(string.Empty); case 2: return("0"); case 3: return("0"); case 4: return("--------"); case 5: return("-----%"); case 6: return("----/--/-- --:--:--"); default: return(match.ToString()); } } }); }
public GameFieldModel(string[] rows) { tiles = LevelParser.Parse(rows); }