Esempio n. 1
0
    public static IEnumerator move(List <MazeNode> Path)
    {
        GamePlay.counterUp();
        GamePlay.scoreUp(10);
        GamePlay.updateCounters();
        MazeBuilder.ClearMaze();
        int x = Path[Path.Count - 1].x;
        int y = Path[Path.Count - 1].y;

        ColorPallet.CallRecolor();
        while (Path.Count > 1)
        {
            Vector3 last  = new Vector3(Path[0].x, Path[0].y, 0) * 10;
            Vector3 next  = new Vector3(Path[1].x, Path[1].y, 0) * 10;
            float   tween = 0;
            while (Vector3.Distance(motionControl.tr.position, next) > 0.5f)
            {
                motionControl.tr.position = Vector3.Lerp(last, next, tween);
                tween += Time.deltaTime * motionControl.s;
                yield return(new WaitForEndOfFrame());
            }
            Path.RemoveAt(0);
        }
        SaveData.saveMove(new MazeNodeData(x, y), GamePlay.getCounter(), GamePlay.getScore());
        MazeBuilder.SetClickZone(x, y);
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     willem     = GetComponent <AudioSource>();
     agent      = GetComponent <NavMeshAgent>();
     builder    = GameObject.Find("MazeBuilder").GetComponent <MazeBuilder>();
     m_animator = GetComponent <Animator>();
 }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUILayout.Space(20);

        serializedObject.Update();

        MazeView view = target as MazeView;

        EditorGUI.BeginChangeCheck();
        width     = EditorGUILayout.IntSlider("Width", width, 0, 20);
        height    = EditorGUILayout.IntSlider("Height", height, 0, 20);
        wallCount = EditorGUILayout.IntSlider("Number of walls", wallCount, 0, (width - 1) * (height - 1));

        if (GUILayout.Button("Generate Maze") || EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(target, $"Generate Maze");

            MazeBuilder builder = new MazeBuilder();
            builder.mazeWidth  = width;
            builder.mazeHeight = height;
            builder.wallCount  = wallCount;
            view.maze          = builder.Build();
        }

        if (GUILayout.Button("Clear Maze"))
        {
            Undo.RecordObject(target, $"Clear Maze");

            view.maze = null;
        }

        serializedObject.ApplyModifiedProperties();
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        int monsterCount = UnityEngine.Random.Range(minMonsterCount, maxMonsterCount);

        mazeBuilder = GetComponent <MazeBuilder>();
        PlaceMonsters(mazeBuilder.Maze, monsterCount);
    }
Esempio n. 5
0
    // Use this for initialization
    void Start()
    {
        maze        = FindObjectOfType <MazeBuilder>();
        rb          = GetComponent <Rigidbody2D>();
        player      = FindObjectOfType <PlayerController>();
        aStar       = FindObjectOfType <AStar>();
        animator    = GetComponent <Animator>();
        theCollider = GetComponent <BoxCollider2D>();

        foreach (Score s in FindObjectsOfType <Score>())
        {
            if (s.gameObject.name == "Score")
            {
                score = s;
            }
        }
        if (!score)
        {
            throw new UnityException("Score object not found");
        }

        ResetEnemy();
        if (gsm.recordThisGame)
        {
            recorder.RecordIfRecording(recorder.CreateCommand(gameObject));
        }
    }
Esempio n. 6
0
        private static async Task CreateMazeImageAndGif(IMazeGenAlgorithm i)
        {
            MazeBuilder mazeBuilder = new MazeBuilder();
            TileMapMaze drawMaze    = new TileMapMaze(60, 60);

            drawMaze.OverrideAllMazeFields();
            var maze = mazeBuilder
                       .SetMazeAlgorithm(i)
                       .SetDrawCallback(m =>
            {
                if (i is RecursiveDivision)
                {
                    //drawMaze.TransformMaze(m);
                    //MazeImageCreator.CreateMazeImage(drawMaze, i.GetName(), 10, "./");
                }
            })
                       .RecordMazeTransformationSteps(true)
                       .SetMazeDimensions(60, 60)
                       .Build();

            await MazeImageCreator.CreateMazeAnimationGifAsync(mazeBuilder.GetMazeTransformationSteps(), drawMaze, i.GetName(), 5).ConfigureAwait(false);

            MazeImageCreator.CreateMazeImage(maze, i.GetName(), 5, "./");

            Console.WriteLine($"Finished maze image and gif creation for algorithm={i.GetName()}.");
        }
Esempio n. 7
0
 // Update is called once per frame
 void Update()
 {
     if (!theCollider)
     {
         theCollider = GetComponent <BoxCollider2D>();
     }
     if (!rb)
     {
         rb = GetComponent <Rigidbody2D>();
     }
     if (!maze)
     {
         maze = FindObjectOfType <MazeBuilder>();
     }
     if (!aStar)
     {
         aStar = FindObjectOfType <AStar>();
         if (aStar)
         {
             BuildPathsFromMaze(ref aStar);
         }
     }
     if (maze && aStar && gsm.state == GameStateManager.State.GAME_MODE_PLAY && gsm.framesInState > 7)
     {
         int dx, dy;
         GetInput(out dx, out dy);
         Move(dx, dy);
     }
 }
Esempio n. 8
0
        public void TestMethod2()
        {
            var m = new MazeBuilder(16, 16);

            m.CreateMazeWithOnePath();
            PrintMaze(m);
        }
    private MazeBlueprint GenerateBlueprint()
    {
        /* Define your maze here ! */

        var mazeHeight = tileMapDrawerConfig.mapSize.y;
        var mazeWidth  = tileMapDrawerConfig.mapSize.x;

        var mazeBuilder = new MazeBuilder();

        mazeBuilder.generateMaze(mazeHeight, mazeWidth);

        mazeBuilder.addHallDigger(mazeDiggerConfig.nHallDigger);
        mazeBuilder.addEdgeDigger(mazeDiggerConfig.nEdgeDigger);
        mazeBuilder.addPathDigger(mazeDiggerConfig.nPathDigger);

        mazeBuilder.runHallDigger(mazeDiggerConfig.hallPercent);
        mazeBuilder.runEdgeDigger(mazeDiggerConfig.edgePercent);
        mazeBuilder.runPathDigger(mazeDiggerConfig.pathPercent);

        mazeBuilder.expandMaze(2);
        this.tileMapDrawerConfig.mapSize *= 2;

        mazeBuilder.GenerateBluePrint();
        return(mazeBuilder.checkoutBlueprint());
    }
Esempio n. 10
0
 public void PrintMaze(MazeBuilder m)
 {
     for (int x = 0; x < m.x; x++)
     {
         for (int y = 0; y < m.y; y++)
         {
             char c = (char)(m.nodes[x, y].group + (int)'a');
             Console.Write(c);
             if (y < m.y - 1)
             {
                 var n1 = m.nodes[x, y];
                 var n2 = m.nodes[x, y + 1];
                 Console.Write(m.HasEdge(n1, n2) ? '-' : ' ');
             }
         }
         Console.WriteLine();
         for (int y = 0; y < m.y; y++)
         {
             if (x < m.x - 1)
             {
                 var n1 = m.nodes[x, y];
                 var n2 = m.nodes[x + 1, y];
                 Console.Write(m.HasEdge(n1, n2) ? "| " : "  ");
             }
         }
         Console.WriteLine();
     }
 }
Esempio n. 11
0
 public Maze CreateMaze(MazeBuilder builder)
 {
     builder.BuildMaze();
     builder.BuildRoom(1);
     builder.BuildRoom(2);
     builder.BuildDoor(1, 2);
     return(builder.GetMaze());
 }
Esempio n. 12
0
        public void TestMethod1()
        {
            var m = new MazeBuilder(2, 2);

            m.AddEdge(m.nodes[0, 0], m.nodes[0, 1]);
            m.AddEdge(m.nodes[0, 1], m.nodes[1, 1]);
            PrintMaze(m);
        }
Esempio n. 13
0
 void Start()
 {
     holder      = new GameObject();
     holder.name = "Chests";
     mazeBuilder = GetComponent <MazeBuilder>();
     chestCount  = Random.Range(minChestCount, maxChestCount);
     PlaceChests();
 }
        public void ShouldReturnCorrectNeighborOnSide()
        {
            MazeBuilder builder = new MazeBuilder(3, 3);

            List <MazeSlot> neighbor = builder.GetNeighbor(builder.Maze[2, 1]);

            Assert.Equal(3, neighbor.Count);
        }
        /// <summary>
        /// 迷宮を生成
        /// </summary>
        /// <returns></returns>
        private Maze.Maze ConstructMaze()
        {
            var builder  = new MazeBuilder();
            var options  = new MazeBuildOptions(_floorSettings.Width, _floorSettings.Height, DecorationState.Labyrinth);
            var director = new MazeDirector(builder, options);

            return(director.Construct());
        }
Esempio n. 16
0
 public Maze CreateMze(MazeBuilder builder)
 {
     builder.BuildMaze();
     builder.BuildRoom(1);
     builder.BuildRoom(2);
     builder.BuildDoor(1, 2);
     return builder.GetMaze();
 }
Esempio n. 17
0
        public void TestAreAdjacentEdges()
        {
            var m = new MazeBuilder(2, 2);

            Assert.IsTrue(m.AreAdjacentEdges(m.nodes[0, 0], m.nodes[0, 1]));
            Assert.IsTrue(m.AreAdjacentEdges(m.nodes[0, 0], m.nodes[1, 0]));
            Assert.IsFalse(m.AreAdjacentEdges(m.nodes[0, 0], m.nodes[1, 1]));
        }
Esempio n. 18
0
        public void TestHasEdge2()
        {
            var m  = new MazeBuilder(2, 2);
            var n1 = m.nodes[0, 0];
            var n3 = m.nodes[1, 1];

            m.AddEdge(n1, n3);
        }
Esempio n. 19
0
        public Maze CreateMaze(MazeBuilder mazeBuilder)
        {
            mazeBuilder.BuildMaze();
            mazeBuilder.BuildRoom(1);
            mazeBuilder.BuildRoom(2);
            mazeBuilder.BuildDoor(1, 2);

            return(mazeBuilder.GetMaze());
        }
Esempio n. 20
0
        public Maze CreateComplexMaze(MazeBuilder builder)
        {
            builder.BuildRoom(1);
            builder.BuildRoom(2);
            builder.BuildRoom(3);
            builder.BuildRoom(4);

            return(builder.GetMaze());
        }
Esempio n. 21
0
 private void Awake()
 {
     mazeBuilderRandom  = new MazeBuilderRandom(this);
     mazebuilderPerlin  = new MazeBuilderPerlin(this);
     mazebuilderPerlin2 = new MazeBuilderPerlin2(this);
     mazebuilderCells   = new MazeBuilderCells(this);
     mazebuilderDepth   = new MazeBuilderDepth(this);
     mazeBuilderKruskal = new MazeBuilderKruskal(this);
     mazeBuilderPrims   = new MazeBuilderPrims(this);
 }
Esempio n. 22
0
        public void Correctly_Converts_Coordinates_To_Index()
        {
            var config    = new MazeConfiguration(4, 3);
            var generator = new MazeBuilder(config);

            Assert.AreEqual(0, generator.ConvertCoordinatesToIndex(new Coordinates(0, 0)));
            Assert.AreEqual(6, generator.ConvertCoordinatesToIndex(new Coordinates(2, 1)));
            Assert.AreEqual(9, generator.ConvertCoordinatesToIndex(new Coordinates(1, 2)));
            Assert.AreEqual(11, generator.ConvertCoordinatesToIndex(new Coordinates(3, 2)));
        }
Esempio n. 23
0
        public void Correctly_Determines_Direction()
        {
            var config    = new MazeConfiguration(4, 3);
            var generator = new MazeBuilder(config);

            Assert.AreEqual(Direction.Up, generator.DetermineDirection(new Coordinates(1, 1), new Coordinates(1, 0)));
            Assert.AreEqual(Direction.Right, generator.DetermineDirection(new Coordinates(1, 1), new Coordinates(2, 1)));
            Assert.AreEqual(Direction.Down, generator.DetermineDirection(new Coordinates(1, 1), new Coordinates(1, 2)));
            Assert.AreEqual(Direction.Left, generator.DetermineDirection(new Coordinates(1, 1), new Coordinates(0, 1)));
        }
Esempio n. 24
0
        public void Correctly_Converts_Index_To_Coordinates()
        {
            var config    = new MazeConfiguration(4, 3);
            var generator = new MazeBuilder(config);

            Assert.AreEqual(new Coordinates(0, 0), generator.ConvertIndexToCoordinates(0));
            Assert.AreEqual(new Coordinates(2, 1), generator.ConvertIndexToCoordinates(6));
            Assert.AreEqual(new Coordinates(1, 2), generator.ConvertIndexToCoordinates(9));
            Assert.AreEqual(new Coordinates(3, 2), generator.ConvertIndexToCoordinates(11));
        }
Esempio n. 25
0
    private void Awake()
    {
        CreatePersistentObjects();

        GameObject.FindWithTag("MusicPlayer").GetComponent <MusicPlayerScript>().StartBattleMusic();
        GameObject.FindWithTag("ScoreHolder").GetComponent <ScoreHolderScript>().ResetScore();

        player      = GameObject.FindWithTag("Player");
        mazeBuilder = GetComponent <MazeBuilder>();
    }
 private void InitMaze()
 {
     if (generateMazeOnStart)
     {
         MazeBuilder builder = new MazeBuilder();
         builder.mazeWidth  = mazeWidth;
         builder.mazeHeight = mazeHeight;
         builder.wallCount  = numberOfWalls;
         mazeView.maze      = builder.Build();
     }
 }
Esempio n. 27
0
        internal void Build(int level, bool connectTunnels = true)
        {
            var roomBuilder = new RoomBuilder(_randomNumberGenerator, _logger, _registry);
            var mazeBuilder = new MazeBuilder(_randomNumberGenerator, roomBuilder, _mazeDescriptor, _logger, _registry);

            var maze = connectTunnels ?
                       mazeBuilder.BuildMaze(level) :
                       mazeBuilder.BuildMazeWithRoomsAndDoors(level);

            Compact(maze, level);
        }
Esempio n. 28
0
        public void TestPerformanceOnlyMaze_WithPrimAndSize100x100_DoesNotThrow()
        {
            MazeBuilder mazeBuilder = new MazeBuilder()
                                      .RecordMazeTransformationSteps(false)
                                      .SetMazeAlgorithm(new RandomizedPrims())
                                      .SetMazeDimensions(100, 100);

            double median = MedianPerfTest(mazeBuilder, 5);

            Log.Logger.Information($"Randomized Prims with RecordTransformationSteps==false Elapsed={TimeSpan.FromTicks(((long)median))}");
        }
Esempio n. 29
0
        public void SetUp()
        {
            var width  = 4;
            var height = 4;

            var builder  = new MazeBuilder();
            var options  = new MazeBuildOptions(width, height, DecorationState.Labyrinth);
            var director = new MazeDirector(builder, options);

            _maze = director.Construct();
        }
Esempio n. 30
0
        public void PlayerControl_DirectionPassedInIsNull_Fails()
        {
            DatabaseListRetrieval.InitializeList();
            MazeBuilder mazeBuilder = new MazeBuilder();
            Maze        playerMaze  = mazeBuilder
                                      .SetRows(5)
                                      .SetColumns(5)
                                      .Build();

            PlayerControl.MovementAttempt(playerMaze, "");
        }
Esempio n. 31
0
        public void PlayerControl_MovementAttemptGetsGoodInput_Success()
        {
            DatabaseListRetrieval.InitializeList();
            MazeBuilder mazeBuilder = new MazeBuilder();
            Maze        playerMaze  = mazeBuilder
                                      .SetRows(5)
                                      .SetColumns(5)
                                      .Build();

            PlayerControl.MovementAttempt(playerMaze, "N");
        }
Esempio n. 32
0
    void Awake()
    {
        mazeBuilder = transform.GetComponent<MazeBuilder>();

        KeyList = new List<Key>();
        DoorList = new List<Door>();
        PortalList = new List<Portal>();
    }