Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MazeCreator{
- MazeMatrixS maze;
- //private uint animHandler;
- private int step;
- void Start() {
- createMaze();
- }
- private void createMaze() {
- maze = new MazeMatrixS.MazeMatrix(/*widthSlider.value*/10, /*heightSlider.value*/10, 0, 0, true);
- // Clear animation timer if runned
- /*if (animHandler) clearInterval(animHandler);
- if (animCb.selected)
- {
- // Set animation timer
- animHandler = setInterval(drawStep, 5);
- }
- else
- {*/
- step = 0;
- redrawMaze();
- //}
- }
- /*private void drawStep() {
- int i = Mathf.Pow(animSpeedSlider.value, 2);
- while (--i && maze.doStep()) {}
- if (!maze.doStep())
- {
- clearInterval(animHandler);
- animHandler = 0;
- }
- redrawMaze();
- }*/
- private void redrawMaze(/*UIComponent view = null*/) {
- float lineThick = /*thicknessSlider.value*/2;
- float startX = lineThick / 2;
- float startY = lineThick / 2;
- int cellW = /*sizeSlider.value*/20;
- int cellH = /*sizeSlider.value*/20;
- int cData;
- //if (!view) view = mazeView;
- //view.setStyle('borderWeight', lineThick);
- //view.graphics.clear();
- //view.width = cellW * maze.width + lineThick;
- //view.height = cellH * maze.height + lineThick;
- //with (view.graphics)
- {
- for (int cx = 0; cx < maze.width; ++cx)
- {
- for (int cy = 0; cy < maze.height; ++cy)
- {
- cData = maze.getCell(cx, cy);
- //lineStyle(lineThick, (cData & MazeMatrix.CELL_VISITED) ? 0x000000 : 0xCCCCCC); ???
- if ((cy > 0) && (cData>0 & MazeMatrixS.WALL_TOP>0)) {
- Debug.DrawLine(new Vector3(startX + cx * cellW, startY + cy * cellH, 0), new Vector3(startX + cx * cellW + cellW, startY + cy * cellH, 0));
- /*moveTo(startX + cx * cellW, startY + cy * cellH);
- lineTo(startX + cx * cellW + cellW, startY + cy * cellH);*/
- }
- if ((cx > 0) && (cData>0 & MazeMatrixS.WALL_LEFT>0)) {
- Debug.DrawLine(new Vector3(startX + cx * cellW, startY + cy * cellH, 0), new Vector3(startX + cx * cellW, startY + cy * cellH + cellH, 0));
- /*moveTo(startX + cx * cellW, startY + cy * cellH);
- lineTo(startX + cx * cellW, startY + cy * cellH + cellH);*/
- }
- }
- }
- // Display routre stack
- /*for (int i = 0; i < maze.activeRoute.length; ++i)
- {
- MazeIndex p = maze.activeRoute[i];
- lineStyle();
- beginFill(0xFF9999, 1);
- drawRect(startX + p.x * cellW + cellW/4, startY + p.y * cellH + cellH/4, cellW/2, cellH/2);
- endFill();
- }*/
- /*// Draw start position
- lineStyle();
- beginFill(0x55FF11, 1);
- drawCircle(startX + maze.startX * cellW + cellW / 2, startY + maze.startY * cellH + cellH / 2, cellW / 2.5);
- endFill();
- // Draw finish position
- lineStyle();
- beginFill(0xFF6611, 1);
- drawRect(startX + maze.finishX * cellW + 2, startY + maze.finishY * cellH + 2, cellW - 4, cellH - 4);
- endFill();*/
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement