示例#1
0
        public void AddStep(Step step)
        {
            var lastStep = Steps.LastOrDefault();

            if (lastStep != null)
            {
                for (var idx = 0; idx < lastStep.Tiles.Count; idx++)
                {
                    lastStep.Tiles[idx].South = step.Tiles[idx];
                    step.Tiles[idx].North = lastStep.Tiles[idx];
                }
            }

            step.Map = this;
            Steps.Add(step);
        }
        private static Map ReadMap(string fileName)
        {
            var mapPath = Path.Combine(Environment.CurrentDirectory, fileName);

            var map = new Map();

            var content = File.ReadLines(mapPath);
            var contentInfo = content
                .Skip(1)
                .ToArray();

            for (var idx = 0; idx < contentInfo.Length; idx++)
            {
                var arr = contentInfo[idx]
                    .Split(' ')
                    .Select(int.Parse)
                    .ToArray();

                var step = new Step();

                foreach (var val in arr)
                {
                    step.AddTile(new Tile {Elevation = val});
                }

                map.AddStep(step);
            }

            return map;
        }