public void SpawnChunksAroundPoint(Vector3 point) { SpawnChunkFeild(); Loom.QueueAsyncTask(WorldThreadName, () => { MazeGen module = new MazeGen(VoxelSettings.SuperSizeX / 2, 4, VoxelSettings.SuperSizeZ / 2, VoxelSettings.seed, 2, 1); for (int x = -1; x <= VoxelSettings.maxChunksX; x++) { for (int z = -1; z <= VoxelSettings.maxChunksZ; z++) { Vector3Int location3D = new Vector3Int(x, 0, z); Vector2Int location2D = new Vector2Int(location3D.x, location3D.z); try { if (Chunks.ContainsKey(location3D) && !Chunks[location3D].Generated) { float[,] surface = Chunks[location3D].GenerateChunk(module); Chunks[location3D].Render(false); } } catch (Exception e) { SafeDebug.LogException(e); } } } SafeDebug.Log("Finished rendering."); Loom.QueueOnMainThread(() => { //MapTexture = module.GetTexture(); }); }); }
void Awake() { instance = this; exitSide = (rnd.Next(2) % 2 == 0) ? ExitSide.E_LEFT : ExitSide.E_RIGHT; Debug.Log(exitSide.ToString()); MakeBlocks(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUILayout.LabelField("Опции"); MazeGenParallel maze_gen = (MazeGenParallel)target; if (GUILayout.Button("ReGenerate Maze Parallel")) { int n = maze_gen.transform.childCount; for (int i = 0; i < n; i++) { SafeDestroy.SafeDestroyGameObject(maze_gen.transform.GetChild(0)); } maze_gen.RegenerateMaze(); } if (GUILayout.Button("ReGenerate Maze")) { MazeGen maze_gen1 = GameObject.Find("Plane").GetComponent <MazeGen>(); int n = maze_gen1.transform.childCount; for (int i = 0; i < n; i++) { SafeDestroy.SafeDestroyGameObject(maze_gen1.transform.GetChild(0)); } maze_gen1.RegenerateMaze(); } EditorGUI.BeginChangeCheck(); this._selected = EditorGUILayout.Popup("My Simple Dropdown", _selected, _options); if (EditorGUI.EndChangeCheck()) { Debug.Log(_options[_selected]); } }
public float[,] Generate(int _seed, bool _enableCaves, float _amp, float _caveDensity, float _groundOffset, float _grassOffset) { try { seed = _seed; enableCaves = _enableCaves; amp = _amp; caveDensity = _caveDensity; groundOffset = _groundOffset; grassOffset = _grassOffset; Vector2Int bottomLeft = new Vector2(Location.x * ChunkSizeX, Location.z * ChunkSizeZ); Vector2Int topRight = new Vector2(Location.x * ChunkSizeX + ChunkSizeX, Location.z * ChunkSizeZ + ChunkSizeZ); MazeGen mountainTerrain = new MazeGen(ChunkSizeX / 2, 4, ChunkMeterSizeY / 2, seed, 2, 1); NoiseModule = mountainTerrain; //NoisePlane = new LibNoise.Models.Plane(NoiseModule); //SetSurfaceData(bottomLeft, topRight); } catch (Exception e) { SafeDebug.LogError(e.Message + "\nFunction: Generate, Chunk: " + Location.ToString(), e); } return(SurfaceData); }
// Start is called before the first frame update void Start() { lastTime = Time.time; MazeGen.solve(MazeGen.mazeRaw, (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.z)); }
public void Last() { mg = new MazeGen(go, this); mg.refresh(); mg.loaddata("temp"); play.interactable = true; mode.interactable = true; last.interactable = false; }
// Use this for initialization void Start() { storm = getStorm(); if (this.gameObject.name == "Player") { controller = getController(); } isFalling = false; waiting = false; }
public void Savegame(MazeGen mg, string name) { BinaryFormatter bf = new BinaryFormatter(); string path = Application.dataPath + "/Levels/" + name + ".oof"; FileStream fs = new FileStream(path, FileMode.Create); MazeData m = new MazeData(mg); bf.Serialize(fs, m); fs.Close(); }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.White; MazeGen maze = new MazeGen(); MazeData mazeData = maze.Generate(); MazeSolver mazeSolver = new MazeSolver(mazeData); mazeSolver.Solve(); Console.ReadLine(); }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad (gameObject); keys = new List<Key> (); bonus = new GameBonus (); maze = GetComponent<MazeGen> (); audioSource = GetComponent<AudioSource>(); InitGame (); }
void Start() { Directory.CreateDirectory(Application.dataPath + "/Levels"); Directory.CreateDirectory(Application.dataPath + "/UI"); mode.interactable = false; play_cam.gameObject.SetActive(false); menu_canvas.gameObject.SetActive(false); t = GetComponent <Transform>(); mg = new MazeGen(go, this); loadbutton.interactable = false; play.interactable = false; play_mode = false; last.interactable = false; }
// Start is called before the first frame update void Start() { mg = new MazeGen(); bool generatedLab = false; instance = this; generatedLab = mg.GenLab(game, numLab, genHeight, genWwidth); if (generatedLab) { Debug.Log("Se ha generado un laberinto, número: " + numLab); numLab++; } }
private void BeginGame() { GameObject [] gameObjs = SceneManager.GetActiveScene().GetRootGameObjects(); for (int i = 0; i < gameObjs.Length; i++) { maze = gameObjs[i].GetComponent <MazeGen>(); if (null != maze) { brickWidth = maze.width; brickHeight = maze.height; offset = maze.brickScale; break; } } this.transform.position = new Vector3((brickWidth >> 1) * offset.x, 0, 0 * offset.z); return; }
public void New() { StopCoroutine(GetComponent <Modes>().End()); play.interactable = true; if (sx.text != null) { MazeGen.sizeX = Int32.Parse(sx.text); } if (sy.text != null) { MazeGen.sizeY = Int32.Parse(sy.text); } mg = new MazeGen(go, this); mode.interactable = true; mg.refresh(); mg.mazeStart(); if (mode.value == 1) { AddCoins(); } }
void Start() { controller = findController(); }
public MazeData(MazeGen mg) { sizeX = MazeGen.sizeX; sizeY = MazeGen.sizeY; blue_indices = new int[mg.blueTiles.Count]; yellow_indices = new int[mg.yellowTiles.Count]; green_indices = new int[mg.greenTiles.Count]; red_indices = new int[mg.redTiles.Count]; blueS_indices = new int[mg.blueShifters.Count]; yellowS_indices = new int[mg.yellowShifters.Count]; greenS_indices = new int[mg.greenShifters.Count]; redS_indices = new int[mg.redShifters.Count]; enemysx = new int[mg.enemies.Length]; enemysy = new int[mg.enemies.Length]; for (int i = 0; i < MazeGen.sizeX; i++) { for (int j = 0; j < MazeGen.sizeY; j++) { g[i, j] = new bool[4]; } } for (int i = 0; i < MazeGen.sizeX; i++) { for (int j = 0; j < MazeGen.sizeY; j++) { for (int k = 0; k < 4; k++) { g[i, j][k] = MazeGen.grids[i][j].dir[k]; } } } for (int i = 0; i < mg.blueTiles.Count; i++) { blue_indices[i] = mg.blueTiles[i]; } for (int i = 0; i < mg.yellowTiles.Count; i++) { yellow_indices[i] = mg.yellowTiles[i]; } for (int i = 0; i < mg.greenTiles.Count; i++) { green_indices[i] = mg.greenTiles[i]; } for (int i = 0; i < mg.redTiles.Count; i++) { red_indices[i] = mg.redTiles[i]; } for (int i = 0; i < mg.blueShifters.Count; i++) { blueS_indices[i] = mg.blueShifters[i]; } for (int i = 0; i < mg.yellowShifters.Count; i++) { yellowS_indices[i] = mg.yellowShifters[i]; } for (int i = 0; i < mg.greenShifters.Count; i++) { greenS_indices[i] = mg.greenShifters[i]; } for (int i = 0; i < mg.redShifters.Count; i++) { redS_indices[i] = mg.redShifters[i]; } for (int i = 0; i < mg.enemies.Length; i++) { enemysx[i] = (int)mg.enemies[i].transform.position.x; enemysy[i] = (int)mg.enemies[i].transform.position.y; } }
void Awake() { instance = this; MakeBlocks(); }
protected override void Awake() { base.Awake(); // setup enemy count enemyCount = 10; // setup size of maze sizex = 10; sizey = 10; // setup dimentions of walls and cooridors corridorWidth = 7; wallWidth = 3; // create new maze object mazeBody = new GameObject(); mazeBody.name = "Maze"; mazeBody.tag = "Terrain"; // initialise wall informaton walls = new List <GameObject>(); wallSprite = Resources.Load <Sprite>("Art/Terrain/Maze/basic"); // generate maze information using helper class maze = new MazeGen(sizex, sizey); // turn maze information into game objects GameObject lastWall; for (int y = 0; y < sizey; y++) { for (int x = 0; x < sizex; x++) { // checks if there is a wall at the bottom position if (maze[x, y].HasFlag(CellState.Top)) { lastWall = new GameObject(); lastWall.name = "Wall"; lastWall = SetupWall(lastWall, corridorWidth + wallWidth, wallWidth, corridorWidth * x, corridorWidth * y - corridorWidth / 2); walls.Add(lastWall); } // checks if ther is a wall on the right posision if (maze[x, y].HasFlag(CellState.Left)) { lastWall = new GameObject(); lastWall.name = "Wall"; lastWall = SetupWall(lastWall, wallWidth, corridorWidth + wallWidth, corridorWidth * x - corridorWidth / 2, corridorWidth * y); walls.Add(lastWall); } } } // generates top and right outer walls lastWall = new GameObject(); lastWall.name = "Wall"; lastWall = SetupWall(lastWall, corridorWidth * sizex + wallWidth, wallWidth, corridorWidth * sizex / 2 - corridorWidth / 2, corridorWidth * sizey - corridorWidth / 2); walls.Add(lastWall); lastWall = new GameObject(); lastWall.name = "Wall"; lastWall = SetupWall(lastWall, wallWidth, corridorWidth * sizey + wallWidth, corridorWidth * sizex - corridorWidth / 2, corridorWidth * sizey / 2 - corridorWidth / 2); walls.Add(lastWall); }
void Awake() { instance = this; }
// Update is called once per frame void Update() { //for (int i = 0; i < MazeGen.mazeRaw.Count; i++) //{ // Debug.Log(MazeGen.mazeRaw[i]); //} //Debug.Log("x: " + (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x) + ", z: " + (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z)); if ((Time.time - lastTime > 0.2f) && ((Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)))) { //if (!(Physics.Raycast(GameObject.Find("Player(Clone)").transform.position, GameObject.Find("Player(Clone)").transform.TransformDirection(Vector3.forward), 0.7f))) RaycastHit hit = new RaycastHit(); Ray ray = new Ray(GameObject.Find("Player(Clone)").transform.position, GameObject.Find("Player(Clone)").transform.forward); if (!Physics.Raycast(ray, out hit, 1) || (Physics.Raycast(ray, out hit, 1) && hit.collider.gameObject.name != "Fence(Clone)")) { MazeGen.solve(MazeGen.mazeRaw, (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.z)); StringBuilder str = new StringBuilder(MazeGen.mazeRaw[(int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x)].ToString());//Set Current position as ' ' str[(int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z)] = ' '; MazeGen.mazeRaw[(int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x)] = str; StartCoroutine("Forward"); } lastTime = Time.time; } if ((Time.time - lastTime > 0.2f) && (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))) { StartCoroutine("Left"); lastTime = Time.time; using (StreamWriter sw = File.AppendText(Application.dataPath + Spawner.path)) { if (AudioCue.play.isPlaying) { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Left" + ",N/A" + "," + AudioCue.currentlyPlaying + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } else { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Left" + ",N/A" + ",0" + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } } } if ((Time.time - lastTime > 0.2f) && (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))) { StartCoroutine("Right"); lastTime = Time.time; using (StreamWriter sw = File.AppendText(Application.dataPath + Spawner.path)) { if (AudioCue.play.isPlaying) { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Right" + ",N/A" + "," + AudioCue.currentlyPlaying + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } else { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Right" + ",N/A" + ",0" + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } } } }