コード例 #1
0
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.A)) //Testing Map generator basic function
            {
                MapService.GenerateMap(3, 3, 1);

                Debug.Log(MapService.LogMap()); //This string should represent a 3x3 matrix only with 0, and 1s

                MapService.GenerateMap(5, 5, 2);

                Debug.Log(MapService.LogMap()); //This string should represent a 5x5 matrix with 0s,1s and 2s

                MapService.GenerateMap(10, 10, 3);

                Debug.Log(MapService.LogMap()); //This string should represent a 10x10 matrix with 0s,1s,2s and 3s
            }

            if (Input.GetKeyDown(KeyCode.S)) //Testing Smoothing with really large map
            {
                Debug.Log("Testing Smoothing with really large map!");

                MapService.GenerateMap(256, 128, 1);

                StartCoroutine(AutomataRoutine());
            }

            if (Input.GetKeyDown(KeyCode.D)) //Generate Mock Map
            {
                Debug.Log("Generate Mock Map!");

                var mock = new List <List <int> > {
                    new List <int> {
                        1, 1, 1, 1, 1
                    },
                    new List <int> {
                        1, 0, 0, 0, 1
                    },
                    new List <int> {
                        1, 0, 1, 0, 1
                    },
                    new List <int> {
                        1, 0, 0, 0, 1
                    },
                    new List <int> {
                        1, 1, 1, 1, 1
                    },
                    new List <int> {
                        1, 0, 0, 0, 1
                    },
                    new List <int> {
                        1, 0, 1, 0, 1
                    },
                    new List <int> {
                        1, 0, 0, 0, 1
                    },
                    new List <int> {
                        1, 1, 1, 1, 1
                    },
                    new List <int> {
                        1, 0, 0, 0, 1
                    },
                    new List <int> {
                        1, 0, 1, 0, 1
                    },
                    new List <int> {
                        1, 0, 0, 0, 1
                    },
                    new List <int> {
                        1, 1, 1, 1, 1
                    }
                };

                MapService = new MapService(mock);

                Debug.Log("Done!");
            }

            if (Input.GetKeyDown(KeyCode.F)) //Generate Usable Map
            {
                Debug.Log("Generate Usable Map!");
                MapService.GenerateMap(50, 50, 1);

                for (int i = 0; i < 3; i++)
                {
                    MapService.ApplyAutomata();
                }


                Debug.Log("Done!");
            }

            if (Input.GetKeyDown(KeyCode.G)) //Testing Regions
            {
                Debug.Log("Testing Regions!");

                MapService.FindRooms(0);

                Debug.Log("Done!");
            }

            if (Input.GetKeyDown(KeyCode.Q)) //Testing removing Islands
            {
                Debug.Log("Testing removing Islands!");
                MapService.ClearIslands();

                MapService.FindRooms(0);

                Debug.Log("Done!");
            }

            if (Input.GetKeyDown(KeyCode.W)) //Testing Connecting Rooms
            {
                Debug.Log("Testing Connecting Rooms!");
                MapService.FindRooms(0);

                MapService.ConnectRooms(0);

                Debug.Log("Done!");
            }

            if (Input.GetKeyDown(KeyCode.Space)) //Toggle RoomGizmo
            {
                Debug.Log("Done!");
                RoomGizmo = !RoomGizmo;
            }
        }