diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 91e702d..51e3133 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -169,7 +169,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2cf81aa4a8d45468f8184f8d5862d7eb, type: 3} m_Name: m_EditorClassIdentifier: - acceleration: 3 + acceleration: 4 friction: 0.1 turnSpeed: 2 drift: 1 diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index fb42b51..3c1f8e4 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -986,6 +986,48 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 833134303} +--- !u!1001 &865504979 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + propertyPath: m_RootOrder + value: 4 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + m_IsPrefabParent: 0 --- !u!1 &881384367 GameObject: m_ObjectHideFlags: 0 @@ -1079,7 +1121,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3} m_Name: m_EditorClassIdentifier: - followThis: {fileID: 0} + followThis: {fileID: 1239288696} --- !u!1 &1001682580 GameObject: m_ObjectHideFlags: 0 @@ -1328,7 +1370,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1487324257 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Generation/DungeonGenerator.cs b/Assets/Scripts/Generation/DungeonGenerator.cs index 73dc8da..192c76c 100644 --- a/Assets/Scripts/Generation/DungeonGenerator.cs +++ b/Assets/Scripts/Generation/DungeonGenerator.cs @@ -68,7 +68,7 @@ public class DungeonGenerator { foreach ( GenVertex r1 in Q ) { foreach ( GenVertex r2 in Q ) { if ( r1 == r2 ) - continue; + goto outer; foreach ( GenEdge e in E ) if ( e.r2 == r1 && e.r1 == r2 ) goto outer; @@ -134,30 +134,34 @@ public class DungeonGenerator { path.tiles.Add(pos1, Room.TileType.GROUND); for ( int x2 = x1 - 1; x2 <= x1 + 1; x2++ ) for ( int y2 = y1 - 1; y2 <= y1 + 1; y2++ ) { - if ( !path.tiles.ContainsKey(new Vector2Int(x2, y2)) ) - path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL); + if (!path.tiles.ContainsKey(new Vector2Int(x2, y2))) + path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL); } } } foreach ( GenRoom r in rooms ) { for ( int x1 = r.bounds.x; x1 < r.bounds.x + r.bounds.width; x1++ ) for ( int y1 = r.bounds.y; y1 < r.bounds.y + r.bounds.height; y1++ ) { - r.tiles.Add(new Vector2Int(x1, y1), Room.TileType.WALL); + r.tiles.Add(new Vector2Int(x1, y1), Room.TileType.WALL); } for ( int x1 = r.bounds.x + 1; x1 < r.bounds.x + r.bounds.width - 1; x1++ ) for ( int y1 = r.bounds.y + 1; y1 < r.bounds.y + r.bounds.height - 1; y1++ ) { r.tiles[new Vector2Int(x1, y1)] = Room.TileType.GROUND; } - foreach ( Vector2Int v in r.AllDoors() ) - r.tiles[v] = Room.TileType.DOOR; + foreach (Vector2Int v in r.AllDoors()) + { + Debug.Log("Door: " + v); + if (!r.bounds.Contains(v)) + throw new NotSupportedException("This is a bug where doors land in the wrong room. It should have been fixed."); + else + r.tiles[v] = Room.TileType.DOOR; + } } foreach (GenRoom r in rooms) { generateInterior (r); } - rooms.Add(path); - start = root.r; end = null; foreach ( GenRoom r in rooms ) { if ( end == null || r.bounds.x > end.bounds.x ) @@ -218,8 +222,8 @@ public class DungeonGenerator { rooms.Add(tunnel); for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { - lower.doorsUp.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y + tunnel.bounds.height)); - higher.doorsDown.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y - 1)); + higher.doorsUp.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y + tunnel.bounds.height)); + lower.doorsDown.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y - 1)); } } @@ -338,14 +342,14 @@ public class DungeonGenerator { lower.doorsDown.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y - 1)); } else for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { - lower.doorsUp.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y + verticalLefter.bounds.height)); + higher.doorsUp.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y + verticalLefter.bounds.height)); } } if ( addVertical2 ) { rooms.Add(verticalRighter); if ( lower == righter ) for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { - higher.doorsDown.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y - 1)); + lower.doorsDown.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y - 1)); } else for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { higher.doorsUp.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y + verticalRighter.bounds.height)); diff --git a/Assets/Scripts/Generation/GenRoom.cs b/Assets/Scripts/Generation/GenRoom.cs index 3cab794..2b9fa56 100644 --- a/Assets/Scripts/Generation/GenRoom.cs +++ b/Assets/Scripts/Generation/GenRoom.cs @@ -21,6 +21,13 @@ public class GenRoom { public float Distance(GenRoom r) { return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y); + //float power = 2; + //float dist = (float) Math.Pow( + // Math.Pow(GetCenter().x - r.GetCenter().x, power) + // + Math.Pow(GetCenter().y - r.GetCenter().y, power), + // 1 / power); + //Debug.Log(bounds.center + " " + bounds + " " + dist); + //return dist; } public Vector2Int GetCenter() { diff --git a/Assets/Scripts/NotificationManager.cs b/Assets/Scripts/NotificationManager.cs index c770c2c..3b340c7 100644 --- a/Assets/Scripts/NotificationManager.cs +++ b/Assets/Scripts/NotificationManager.cs @@ -32,19 +32,19 @@ public class NotificationManager : MonoBehaviour { // Use this for initialization void Start() { delay = 0; - showingMessage = false; messages = new List(); text = GetComponent(); + hide(); } void Update() { if ( showingMessage ) { if ( Time.time > delay ) { - if ( messages.Count == 1 ) { - GetComponentInParent().enabled = false; - messages.Remove(messages[0]); - showingMessage = false; + if (messages.Count <= 1) { + messages.Remove(messages[0]); + hide(); } else { + messages.Remove(messages[0]); text.text = messages[0].getText(); delay = Time.time + messages[0].getDuration(); } @@ -60,7 +60,19 @@ public class NotificationManager : MonoBehaviour { GetComponent().text = text; delay = Time.time + duration; - GetComponentInParent().enabled = true; + show(); } } + + void show() { + GetComponentInParent().enabled = true; + text.enabled = true; + showingMessage = true; + } + + void hide() { + GetComponentInParent().enabled = false; + text.enabled = false; + showingMessage = false; + } } diff --git a/Assets/Scripts/UIController.cs b/Assets/Scripts/UIController.cs index 080cb3b..d9cec90 100644 --- a/Assets/Scripts/UIController.cs +++ b/Assets/Scripts/UIController.cs @@ -2,53 +2,74 @@ using System.Collections.Generic; using UnityEngine; -public class UIController : MonoBehaviour { +public class UIController : MonoBehaviour +{ GameObject score; GameObject pauseMenu; + [SerializeField] + NotificationManager notifications; + [SerializeField] GameObject gameOverPanel; [SerializeField] - private HealthbarController healthcontroller; + HealthbarController healthcontroller; - public void ShowPauseMenu() { + + public void ShowPauseMenu() + { pauseMenu.SetActive(true); } - public void ClosePauseMenu() { + public void ClosePauseMenu() + { pauseMenu.SetActive(false); } - public void LoadSceneByIndex(int index) { + public void LoadSceneByIndex(int index) + { Debug.Log("Loaded scene " + index); UnityEngine.SceneManagement.SceneManager.LoadScene(index); } - public void QuitGame() { + public void QuitGame() + { Debug.Log("Quit game"); Application.Quit(); } - public void ShowGameOverUI() { - if ( gameOverPanel != null ) { + public void ShowGameOverUI() + { + if (gameOverPanel != null) + { Canvas gameOverCanvas = gameOverPanel.GetComponent(); Debug.Log("Loading Canvas"); - if ( gameOverCanvas != null ) { + if (gameOverCanvas != null) + { Debug.Log("Loaded Canvas"); gameOverCanvas.enabled = true; - } else { + } + else + { Debug.Log("Gameover panel has no Canvas"); } - } else { + } + else + { Debug.Log("No game over panel assigned"); } } - public void InitHealthController(Player ply) { + public void InitHealthController(Player ply) + { healthcontroller.SetPlayer(ply); } + + public NotificationManager GetNotificationManager() { + return notifications; + } }