private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.layer != LayerMask.NameToLayer("Player")) { return; } GameObject[,] minimapRealization = DungeonMinimapBuilder.GetMapRealization(); int x = (int)roomBuilder.Position.x, y = (int)roomBuilder.Position.y; DungeonMinimapRoomBuilder minimapRoomBuilder = minimapRealization[x, y].gameObject.GetComponent <DungeonMinimapRoomBuilder>(); minimapRoomBuilder.IsVisited = true; minimapRoomBuilder.IsCurrentlyVisited = true; for (int i = 0, neighbours = 4; i < neighbours; i++) { if (minimapRoomBuilder.Neighbours[i] == null) { continue; } DungeonMinimapRoomBuilder neighbourMinimapRoomBuilder = minimapRoomBuilder.Neighbours[i].GetComponent <DungeonMinimapRoomBuilder>(); neighbourMinimapRoomBuilder.IsCurrentlyVisited = false; } DungeonMinimapBuilder.Camera.transform.position = minimapRealization[x, y].gameObject.transform.position + new Vector3(0, 0, -10); OnUpdateMinimap.Raise(); }
public void UpdateNeighbours() { GameObject[,] minimapRealization = DungeonMinimapBuilder.GetMapRealization(); // Explicit casting int row = (int)position.x, column = (int)position.y; // Add neighbours for (int i = 0, direction = 4; i < direction; i++) { switch (i) { default: neighbours[i] = null; break; case 0: neighbours[i] = state[i] ? minimapRealization[row - 1, column] : null; break; case 1: neighbours[i] = state[i] ? minimapRealization[row, column + 1] : null; break; case 2: neighbours[i] = state[i] ? minimapRealization[row + 1, column] : null; break; case 3: neighbours[i] = state[i] ? minimapRealization[row, column - 1] : null; break; } } }