/// <summary> /// Loads settings, initializes poolers and scene entities. /// </summary> /// <param name="config">Configuration</param> public WormScene(Settings config, Game game) { #if DEBUG visualizeCollision = config.visualizeCollision; #endif updateInterval = 1.0f / config.refreshRate; AddGraphic(config.surface); AddGraphic(config.tilemap); collision = config.collision; spawnFruits = config.spawnFruits; fruitAmount = config.fruitAmount; minWormLength = config.minWormLength; step = config.step; wormCap = config.wormCap; size = config.size; width = config.width; height = config.height; windowWidth = config.windowWidth; windowHeight = config.windowHeight; // Config load end currentStep = config.size - config.step; CreateBorders(config.width, config.height, Colors.foreground); worms = new Worms(config, this); players = new Players(config, this); fruits = new Fruits(config); blocks = new Blocks(config, game, this); Start(); }
static void InsertTeamWormsScore(Dictionary <string, List <Worms> > result) { while (true) { string readLine = Console.ReadLine(); if (readLine.Equals("quit")) { break; } Match regex = Regex.Match(readLine, @"(?<worm>.+) -> (?<team>.+) -> (?<score>\d+)"); string worm = regex.Groups["worm"].Value; bool hasWorms = true; foreach (var kvp in result) { foreach (var w in kvp.Value) { if (w.WormName == worm) { hasWorms = false; } } } if (hasWorms) { string team = regex.Groups["team"].Value; long score = long.Parse(regex.Groups["score"].Value); if (!result.ContainsKey(team)) { result.Add(team, new List <Worms>()); } Worms newWorm = new Worms() { WormName = worm, WormScore = score }; result[team].Add(newWorm); } } }