From e35c70e002e136d95c5e7217957bef0fd7863d0f Mon Sep 17 00:00:00 2001 From: Saibotk Date: Sun, 22 Apr 2018 17:52:20 +0200 Subject: [PATCH] Generation integration Part 1 Fix Texture Unit size Added Root tags Fixed NullPointers Todo: - Fix sprite rotation - Fix processing of hallways - Put doors in their own root GameObject --- Assets/Scenes/CodeDEV.unity | 3 +- Assets/Scripts/GameController.cs | 7 ++- Assets/Scripts/Objectives/StartObjective.cs | 4 +- Assets/Scripts/Room.cs | 62 ++++++++++++++++--- .../textures/Entities/Player/car.png.meta | 35 ++++++++++- .../textures/FixedObjects/Door/doorC.png.meta | 35 ++++++++++- .../textures/FixedObjects/Door/doorL.png.meta | 35 ++++++++++- .../textures/FixedObjects/Door/doorR.png.meta | 35 ++++++++++- .../FixedObjects/Ground/ground0.png.meta | 35 ++++++++++- .../FixedObjects/Ground/ground1.png.meta | 35 ++++++++++- .../FixedObjects/Wall/wallCornerIn.png.meta | 35 ++++++++++- .../FixedObjects/Wall/wallCornerOut.png.meta | 35 ++++++++++- .../FixedObjects/Wall/wallSide.png.meta | 35 ++++++++++- ProjectSettings/TagManager.asset | 2 + 14 files changed, 372 insertions(+), 21 deletions(-) diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index b8fcdba..1ae8fe3 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -1178,7 +1178,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: gameOverPanel: {fileID: 354516592} - healthcontroller: {fileID: 0} + healthcontroller: {fileID: 623293249} --- !u!4 &1487324258 Transform: m_ObjectHideFlags: 0 @@ -1353,3 +1353,4 @@ MonoBehaviour: cam: {fileID: 881384367} playerPrefab: {fileID: 1679161327080020, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} + mapRoot: {fileID: 1624368723} diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 35bac10..4faf9e6 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -154,9 +154,13 @@ public class GameController : MonoBehaviour { dg.Generate(); GameObject goStart = gp.ProcessRoom(dg.start.tiles); start = goStart.AddComponent(); + //start.SetDoorsRootObject(new List(goStart.GetComponentsInChildren()).Find(x => x.tag == "DoorRoot").gameObject); + start.Reload(); start.transform.SetParent(mapRoot.transform); GameObject goFinish = gp.ProcessRoom(dg.end.tiles); finish = goFinish.AddComponent(); + //finish.SetDoorsRootObject(new List(goFinish.GetComponentsInChildren()).Find(x => x.tag == "DoorRoot").gameObject); + finish.Reload(); finish.transform.SetParent(mapRoot.transform); foreach (GenRoom gr in dg.rooms) { GameObject groom = gp.ProcessRoom(gr.tiles); @@ -170,7 +174,8 @@ public class GameController : MonoBehaviour { start.SetObjective(goal); start.OnPlayerEnter(player); player = goal.GetPlayer(); - cam.GetComponent().SetFollow(player.gameObject); + if(player != null) + cam.GetComponent().SetFollow(player.gameObject); } private void Running() { diff --git a/Assets/Scripts/Objectives/StartObjective.cs b/Assets/Scripts/Objectives/StartObjective.cs index 8ab1684..a799bd9 100644 --- a/Assets/Scripts/Objectives/StartObjective.cs +++ b/Assets/Scripts/Objectives/StartObjective.cs @@ -19,7 +19,8 @@ public class StartObjective : Objective { /// Handle activation code for a goal. /// /// Player is ignored - public override void ActivateGoal(Player player=null) { + public override void ActivateGoal(Player player) { + Debug.Log(room == null); if ( room.GetSpawnpoints().Count > 0 ) { GameObject ply = GameObject.Instantiate(playerPrefab); ply.transform.position = room.GetSpawnpoints()[0].position; @@ -33,6 +34,7 @@ public class StartObjective : Objective { /// /// Player public Player GetPlayer() { + Debug.Log(player == null); return player; } diff --git a/Assets/Scripts/Room.cs b/Assets/Scripts/Room.cs index e9a77ad..bc2302e 100644 --- a/Assets/Scripts/Room.cs +++ b/Assets/Scripts/Room.cs @@ -22,17 +22,61 @@ public class Room : MonoBehaviour { // Use this for initialization void Start() { doors = new List(); - foreach ( Door d in doorsRootObject.GetComponentsInChildren() ) { - doors.Add(d); - } - Debug.Log("[ROOMS] Doors: " + doors.Count); - spawnpoints = new List(); - foreach ( Transform t in spawnpointRootObject.GetComponentsInChildren() ) { - if ( t.gameObject != spawnpointRootObject ) { - spawnpoints.Add(t); + if ( doorsRootObject != null ) { + foreach ( Door d in doorsRootObject.GetComponentsInChildren() ) { + doors.Add(d); } + Debug.Log("[ROOMS] Doors: " + doors.Count); } - Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count); + + spawnpoints = new List(); + if ( spawnpointRootObject != null ) { + foreach ( Transform t in spawnpointRootObject.GetComponentsInChildren() ) { + if ( t.gameObject != spawnpointRootObject ) { + spawnpoints.Add(t); + } + } + Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count); + } + } + + /// + /// Reloads the spawnpoints and doors. + /// + public void Reload() { + doors = new List(); + if ( doorsRootObject != null ) { + foreach ( Door d in doorsRootObject.GetComponentsInChildren() ) { + doors.Add(d); + } + Debug.Log("[ROOMS] Doors: " + doors.Count); + } + + spawnpoints = new List(); + if ( spawnpointRootObject != null ) { + foreach ( Transform t in spawnpointRootObject.GetComponentsInChildren() ) { + if ( t.gameObject != spawnpointRootObject ) { + spawnpoints.Add(t); + } + } + Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count); + } + } + + /// + /// Sets the doors root object. + /// + /// + public void SetDoorsRootObject(GameObject go) { + doorsRootObject = go; + } + + /// + /// Sets the spawnpoints root object. + /// + /// + public void SetSpawnPointsRootObject(GameObject go) { + spawnpointRootObject = go; } /// diff --git a/Assets/graphics/textures/Entities/Player/car.png.meta b/Assets/graphics/textures/Entities/Player/car.png.meta index 69f7c6c..59aaadb 100644 --- a/Assets/graphics/textures/Entities/Player/car.png.meta +++ b/Assets/graphics/textures/Entities/Player/car.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Door/doorC.png.meta b/Assets/graphics/textures/FixedObjects/Door/doorC.png.meta index 1c38956..5999ff2 100644 --- a/Assets/graphics/textures/FixedObjects/Door/doorC.png.meta +++ b/Assets/graphics/textures/FixedObjects/Door/doorC.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Door/doorL.png.meta b/Assets/graphics/textures/FixedObjects/Door/doorL.png.meta index 966f98c..f383f28 100644 --- a/Assets/graphics/textures/FixedObjects/Door/doorL.png.meta +++ b/Assets/graphics/textures/FixedObjects/Door/doorL.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Door/doorR.png.meta b/Assets/graphics/textures/FixedObjects/Door/doorR.png.meta index b3898c7..0f7d2e6 100644 --- a/Assets/graphics/textures/FixedObjects/Door/doorR.png.meta +++ b/Assets/graphics/textures/FixedObjects/Door/doorR.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Ground/ground0.png.meta b/Assets/graphics/textures/FixedObjects/Ground/ground0.png.meta index 486a97c..0bfdfc4 100644 --- a/Assets/graphics/textures/FixedObjects/Ground/ground0.png.meta +++ b/Assets/graphics/textures/FixedObjects/Ground/ground0.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Ground/ground1.png.meta b/Assets/graphics/textures/FixedObjects/Ground/ground1.png.meta index 3694438..3ad48bb 100644 --- a/Assets/graphics/textures/FixedObjects/Ground/ground1.png.meta +++ b/Assets/graphics/textures/FixedObjects/Ground/ground1.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Wall/wallCornerIn.png.meta b/Assets/graphics/textures/FixedObjects/Wall/wallCornerIn.png.meta index 653c649..a4f2b8e 100644 --- a/Assets/graphics/textures/FixedObjects/Wall/wallCornerIn.png.meta +++ b/Assets/graphics/textures/FixedObjects/Wall/wallCornerIn.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Wall/wallCornerOut.png.meta b/Assets/graphics/textures/FixedObjects/Wall/wallCornerOut.png.meta index 80126e3..4b8a911 100644 --- a/Assets/graphics/textures/FixedObjects/Wall/wallCornerOut.png.meta +++ b/Assets/graphics/textures/FixedObjects/Wall/wallCornerOut.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/graphics/textures/FixedObjects/Wall/wallSide.png.meta b/Assets/graphics/textures/FixedObjects/Wall/wallSide.png.meta index 2d69888..41f8889 100644 --- a/Assets/graphics/textures/FixedObjects/Wall/wallSide.png.meta +++ b/Assets/graphics/textures/FixedObjects/Wall/wallSide.png.meta @@ -43,7 +43,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 1000 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -67,6 +67,39 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index fc756ab..76be908 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -6,6 +6,8 @@ TagManager: tags: - wall - door + - DoorRoot + - SpawnlistRoot layers: - Default - TransparentFX