Exemple #1
0
        static void Main()
        {
            var firstLevelName = ConfigLoader.GetFirstMapLevelFromConfig();

            AllLevels = TextGameEngine.Map.MapBuilder.GetAllLevels().ToArray();

            var level = string.IsNullOrEmpty(firstLevelName) ? AllLevels.FirstOrDefault() : AllLevels.FirstOrDefault(f => f.Name.ToLower() == firstLevelName);

            if (level == null)
            {
                Console.WriteLine("No Levels Detected");
                return;
            }

            var map = level.Map;

            // from this point on player pos is here and not in map
            var playerPos = LocationHelper.GetFirstObjectFromMap <PlayerStartObject>(map);
            var player    = new Player((PlayerStartObject)map[playerPos.XAxis, playerPos.YAxis])
            {
                StartOb = (PlayerStartObject)map[playerPos.XAxis, playerPos.YAxis]
            };

            while (true)
            {
                var next = PlayGame(level, player);
                level = AllLevels.FirstOrDefault(f => string.Equals(f.Name, next, StringComparison.CurrentCultureIgnoreCase));
            }
        }