private void OnTriggerEnter(Collider other) { // On contact with floors if (other.gameObject.CompareTag("Destroyable")) { GameObject maze = other.transform.parent.gameObject; MazeLoader script = maze.GetComponent <MazeLoader>(); int row = (int)other.transform.localPosition.x / mazeSize; int column = (int)other.transform.localPosition.z / mazeSize; for (int i = 0; i < script.shortestPath.Length; i++) { var point = script.shortestPath[i]; // Debug.Log(row + "," + column + "==" + point[0] + "," + point[1]); // if you shoot a floor that is part of the shortest path, you either win or lose depending on which side of the destroyable maze you are on playerScript.GameOverMessage(row == point[0] && column == point[1], playerCrossedAllMazes); } Destroy(other.gameObject); } // Prevent player from colliding with projectile if (!other.gameObject.CompareTag("Player") /* && !other.gameObject.CompareTag("Pick Up") */) { AmIOutOfAmmo(); Destroy(gameObject); } }
void Start() { playerBodyMesh = GameObject.Find("Player").transform.Find("Model").gameObject.GetComponent <SkinnedMeshRenderer>(); ml = GameObject.Find("Main Camera").GetComponent <MazeLoader>(); walls = ml.walls; hb = GameObject.Find("Healthbar").GetComponent <Healthbar>(); keyimg = GameObject.Find("KeyImage").GetComponent <Image>(); }
// Use this for initialization void Start() { agent = GetComponent <NavMeshAgent> (); anim = GetComponent <Animator> (); ml = FindObjectOfType <MazeLoader> (); anim.SetBool("Run", Random.Range(0, 2) == 1 ? true : false); anim.SetBool("Attack", false); position = GameObject.Find("Floor " + Random.Range(0, ml.mazeColumns) + "," + Random.Range(0, ml.mazeRows)).transform.position; }
// Start is called before the first frame update void Start() { maze = GameObject.Find("/GameManager (Maze Loader Holder)").GetComponent <MazeLoader>(); if (!title) { switch (InventoryManagement.Difficulty) { case "Easy": bozuSpeed = 4f; bozuSpeedMult = 1.05f; bozuSpawnMult = 1.05f; break; case "Medium": bozuSpeedMult = 1.1f; bozuSpawnMult = 1.1f; break; case "Hard": bozuSpeedMult = 1.2f; bozuSpawnMult = 1.2f; break; case "Default": bozuSpeed = 4f; bozuSpeedMult = 1.05f; bozuSpawnMult = 1.05f; break; } bozuSpeed += bozuSpeed * ((bozuSpeedMult - 1) * (InventoryManagement.CurrentLevel - 1)); spawnRateBozu -= spawnRateBozu * ((bozuSpawnMult - 1) * (InventoryManagement.CurrentLevel - 1)); initSpawnBozu += (int)Mathf.Round(spawnRateBozu * ((bozuSpawnMult - 1) * (InventoryManagement.CurrentLevel - 1))); maxBozuAmt += (int)Mathf.Round(spawnRateBozu * ((bozuSpawnMult - 1) * (InventoryManagement.CurrentLevel - 1))); } noteAmt = 0; bozuAmt = 0; skeleAmt = 0; if (player != null) { playerMove = player.GetComponent <PlayerMovement>(); } noteCount = 1; minX = GetComponent <Collider>().bounds.min.x; maxX = GetComponent <Collider>().bounds.max.x; minZ = GetComponent <Collider>().bounds.min.z; maxZ = GetComponent <Collider>().bounds.max.z; yCoord = GetComponent <Collider>().bounds.max.y + 2; initSpawn(); }
private void Start() { mazeLoader = GetComponent <MazeLoader> (); #if (UNITY_STANDALONE_WIN || UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX) if (!hasSpawnedAlready) { InvokeRepeating(nameof(SpawnJumpPads), 0, spawnInterval); hasSpawnedAlready = true; } #endif }
void Awake() { GameObject obj = GameObject.Find("Settings"); data = obj.GetComponent <DataScript>(); treasureCount = data.treasures; mazeSize = data.mazeSize; obj = GameObject.Find("[CameraRig]"); while (!obj) { obj = GameObject.Find("[CameraRig]"); } mazeStructure = obj.GetComponent <MazeLoader>(); inputScript = obj.GetComponent <InputScript>(); }
private bool MazeLoaderScriptLoaded() { if (!mazeStructure) { GameObject cameraRig = GameObject.Find("[CameraRig]"); if (cameraRig) { cameraTransform = cameraRig.GetComponent <Transform>(); mazeStructure = cameraRig.GetComponent <MazeLoader>(); return(true); } else { return(false); } } return(true); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); MazeLoader ml = (MazeLoader)target; if (GUILayout.Button("Generate Maze")) { ml.GenerateMaze(); } if (GUILayout.Button("Clear Maze")) { ml.ClearMaze(); } if (GUILayout.Button("Generate Spawn Points")) { ml.GenerateSpawnPoints(); } }
private void cmdLoadMaze_Click(object sender, System.EventArgs e) { OpenFileDialog OpenFile = new OpenFileDialog { Filter = "Text Files|*.txt", Title = "Select a maze map text file..." }; if (OpenFile.ShowDialog() != DialogResult.OK) { return; } Loader = new MazeLoader(); Loader.InitializeLoader(); try { int[,] LoadedMaze = Loader.LoadCoordinatesFromFile(OpenFile.FileName); Settings.MAZE_ROWS = LoadedMaze.GetLength(0); Settings.MAZE_COLUMNS = LoadedMaze.GetLength(1); pbMaze.Size = new Size(Settings.MAZE_COLUMNS * Settings.MAZE_BLOCK_SIZE + 3, Settings.MAZE_ROWS * Settings.MAZE_BLOCK_SIZE + 3); Solver = new Solver(LoadedMaze); Maze = Solver.GetMaze(); EntrancePoint = new Point(Loader.EntranceCoordinates.X, Loader.EntranceCoordinates.Y); ExitPoint = new Point(Loader.ExitCoordinates.X, Loader.ExitCoordinates.Y); // We do not want to modify the loaded maze cmdManualEdit.Enabled = false; pbMaze.Refresh(); } catch (Exception ex) { MessageBox.Show($"An error has occurred while trying to load your maze.\n\nDetails:\n{ex.Message}", "Error while loading maze!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Writes the maze in a dummy file and attempts to load it. /// If the file is loaded successfully, a Solver is instantiated. /// The entrance and exit points are also set. /// </summary> private void LoadSampleMaze() { string TempFile = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); try { File.WriteAllText(TempFile, SampleMaze); Debug.WriteLine("LoadSampleMaze(): Temporary file containing sample maze has been written."); } catch (IOException ioEx) { Debug.WriteLine("LoadSampleMaze(): An IOException has been thrown: {0}.", ioEx.Message); AttemptFileDelete(TempFile); } Debug.WriteLine("LoadSampleMaze(): Loading maze matrix from the temporary file..."); try { MazeLoader = new MazeLoader(); MazeLoader.InitializeLoader(); MazeMatrix = MazeLoader.LoadCoordinatesFromFile(TempFile); } catch (Exception ex) { Debug.WriteLine("LoadSampleMaze(): An exception has been thrown while loading the matrix: {0}.", ex.Message); AttemptFileDelete(TempFile); } MazeSolver = new Solver(MazeMatrix); MazeMatrix = MazeSolver.GetMaze(); EntrancePoint = new Point(MazeLoader.EntranceCoordinates.X, MazeLoader.EntranceCoordinates.Y); ExitPoint = new Point(MazeLoader.ExitCoordinates.X, MazeLoader.ExitCoordinates.Y); if (EntrancePoint == null || ExitPoint == null) { Debug.WriteLine("LoadSampleMaze(): Entrance point or exit point is either invalid or non-existent."); } AttemptFileDelete(TempFile); }
public void ExceptionThrownOnMazeReadingRaisesException() { var loader = new MazeLoader(); var validatorMock = new Mock <IMazeValidator>(); validatorMock.Setup(x => x.ValidateMazeFile(It.IsAny <string>())).Verifiable("Must be called"); var readerMock = new Mock <IMazeReader>(); readerMock.Setup(x => x.ReadMaze(It.IsAny <string>())).Throws <Exception>().Verifiable("Must be called"); loader.MazeValidator = validatorMock.Object; loader.MazeReader = readerMock.Object; Assert.Throws(typeof(Exception), () => loader.LoadCoordinatesFromFile("file")); validatorMock.Verify(x => x.ValidateMazeFile(It.IsAny <string>()), Times.Once); readerMock.Verify(x => x.ReadMaze(It.IsAny <string>()), Times.Once); }
void Start() { GameObject mazeLoaderObj = GameObject.Find("[CameraRig]"); MazeLoader mazeScript = mazeLoaderObj.GetComponent <MazeLoader>(); inputScript = mazeLoaderObj.GetComponent <InputScript>(); maze = mazeScript.GetMazeCells(); for (int i = 0; i < data.mazeSize; i++) { for (int j = 0; j < data.mazeSize; j++) { PlaceDirt(i, j); PlaceTorches(i, j); PlaceMoss(i, j); PlaceSpiderWeb(i, j); PlaceTableAndChair(i, j); PlacePots(i, j); } } }
// Use this for initialization void Start() { reference = this; // CheckMazeNeighbors (); //ShowMazeCellWallData ("Check"); //ShowMazeCellWallBoolData ("Initial Check"); // ShowMazeCellWallBoolData ("Adjusted Check"); SolveMaze(); //mazeCells [mazeRows - 1, mazeColumns - 1] cam.transform.Translate(110, -40, -500); GameObject.Find("MazeCreator").transform.Translate(200, 200, 120); }
private void Awake() { // Grab the MazeLoader and TimeController from the scene mazeLoader = FindObjectOfType(typeof(MazeLoader)) as MazeLoader; timeController = FindObjectOfType(typeof(TimeController)) as TimeController; }
public Level01(IControls controls) { _maze = MazeLoader.Load("Game/MainGame/level01.txt"); _maze.AddEntity(new Cursor(controls)); _statusBar = new StatusBar(); }
void Start() { ml = FindObjectOfType <MazeLoader> (); player = GameObject.FindGameObjectWithTag("Player"); }
// Start is called before the first frame update void Start() { ml = GameObject.Find("Main Camera").GetComponent <MazeLoader>(); pos_has_been_set = false; }