コード例 #1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
コード例 #2
0
        public void TestMazeDistancesFix()
        {
            Trace.AutoFlush = true;
            IMazeGenerator generator = new RecursiveBacktracker4(227);

            const int width = 10;
            const int height = 5;

            Maze4 maze = new Maze4(generator);
            maze.GenerateNew(width, height);

            Trace.WriteLine("Labyrinth:");
            Trace.WriteLine(maze.RenderToString());

            Trace.WriteLine(Environment.NewLine + "Ermittle Distanzen ...");
            int[,] distances;
            IList<Tuple<int, IRoom4>> remoteRooms = maze.SetStartingPoint(0, 0, out distances);

            if (remoteRooms.Count > 0)
            {
                Trace.WriteLine(Environment.NewLine + "Sackgassen:");
                foreach (var room in remoteRooms)
                {
                    var position = maze.GetPosition(room.Item2);
                    Trace.WriteLine("  + " + position.Item1 + "," + position.Item2 + " (Distanz: " + room.Item1 + ")");
                }

                Trace.WriteLine(Environment.NewLine + "Distanzkarte:");
                PrintDistanceMap(distances, remoteRooms);
            }
            else
            {
                Trace.Fail("Keine Sackgassen ermittelt.");
            }
        }