From d45ba1290e0c15d2fa71d7cac75502503478e519 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 17:22:02 +0200 Subject: [PATCH 01/10] Update Steffo scene --- Assets/Animations.meta | 8 ++++++++ Assets/Animators.meta | 8 ++++++++ Assets/Assets.meta | 8 ++++++++ Assets/PhysMats.meta | 8 ++++++++ Assets/Scenes/Steffo.unity | 12 ++++++++++++ Assets/Scripts/Player.cs | 10 +++++----- Assets/Sounds.meta | 8 ++++++++ 7 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 Assets/Animations.meta create mode 100644 Assets/Animators.meta create mode 100644 Assets/Assets.meta create mode 100644 Assets/PhysMats.meta create mode 100644 Assets/Sounds.meta diff --git a/Assets/Animations.meta b/Assets/Animations.meta new file mode 100644 index 0000000..b2a79e2 --- /dev/null +++ b/Assets/Animations.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef3d86d84c224344a94715cdfa9fe32c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animators.meta b/Assets/Animators.meta new file mode 100644 index 0000000..7ff80b8 --- /dev/null +++ b/Assets/Animators.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 043f304edcc831c4ea9fcf0e1a2e520d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Assets.meta b/Assets/Assets.meta new file mode 100644 index 0000000..4eba494 --- /dev/null +++ b/Assets/Assets.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0460346d99d385241a6d87bbd10aceb8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PhysMats.meta b/Assets/PhysMats.meta new file mode 100644 index 0000000..bc5b1b2 --- /dev/null +++ b/Assets/PhysMats.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e823a56cb429e4b49becdc740fba66b9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Steffo.unity b/Assets/Scenes/Steffo.unity index 3b2ac89..d68be2b 100644 --- a/Assets/Scenes/Steffo.unity +++ b/Assets/Scenes/Steffo.unity @@ -339,5 +339,17 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, + type: 3} + propertyPath: wallSprite + value: + objectReference: {fileID: 21300000, guid: 0121970e693ee0a4d987bd5fe694ad67, + type: 3} + - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, + type: 3} + propertyPath: corridorSprite + value: + objectReference: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, + type: 3} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: cd714ea41cb7c454994bf0f5ad99abd1, type: 3} diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 96900b0..cfef994 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -25,24 +25,24 @@ public class Player : MonoBehaviour { if (Input.GetKey(KeyCode.A)) { - if (is_valid_movement("left")) transform.Translate(Vector3.left); + if (CanMoveTo("left")) transform.Translate(Vector3.left); } if (Input.GetKey(KeyCode.D)) { - if (is_valid_movement("right")) transform.Translate(Vector3.right); + if (CanMoveTo("right")) transform.Translate(Vector3.right); } if (Input.GetKey(KeyCode.W)) { - if (is_valid_movement("up")) transform.Translate(Vector3.up); + if (CanMoveTo("up")) transform.Translate(Vector3.up); } if (Input.GetKey(KeyCode.S)) { - if (is_valid_movement("down")) transform.Translate(Vector3.down); + if (CanMoveTo("down")) transform.Translate(Vector3.down); } // Qui c'è da aggiungere la condizione per il controllo degli hp } - bool is_valid_movement(string direction) + bool CanMoveTo(Vector2Int direction) { Tile tile; int posX = (int) transform.position.x; diff --git a/Assets/Sounds.meta b/Assets/Sounds.meta new file mode 100644 index 0000000..5fd147f --- /dev/null +++ b/Assets/Sounds.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 19c0d85909aede34bb371863f187b9e0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 09dd536edf6a71076a311c3c8a3ca12ea109d273 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 17:24:26 +0200 Subject: [PATCH 02/10] temp fix --- Assets/Scripts/Map.cs | 6 +++--- Assets/Scripts/Player.cs | 24 +++++++++--------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index c86df1e..5cf1076 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -148,14 +148,14 @@ public class Map : MonoBehaviour private List rooms; private System.Random rnd; - public Tile GetTile(int x, int y) { - GameObject tileObject = tiles[x, y]; + public Tile GetTile(Vector2Int position) { + GameObject tileObject = tiles[position.x, position.y]; Tile tile = tileObject.GetComponent(); return tile; } private void InitTile(int x, int y, bool walkable, Sprite tileSprite, bool roomPart) { - Tile tile = GetTile(x, y); + Tile tile = GetTile(new Vector2Int(x, y)); tile.walkable = walkable; tile.sprite = tileSprite; tile.roomPart = roomPart; diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index cfef994..44f77a4 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -23,21 +23,21 @@ public class Player : MonoBehaviour void playerMovement() { - if (Input.GetKey(KeyCode.A)) + if (Input.GetKeyDown(KeyCode.A)) { - if (CanMoveTo("left")) transform.Translate(Vector3.left); + if (CanMoveTo(Vector2Int.left)) transform.Translate(Vector3.left); } - if (Input.GetKey(KeyCode.D)) + if (Input.GetKeyDown(KeyCode.D)) { - if (CanMoveTo("right")) transform.Translate(Vector3.right); + if (CanMoveTo(Vector2Int.right)) transform.Translate(Vector3.right); } - if (Input.GetKey(KeyCode.W)) + if (Input.GetKeyDown(KeyCode.W)) { - if (CanMoveTo("up")) transform.Translate(Vector3.up); + if (CanMoveTo(Vector2Int.up)) transform.Translate(Vector3.up); } - if (Input.GetKey(KeyCode.S)) + if (Input.GetKeyDown(KeyCode.S)) { - if (CanMoveTo("down")) transform.Translate(Vector3.down); + if (CanMoveTo(Vector2Int.down)) transform.Translate(Vector3.down); } // Qui c'è da aggiungere la condizione per il controllo degli hp } @@ -45,12 +45,6 @@ public class Player : MonoBehaviour bool CanMoveTo(Vector2Int direction) { Tile tile; - int posX = (int) transform.position.x; - int posY = (int) transform.position.y; - if (direction == "left") tile = map.GetTile(posX - 1, posY); - else if (direction == "right") tile = map.GetTile(posX + 1, posY); - else if (direction == "up") tile = map.GetTile(posX, posY + 1); - else tile = map.GetTile(posX, posY - 1); - return tile.walkable; + return map.GetTile(direction).walkable; } } From 8af505138f6223006c13801610f2cf5cdced7b73 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 17:28:38 +0200 Subject: [PATCH 03/10] comment stuff --- Assets/Scripts/Consumabile.cs | 2 + Assets/Scripts/Map.cs | 18 +++--- Assets/Scripts/Mostro.cs | 2 + Assets/Scripts/Player.cs | 29 +++++---- Assets/Sprites/PurpleTileset2.png.meta | 90 ++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 Assets/Sprites/PurpleTileset2.png.meta diff --git a/Assets/Scripts/Consumabile.cs b/Assets/Scripts/Consumabile.cs index aecdeda..9121f40 100644 --- a/Assets/Scripts/Consumabile.cs +++ b/Assets/Scripts/Consumabile.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; +/* public class Consumabile : Object { // Start is called before the first frame update @@ -30,3 +31,4 @@ public class Consumabile : Object } } } +*/ \ No newline at end of file diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index 5cf1076..0da467c 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -154,8 +154,8 @@ public class Map : MonoBehaviour return tile; } - private void InitTile(int x, int y, bool walkable, Sprite tileSprite, bool roomPart) { - Tile tile = GetTile(new Vector2Int(x, y)); + private void InitTile(Vector2Int position, bool walkable, Sprite tileSprite, bool roomPart) { + Tile tile = GetTile(position); tile.walkable = walkable; tile.sprite = tileSprite; tile.roomPart = roomPart; @@ -178,7 +178,7 @@ public class Map : MonoBehaviour private void PlaceRoom(MapRoom mr) { for(int x = mr.start.x; x <= mr.end.x; x++) { for(int y = mr.start.y; y <= mr.end.y; y++) { - InitTile(x, y, true, roomSprite, true); + InitTile(new Vector2Int(x, y), true, roomSprite, true); } } } @@ -187,7 +187,7 @@ public class Map : MonoBehaviour //Returns true if the room can be safely placed for(int x = Mathf.Clamp(mr.start.x-1, 0, mapSize-1); x <= Mathf.Clamp(mr.end.x+1, 0, mapSize-1); x++) { for(int y = Mathf.Clamp(mr.start.y-1, 0, mapSize-1); y <= Mathf.Clamp(mr.end.y+1, 0, mapSize-1); y++) { - if(GetTile(x, y).roomPart) { + if(GetTile(new Vector2Int(x, y)).roomPart) { return false; } } @@ -197,17 +197,17 @@ public class Map : MonoBehaviour private void PlaceCorridor(MapCorridor mc) { Vector2Int cursor = new Vector2Int(mc.start.x, mc.start.y); - InitTile(cursor.x, cursor.y, true, corridorSprite, false); + InitTile(cursor, true, corridorSprite, false); if(mc.horizontal_priority) { while(cursor.x != mc.end.x) { if(cursor.x > mc.end.x) cursor.x--; else cursor.x++; - InitTile(cursor.x, cursor.y, true, corridorSprite, false); + InitTile(cursor, true, corridorSprite, false); } while(cursor.y != mc.end.y) { if(cursor.y > mc.end.y) cursor.y--; else cursor.y++; - InitTile(cursor.x, cursor.y, true, corridorSprite, false); + InitTile(cursor, true, corridorSprite, false); } } else @@ -215,12 +215,12 @@ public class Map : MonoBehaviour while(cursor.y != mc.end.y) { if(cursor.y > mc.end.y) cursor.y--; else cursor.y++; - InitTile(cursor.x, cursor.y, true, corridorSprite, false); + InitTile(cursor, true, corridorSprite, false); } while(cursor.x != mc.end.x) { if(cursor.x > mc.end.x) cursor.x--; else cursor.x++; - InitTile(cursor.x, cursor.y, true, corridorSprite, false); + InitTile(cursor, true, corridorSprite, false); } } } diff --git a/Assets/Scripts/Mostro.cs b/Assets/Scripts/Mostro.cs index 467af32..cf9d969 100644 --- a/Assets/Scripts/Mostro.cs +++ b/Assets/Scripts/Mostro.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; +/* public class Mostro : MonoBehaviour { public string nome; @@ -60,3 +61,4 @@ public class Mostro : MonoBehaviour return tile.walkable; } } +*/ diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 44f77a4..dffaeaf 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -18,33 +18,40 @@ public class Player : MonoBehaviour // Update is called once per frame void Update() { - playerMovement(); + CheckForMovementInput(); } - void playerMovement() + void CheckForMovementInput() { + bool hasMoved = false; if (Input.GetKeyDown(KeyCode.A)) { - if (CanMoveTo(Vector2Int.left)) transform.Translate(Vector3.left); + if (CanMoveTo(Vector2Int.left)) { + transform.Translate(Vector3.left);} } - if (Input.GetKeyDown(KeyCode.D)) + else if (Input.GetKeyDown(KeyCode.D)) { - if (CanMoveTo(Vector2Int.right)) transform.Translate(Vector3.right); + if (CanMoveTo(Vector2Int.right)) { + transform.Translate(Vector3.right); + } } - if (Input.GetKeyDown(KeyCode.W)) + else if (Input.GetKeyDown(KeyCode.W)) { - if (CanMoveTo(Vector2Int.up)) transform.Translate(Vector3.up); + if (CanMoveTo(Vector2Int.up)) { + transform.Translate(Vector3.up); + } } - if (Input.GetKeyDown(KeyCode.S)) + else if (Input.GetKeyDown(KeyCode.S)) { - if (CanMoveTo(Vector2Int.down)) transform.Translate(Vector3.down); + if (CanMoveTo(Vector2Int.down)) { + transform.Translate(Vector3.down); + } } - // Qui c'è da aggiungere la condizione per il controllo degli hp + } bool CanMoveTo(Vector2Int direction) { - Tile tile; return map.GetTile(direction).walkable; } } diff --git a/Assets/Sprites/PurpleTileset2.png.meta b/Assets/Sprites/PurpleTileset2.png.meta new file mode 100644 index 0000000..9866600 --- /dev/null +++ b/Assets/Sprites/PurpleTileset2.png.meta @@ -0,0 +1,90 @@ +fileFormatVersion: 2 +guid: fa4c9841fd8a5fb4f94ff78c95301065 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 1f47e62ae7a531443a5dba842e499602 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: From 6c875795a8fa5196f572e243f8222a167ebbd374 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 17:57:01 +0200 Subject: [PATCH 04/10] Do stuff --- ...uteDrawer.cs => CustomAttributeDrawers.cs} | 18 ++++++ .../CustomAttributeDrawers.cs.meta} | 2 +- Assets/Scripts/BeforeStartAttribute.cs | 5 -- Assets/Scripts/CustomAttributes.cs | 5 ++ .../CustomAttributes.cs.meta} | 2 +- Assets/Scripts/Map.cs | 5 ++ Assets/Scripts/Monster.cs | 40 ++++++++++++ ...StartAttribute.cs.meta => Monster.cs.meta} | 2 +- Assets/Scripts/Mostro.cs | 64 ------------------- Assets/Scripts/Player.cs | 43 +++++++------ 10 files changed, 96 insertions(+), 90 deletions(-) rename Assets/Editor/{BeforeStartAttributeDrawer.cs => CustomAttributeDrawers.cs} (55%) rename Assets/{Scripts/Mostro.cs.meta => Editor/CustomAttributeDrawers.cs.meta} (83%) delete mode 100644 Assets/Scripts/BeforeStartAttribute.cs create mode 100644 Assets/Scripts/CustomAttributes.cs rename Assets/{Editor/BeforeStartAttributeDrawer.cs.meta => Scripts/CustomAttributes.cs.meta} (83%) create mode 100644 Assets/Scripts/Monster.cs rename Assets/Scripts/{BeforeStartAttribute.cs.meta => Monster.cs.meta} (83%) delete mode 100644 Assets/Scripts/Mostro.cs diff --git a/Assets/Editor/BeforeStartAttributeDrawer.cs b/Assets/Editor/CustomAttributeDrawers.cs similarity index 55% rename from Assets/Editor/BeforeStartAttributeDrawer.cs rename to Assets/Editor/CustomAttributeDrawers.cs index 19006b1..babc351 100644 --- a/Assets/Editor/BeforeStartAttributeDrawer.cs +++ b/Assets/Editor/CustomAttributeDrawers.cs @@ -18,4 +18,22 @@ public class BeforeStartAttributeDrawer : PropertyDrawer EditorGUI.PropertyField(position, property, label, true); GUI.enabled = true; } +} + +[CustomPropertyDrawer(typeof(AfterStartAttribute))] +public class AfterStartAttributeDrawer : PropertyDrawer +{ + // Necessary since some properties tend to collapse smaller than their content + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return EditorGUI.GetPropertyHeight(property, label, true); + } + + // Draw a disabled property field + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + GUI.enabled = Application.isPlaying; + EditorGUI.PropertyField(position, property, label, true); + GUI.enabled = true; + } } \ No newline at end of file diff --git a/Assets/Scripts/Mostro.cs.meta b/Assets/Editor/CustomAttributeDrawers.cs.meta similarity index 83% rename from Assets/Scripts/Mostro.cs.meta rename to Assets/Editor/CustomAttributeDrawers.cs.meta index 31bb5e3..2c1c0f3 100644 --- a/Assets/Scripts/Mostro.cs.meta +++ b/Assets/Editor/CustomAttributeDrawers.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d484827da1a4f984c837dbfb9f970bdd +guid: cd8509fca2c0ebe47acb277e2aed11f2 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/BeforeStartAttribute.cs b/Assets/Scripts/BeforeStartAttribute.cs deleted file mode 100644 index cd1cf30..0000000 --- a/Assets/Scripts/BeforeStartAttribute.cs +++ /dev/null @@ -1,5 +0,0 @@ -using UnityEngine; - -public class BeforeStartAttribute : PropertyAttribute { - -} \ No newline at end of file diff --git a/Assets/Scripts/CustomAttributes.cs b/Assets/Scripts/CustomAttributes.cs new file mode 100644 index 0000000..01377f1 --- /dev/null +++ b/Assets/Scripts/CustomAttributes.cs @@ -0,0 +1,5 @@ +using UnityEngine; + +public class BeforeStartAttribute : PropertyAttribute {} + +public class AfterStartAttribute : PropertyAttribute {} \ No newline at end of file diff --git a/Assets/Editor/BeforeStartAttributeDrawer.cs.meta b/Assets/Scripts/CustomAttributes.cs.meta similarity index 83% rename from Assets/Editor/BeforeStartAttributeDrawer.cs.meta rename to Assets/Scripts/CustomAttributes.cs.meta index 4216c56..6e0a606 100644 --- a/Assets/Editor/BeforeStartAttributeDrawer.cs.meta +++ b/Assets/Scripts/CustomAttributes.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 13bad693cf0c2634ea1e2be679edf00f +guid: 6fdc88abee025004d9040a4026bfcb11 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index 0da467c..182bf0a 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -154,6 +154,11 @@ public class Map : MonoBehaviour return tile; } + public bool CanMoveTo(Vector2Int direction) + { + return GetTile(direction).walkable; + } + private void InitTile(Vector2Int position, bool walkable, Sprite tileSprite, bool roomPart) { Tile tile = GetTile(position); tile.walkable = walkable; diff --git a/Assets/Scripts/Monster.cs b/Assets/Scripts/Monster.cs new file mode 100644 index 0000000..f84b5da --- /dev/null +++ b/Assets/Scripts/Monster.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Monster : MonoBehaviour +{ + public int hpMax; + public int hp; + public bool isUndead; + public int movesPerTurn; + public bool hasSpottedPlayer; + + [BeforeStartAttribute] + public Sprite sprite; + + private Map map; + + // Start is called before the first frame update + void Start() + { + map = GameObject.FindGameObjectWithTag("Map").GetComponent(); + hasSpottedPlayer = false; + } + + void Turn(){ + int direction = Random.Range(0, 4); + if (direction == 0 && map.CanMoveTo(Vector2Int.left)){ + transform.Translate(Vector3.left); + } + else if (direction == 1 && map.CanMoveTo(Vector2Int.right)){ + transform.Translate(Vector3.right); + } + else if (direction == 2 && map.CanMoveTo(Vector2Int.up)){ + transform.Translate(Vector3.up); + } + else if (direction == 3 && map.CanMoveTo(Vector2Int.left)){ + transform.Translate(Vector3.left); + } + } +} diff --git a/Assets/Scripts/BeforeStartAttribute.cs.meta b/Assets/Scripts/Monster.cs.meta similarity index 83% rename from Assets/Scripts/BeforeStartAttribute.cs.meta rename to Assets/Scripts/Monster.cs.meta index 68df79c..f99ee29 100644 --- a/Assets/Scripts/BeforeStartAttribute.cs.meta +++ b/Assets/Scripts/Monster.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ec73aa347f0168f4f95e1acbd3072646 +guid: a72ad0eb2136f284bab78f19fa561bb8 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Mostro.cs b/Assets/Scripts/Mostro.cs deleted file mode 100644 index cf9d969..0000000 --- a/Assets/Scripts/Mostro.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/* -public class Mostro : MonoBehaviour -{ - public string nome; - public Sprite sprite; - public int hpmax, hp, exp; - public bool is_undead; - public enum speed {slow, standard, fast}; - private bool player_spotted; - public Map map; - // Start is called before the first frame update - void Start() - { - map = gameObjectMappa.GetComponent(); - player_spotted = false; - } - - // Update is called once per frame - void Update() - { - if (!player_spotted){ - roam(); - } - //Da mettere il pathfinding per quando trova il personaggio - } - void roam(){ - while (true) - { - int direction = Random.Range(1, 5); - if (direction==1 && is_valid_movement("left")){ - transform.Translate(Vector3.left); - break; - } - else if (direction==2 && is_valid_movement("right")){ - transform.Translate(Vector3.right); - break; - } - else if (direction==3 && is_valid_movement("up")){ - transform.Translate(Vector3.up); - break; - } - else if (is_valid_movement("down")){ - transform.Translate(Vector3.up); - break; - } - } - } - bool is_valid_movement(string direction) - { - Tile tile; - int posX = (int) transform.position.x; - int posY = (int) transform.position.y; - if (direction == "left") tile = map.GetTile(posX - 1, posY); - else if (direction == "right") tile = map.GetTile(posX + 1, posY); - else if (direction == "up") tile = map.GetTile(posX, posY + 1); - else tile = map.GetTile(posX, posY - 1); - return tile.walkable; - } -} -*/ diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index dffaeaf..86df64c 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -4,18 +4,23 @@ using UnityEngine; public class Player : MonoBehaviour { - private int exp, level, hp, maxhp; - public int startingHp; - public Map map; - //TODO: Aggiungi gli oggetti in inventario + public int exp; + public int level; + public int hpMax; + + [AfterStartAttribute] + public int hp; + + private Map map; + private GameObject gameController; - // Start is called before the first frame update void Start() { - hp = startingHp; + map = GameObject.FindGameObjectWithTag("Map").GetComponent(); + gameController = GameObject.FindGameObjectWithTag("GameController"); + hp = hpMax; } - // Update is called once per frame void Update() { CheckForMovementInput(); @@ -26,32 +31,34 @@ public class Player : MonoBehaviour bool hasMoved = false; if (Input.GetKeyDown(KeyCode.A)) { - if (CanMoveTo(Vector2Int.left)) { - transform.Translate(Vector3.left);} + if (map.CanMoveTo(Vector2Int.left)) { + transform.Translate(Vector3.left); + hasMoved = true; + } } else if (Input.GetKeyDown(KeyCode.D)) { - if (CanMoveTo(Vector2Int.right)) { + if (map.CanMoveTo(Vector2Int.right)) { transform.Translate(Vector3.right); + hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.W)) { - if (CanMoveTo(Vector2Int.up)) { + if (map.CanMoveTo(Vector2Int.up)) { transform.Translate(Vector3.up); + hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.S)) { - if (CanMoveTo(Vector2Int.down)) { + if (map.CanMoveTo(Vector2Int.down)) { transform.Translate(Vector3.down); + hasMoved = true; } } - - } - - bool CanMoveTo(Vector2Int direction) - { - return map.GetTile(direction).walkable; + if(hasMoved) { + gameController.BroadcastMessage("Turn"); + } } } From ca23b945dfcab3ff6ed957282d5281c8bdd8f29f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 19:04:27 +0200 Subject: [PATCH 05/10] cose --- Assets/Prefabs/Map.prefab | 18 +++++- Assets/Scenes/Steffo.unity | 36 ++++++++++-- Assets/Scripts/Map.cs | 81 ++++++++++++++------------ Assets/Scripts/Monster.cs | 2 +- Assets/Sprites/PurpleTileset2.png.meta | 24 +++++++- ProjectSettings/TagManager.asset | 3 +- 6 files changed, 119 insertions(+), 45 deletions(-) diff --git a/Assets/Prefabs/Map.prefab b/Assets/Prefabs/Map.prefab index e8043ff..a7687dc 100644 --- a/Assets/Prefabs/Map.prefab +++ b/Assets/Prefabs/Map.prefab @@ -45,8 +45,22 @@ MonoBehaviour: m_EditorClassIdentifier: mapSize: 30 roomsToGenerate: 5 + minRoomSize: 2 + maxRoomSize: 6 + maxRoomIterations: 100 wallSprite: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3} - roomSprite: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - corridorSprite: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + floorSprites: + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, type: 3} tilePrefab: {fileID: 3219556109866242471, guid: 0e0b618b5499bbb40b076c0291d55487, type: 3} diff --git a/Assets/Scenes/Steffo.unity b/Assets/Scenes/Steffo.unity index d68be2b..7dd5a86 100644 --- a/Assets/Scenes/Steffo.unity +++ b/Assets/Scenes/Steffo.unity @@ -341,15 +341,43 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, type: 3} - propertyPath: wallSprite + propertyPath: floorSprites.Array.size + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, + type: 3} + propertyPath: roomsToGenerate + value: 10 + objectReference: {fileID: 0} + - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, + type: 3} + propertyPath: floorSprites.Array.data[2] value: - objectReference: {fileID: 21300000, guid: 0121970e693ee0a4d987bd5fe694ad67, + objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, type: 3} - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, type: 3} - propertyPath: corridorSprite + propertyPath: floorSprites.Array.data[3] value: - objectReference: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, + objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, + type: 3} + - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, + type: 3} + propertyPath: floorSprites.Array.data[4] + value: + objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, + type: 3} + - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, + type: 3} + propertyPath: floorSprites.Array.data[5] + value: + objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, + type: 3} + - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, + type: 3} + propertyPath: floorSprites.Array.data[1] + value: + objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: cd714ea41cb7c454994bf0f5ad99abd1, type: 3} diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index 182bf0a..3c5b1f7 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -18,10 +18,10 @@ public class MapRoom { public readonly Vector2Int end; public readonly int mapSize; - public MapRoom(int mapSize, int maxRoomSize) { + public MapRoom(int mapSize, int maxRoomSize, int minRoomSize) { this.mapSize = mapSize; - start = new Vector2Int(Random.Range(0, mapSize), Random.Range(0, mapSize)); - end = new Vector2Int(Random.Range(0, mapSize), Random.Range(0, mapSize)); + start = new Vector2Int(Random.Range(1, mapSize-1), Random.Range(1, mapSize-1)); + end = new Vector2Int(Random.Range(1, mapSize-1), Random.Range(1, mapSize-1)); if(start.x > end.x) { int swap = start.x; start.x = end.x; @@ -40,36 +40,30 @@ public class MapRoom { end.y--; start.y++; } - } - - public bool RightCheck() { - return end.x < mapSize-1; + while(end.x - start.x < minRoomSize) { + end.x++; + start.x--; + } + while(end.y - start.y < minRoomSize) { + end.y++; + start.y--; + } + start.Clamp(new Vector2Int(1, 1), new Vector2Int(mapSize-1, mapSize-1)); + end.Clamp(new Vector2Int(1, 1), new Vector2Int(mapSize-1, mapSize-1)); } public Vector2Int RightCorridorAttachment() { return new Vector2Int(end.x+1, Random.Range(start.y, end.y+1)); } - public bool LeftCheck() { - return start.x > 0; - } - public Vector2Int LeftCorridorAttachment() { return new Vector2Int(start.x-1, Random.Range(start.y, end.y+1)); } - - public bool TopCheck() { - return end.y < mapSize-1; - } public Vector2Int TopCorridorAttachment() { return new Vector2Int(Random.Range(start.x, end.x+1), end.y+1); } - public bool BottomCheck() { - return start.y > 0; - } - public Vector2Int BottomCorridorAttachment() { return new Vector2Int(Random.Range(start.x, end.x+1), start.y-1); } @@ -90,10 +84,10 @@ public class MapCorridor { public MapCorridor(MapRoom from, MapRoom to, int mapSize) { List corridorModes = new List(); //Find allowed CorridorModes - if(from.end.y <= to.start.y && from.BottomCheck() && to.TopCheck()) corridorModes.Add(CorridorModes.bottomToTop); - if(from.start.y >= to.end.y && from.TopCheck() && to.BottomCheck()) corridorModes.Add(CorridorModes.topToBottom); - if(from.end.x <= to.start.y && from.RightCheck() && to.LeftCheck()) corridorModes.Add(CorridorModes.rightToLeft); - if(from.start.y >= to.end.y && from.LeftCheck() && to.RightCheck()) corridorModes.Add(CorridorModes.leftToRight); + if(from.end.y <= to.start.y) corridorModes.Add(CorridorModes.bottomToTop); + if(from.start.y >= to.end.y) corridorModes.Add(CorridorModes.topToBottom); + if(from.end.x <= to.start.x) corridorModes.Add(CorridorModes.rightToLeft); + if(from.start.x >= to.end.x) corridorModes.Add(CorridorModes.leftToRight); //Select and use a corridor mode if(corridorModes.Count < 1) throw new ImpossibleCorridorError(); CorridorModes corridorMode = corridorModes[Random.Range(0, corridorModes.Count)]; @@ -115,6 +109,9 @@ public class MapCorridor { } //50% horizontal_priority = Random.Range(0f, 1f) >= 0.5f; + + start.Clamp(new Vector2Int(1, 1), new Vector2Int(mapSize-1, mapSize-1)); + end.Clamp(new Vector2Int(1, 1), new Vector2Int(mapSize-1, mapSize-1)); } } @@ -126,6 +123,9 @@ public class Map : MonoBehaviour [BeforeStartAttribute] public int roomsToGenerate = 5; + [BeforeStartAttribute] + public int minRoomSize = 2; + [BeforeStartAttribute] public int maxRoomSize = 6; @@ -136,10 +136,7 @@ public class Map : MonoBehaviour public Sprite wallSprite; [BeforeStartAttribute] - public Sprite roomSprite; - - [BeforeStartAttribute] - public Sprite corridorSprite; + public List floorSprites; [BeforeStartAttribute] public GameObject tilePrefab; @@ -156,7 +153,12 @@ public class Map : MonoBehaviour public bool CanMoveTo(Vector2Int direction) { - return GetTile(direction).walkable; + try { + return GetTile(direction).walkable; + } + catch(System.ArgumentOutOfRangeException) { + return false; + } } private void InitTile(Vector2Int position, bool walkable, Sprite tileSprite, bool roomPart) { @@ -183,7 +185,7 @@ public class Map : MonoBehaviour private void PlaceRoom(MapRoom mr) { for(int x = mr.start.x; x <= mr.end.x; x++) { for(int y = mr.start.y; y <= mr.end.y; y++) { - InitTile(new Vector2Int(x, y), true, roomSprite, true); + InitTile(new Vector2Int(x, y), true, GetFloorTileSprite(), true); } } } @@ -202,17 +204,17 @@ public class Map : MonoBehaviour private void PlaceCorridor(MapCorridor mc) { Vector2Int cursor = new Vector2Int(mc.start.x, mc.start.y); - InitTile(cursor, true, corridorSprite, false); + InitTile(cursor, true, GetFloorTileSprite(), false); if(mc.horizontal_priority) { while(cursor.x != mc.end.x) { if(cursor.x > mc.end.x) cursor.x--; else cursor.x++; - InitTile(cursor, true, corridorSprite, false); + InitTile(cursor, true, GetFloorTileSprite(), false); } while(cursor.y != mc.end.y) { if(cursor.y > mc.end.y) cursor.y--; else cursor.y++; - InitTile(cursor, true, corridorSprite, false); + InitTile(cursor, true, GetFloorTileSprite(), false); } } else @@ -220,12 +222,12 @@ public class Map : MonoBehaviour while(cursor.y != mc.end.y) { if(cursor.y > mc.end.y) cursor.y--; else cursor.y++; - InitTile(cursor, true, corridorSprite, false); + InitTile(cursor, true, GetFloorTileSprite(), false); } while(cursor.x != mc.end.x) { if(cursor.x > mc.end.x) cursor.x--; else cursor.x++; - InitTile(cursor, true, corridorSprite, false); + InitTile(cursor, true, GetFloorTileSprite(), false); } } } @@ -235,11 +237,13 @@ public class Map : MonoBehaviour int roomIterations = 0; while(rooms.Count < roomsToGenerate && roomIterations < maxRoomIterations) { roomIterations++; - MapRoom room = new MapRoom(mapSize, maxRoomSize); + MapRoom room = new MapRoom(mapSize, maxRoomSize, minRoomSize); if(ScanRoom(room)) { + //Fill with the room PlaceRoom(room); rooms.Add(room); } + //Place a corridor if(rooms.Count > 1) { MapRoom from = rooms[rooms.Count-2]; MapRoom to = rooms[rooms.Count-1]; @@ -247,11 +251,16 @@ public class Map : MonoBehaviour MapCorridor corridor = new MapCorridor(from, to, mapSize); PlaceCorridor(corridor); } - catch (ImpossibleCorridorError) {} + catch (ImpossibleCorridorError) { + } } } } + private Sprite GetFloorTileSprite() { + return floorSprites[Random.Range(0, floorSprites.Count)]; + } + private void Start() { //Initialize everything diff --git a/Assets/Scripts/Monster.cs b/Assets/Scripts/Monster.cs index f84b5da..e9efb1a 100644 --- a/Assets/Scripts/Monster.cs +++ b/Assets/Scripts/Monster.cs @@ -16,7 +16,7 @@ public class Monster : MonoBehaviour private Map map; // Start is called before the first frame update - void Start() + private void Start() { map = GameObject.FindGameObjectWithTag("Map").GetComponent(); hasSpottedPlayer = false; diff --git a/Assets/Sprites/PurpleTileset2.png.meta b/Assets/Sprites/PurpleTileset2.png.meta index 9866600..ead95e1 100644 --- a/Assets/Sprites/PurpleTileset2.png.meta +++ b/Assets/Sprites/PurpleTileset2.png.meta @@ -45,7 +45,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 40 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -69,6 +69,28 @@ 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: 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 1c92a78..82e2d19 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -3,7 +3,8 @@ --- !u!78 &1 TagManager: serializedVersion: 2 - tags: [] + tags: + - Map layers: - Default - TransparentFX From a76ef94777e826a551d488d6c743ae34ece21efc Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 19:19:37 +0200 Subject: [PATCH 06/10] Fix map generation --- Assets/Scripts/Map.cs | 53 ++++--------------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index 3c5b1f7..7267d2f 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -52,28 +52,9 @@ public class MapRoom { end.Clamp(new Vector2Int(1, 1), new Vector2Int(mapSize-1, mapSize-1)); } - public Vector2Int RightCorridorAttachment() { - return new Vector2Int(end.x+1, Random.Range(start.y, end.y+1)); + public Vector2Int RandomPoint() { + return new Vector2Int(Random.Range(start.x, end.x+1), Random.Range(start.y, end.y+1)); } - - public Vector2Int LeftCorridorAttachment() { - return new Vector2Int(start.x-1, Random.Range(start.y, end.y+1)); - } - - public Vector2Int TopCorridorAttachment() { - return new Vector2Int(Random.Range(start.x, end.x+1), end.y+1); - } - - public Vector2Int BottomCorridorAttachment() { - return new Vector2Int(Random.Range(start.x, end.x+1), start.y-1); - } -} - -public enum CorridorModes { - bottomToTop, - topToBottom, - rightToLeft, - leftToRight } public class MapCorridor { @@ -82,36 +63,10 @@ public class MapCorridor { public readonly bool horizontal_priority; public MapCorridor(MapRoom from, MapRoom to, int mapSize) { - List corridorModes = new List(); - //Find allowed CorridorModes - if(from.end.y <= to.start.y) corridorModes.Add(CorridorModes.bottomToTop); - if(from.start.y >= to.end.y) corridorModes.Add(CorridorModes.topToBottom); - if(from.end.x <= to.start.x) corridorModes.Add(CorridorModes.rightToLeft); - if(from.start.x >= to.end.x) corridorModes.Add(CorridorModes.leftToRight); - //Select and use a corridor mode - if(corridorModes.Count < 1) throw new ImpossibleCorridorError(); - CorridorModes corridorMode = corridorModes[Random.Range(0, corridorModes.Count)]; - if(corridorMode == CorridorModes.bottomToTop) { - start = from.BottomCorridorAttachment(); - end = to.TopCorridorAttachment(); - } - if(corridorMode == CorridorModes.topToBottom) { - start = from.TopCorridorAttachment(); - end = to.BottomCorridorAttachment(); - } - if(corridorMode == CorridorModes.rightToLeft) { - start = from.RightCorridorAttachment(); - end = to.LeftCorridorAttachment(); - } - if(corridorMode == CorridorModes.leftToRight) { - start = from.LeftCorridorAttachment(); - end = to.RightCorridorAttachment(); - } + start = from.RandomPoint(); + end = to.RandomPoint(); //50% horizontal_priority = Random.Range(0f, 1f) >= 0.5f; - - start.Clamp(new Vector2Int(1, 1), new Vector2Int(mapSize-1, mapSize-1)); - end.Clamp(new Vector2Int(1, 1), new Vector2Int(mapSize-1, mapSize-1)); } } From 45ca06e33f36308779cbda9a9ac528549ecd75ee Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Sat, 27 Apr 2019 19:19:46 +0200 Subject: [PATCH 07/10] Fixed player movement script It works --- Assets/Scripts/Player.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 86df64c..0a2d84c 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -29,30 +29,33 @@ public class Player : MonoBehaviour void CheckForMovementInput() { bool hasMoved = false; + Vector2Int posizione = new Vector2Int(); + posizione.x = (int)transform.position.x+1; + posizione.y = (int)transform.position.y+1; if (Input.GetKeyDown(KeyCode.A)) { - if (map.CanMoveTo(Vector2Int.left)) { + if (map.CanMoveTo(posizione + Vector2Int.left)) { transform.Translate(Vector3.left); hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.D)) { - if (map.CanMoveTo(Vector2Int.right)) { + if (map.CanMoveTo(posizione + Vector2Int.right)) { transform.Translate(Vector3.right); hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.W)) { - if (map.CanMoveTo(Vector2Int.up)) { + if (map.CanMoveTo(posizione + Vector2Int.up)) { transform.Translate(Vector3.up); hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.S)) { - if (map.CanMoveTo(Vector2Int.down)) { + if (map.CanMoveTo(posizione + Vector2Int.down)) { transform.Translate(Vector3.down); hasMoved = true; } From 147f063d3f307a64b5b3db54ae160a6453dbc640 Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Sat, 27 Apr 2019 19:54:06 +0200 Subject: [PATCH 08/10] Add monster awareness Now monsters should be aware of the player if he's in 3 tiles from them --- Assets/Animations.meta | 8 -------- Assets/Animators.meta | 8 -------- Assets/Assets.meta | 8 -------- Assets/PhysMats.meta | 8 -------- Assets/Scripts/Monster.cs | 36 +++++++++++++++++++++++++++--------- Assets/Sounds.meta | 8 -------- 6 files changed, 27 insertions(+), 49 deletions(-) delete mode 100644 Assets/Animations.meta delete mode 100644 Assets/Animators.meta delete mode 100644 Assets/Assets.meta delete mode 100644 Assets/PhysMats.meta delete mode 100644 Assets/Sounds.meta diff --git a/Assets/Animations.meta b/Assets/Animations.meta deleted file mode 100644 index b2a79e2..0000000 --- a/Assets/Animations.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ef3d86d84c224344a94715cdfa9fe32c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Animators.meta b/Assets/Animators.meta deleted file mode 100644 index 7ff80b8..0000000 --- a/Assets/Animators.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 043f304edcc831c4ea9fcf0e1a2e520d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Assets.meta b/Assets/Assets.meta deleted file mode 100644 index 4eba494..0000000 --- a/Assets/Assets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0460346d99d385241a6d87bbd10aceb8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/PhysMats.meta b/Assets/PhysMats.meta deleted file mode 100644 index bc5b1b2..0000000 --- a/Assets/PhysMats.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e823a56cb429e4b49becdc740fba66b9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Monster.cs b/Assets/Scripts/Monster.cs index e9efb1a..976a1d3 100644 --- a/Assets/Scripts/Monster.cs +++ b/Assets/Scripts/Monster.cs @@ -14,27 +14,45 @@ public class Monster : MonoBehaviour public Sprite sprite; private Map map; + + private Player player; // Start is called before the first frame update private void Start() { map = GameObject.FindGameObjectWithTag("Map").GetComponent(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); hasSpottedPlayer = false; } void Turn(){ - int direction = Random.Range(0, 4); - if (direction == 0 && map.CanMoveTo(Vector2Int.left)){ - transform.Translate(Vector3.left); + IsPlayerNear(); + if (!hasSpottedPlayer){ + int direction = Random.Range(0, 4); + if (direction == 0 && map.CanMoveTo(Vector2Int.left)){ + transform.Translate(Vector3.left); + } + else if (direction == 1 && map.CanMoveTo(Vector2Int.right)){ + transform.Translate(Vector3.right); + } + else if (direction == 2 && map.CanMoveTo(Vector2Int.up)){ + transform.Translate(Vector3.up); + } + else if (direction == 3 && map.CanMoveTo(Vector2Int.left)){ + transform.Translate(Vector3.left); + } } - else if (direction == 1 && map.CanMoveTo(Vector2Int.right)){ - transform.Translate(Vector3.right); + else{ + //Put here pathfinding code } - else if (direction == 2 && map.CanMoveTo(Vector2Int.up)){ - transform.Translate(Vector3.up); + } + + void IsPlayerNear(){ + if ((player.transform.position.x-transform.position.x)<=3 || (transform.position.x-player.transform.position.x)>=-3){ + hasSpottedPlayer=true; } - else if (direction == 3 && map.CanMoveTo(Vector2Int.left)){ - transform.Translate(Vector3.left); + if ((player.transform.position.y-transform.position.y)<=3 || (transform.position.y-player.transform.position.y)>=-3){ + hasSpottedPlayer=true; } } } diff --git a/Assets/Sounds.meta b/Assets/Sounds.meta deleted file mode 100644 index 5fd147f..0000000 --- a/Assets/Sounds.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 19c0d85909aede34bb371863f187b9e0 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From a23d6a313446e249c0e6b362dd6760587ddb30e0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 20:13:28 +0200 Subject: [PATCH 09/10] Commit stuff? --- Assets/Animations.meta | 8 ++ Assets/Animators.meta | 8 ++ Assets/Assets.meta | 8 ++ Assets/PhysMats.meta | 8 ++ Assets/Prefabs/Enemy.prefab | 51 +++++++++ Assets/Prefabs/Enemy.prefab.meta | 7 ++ Assets/Prefabs/GameController.prefab | 164 ++++++++++++++++++++++++++- Assets/Prefabs/Player.prefab | 49 ++++++++ Assets/Prefabs/Player.prefab.meta | 7 ++ Assets/Scenes/Steffo.unity | 58 ++-------- Assets/Scripts/Map.cs | 2 +- Assets/Sounds.meta | 8 ++ 12 files changed, 325 insertions(+), 53 deletions(-) create mode 100644 Assets/Animations.meta create mode 100644 Assets/Animators.meta create mode 100644 Assets/Assets.meta create mode 100644 Assets/PhysMats.meta create mode 100644 Assets/Prefabs/Enemy.prefab create mode 100644 Assets/Prefabs/Enemy.prefab.meta create mode 100644 Assets/Prefabs/Player.prefab create mode 100644 Assets/Prefabs/Player.prefab.meta create mode 100644 Assets/Sounds.meta diff --git a/Assets/Animations.meta b/Assets/Animations.meta new file mode 100644 index 0000000..b2a79e2 --- /dev/null +++ b/Assets/Animations.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef3d86d84c224344a94715cdfa9fe32c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animators.meta b/Assets/Animators.meta new file mode 100644 index 0000000..7ff80b8 --- /dev/null +++ b/Assets/Animators.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 043f304edcc831c4ea9fcf0e1a2e520d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Assets.meta b/Assets/Assets.meta new file mode 100644 index 0000000..4eba494 --- /dev/null +++ b/Assets/Assets.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0460346d99d385241a6d87bbd10aceb8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PhysMats.meta b/Assets/PhysMats.meta new file mode 100644 index 0000000..bc5b1b2 --- /dev/null +++ b/Assets/PhysMats.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e823a56cb429e4b49becdc740fba66b9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab new file mode 100644 index 0000000..6f6dade --- /dev/null +++ b/Assets/Prefabs/Enemy.prefab @@ -0,0 +1,51 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1164136568549368904 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2043533519980591455} + - component: {fileID: 7440667849060313208} + m_Layer: 0 + m_Name: Enemy + m_TagString: Untagged + m_Icon: {fileID: 7174288486110832750, guid: 0000000000000000d000000000000000, type: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2043533519980591455 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164136568549368904} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 1.7943853, y: 1.0483005, z: -91.41211} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7440667849060313208 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164136568549368904} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a72ad0eb2136f284bab78f19fa561bb8, type: 3} + m_Name: + m_EditorClassIdentifier: + hpMax: 0 + hp: 0 + isUndead: 0 + movesPerTurn: 0 + hasSpottedPlayer: 0 + sprite: {fileID: 0} diff --git a/Assets/Prefabs/Enemy.prefab.meta b/Assets/Prefabs/Enemy.prefab.meta new file mode 100644 index 0000000..feab3cc --- /dev/null +++ b/Assets/Prefabs/Enemy.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a4aeecfb369f0974490d158ef9489335 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab index e2319f9..9bfde67 100644 --- a/Assets/Prefabs/GameController.prefab +++ b/Assets/Prefabs/GameController.prefab @@ -23,10 +23,168 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2866215097817665852} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.18855336, y: 0.26111984, z: 34.533203} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] + m_Children: + - {fileID: 5874724150191971617} + - {fileID: 368318821130531976} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &1819628990077898199 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 3211721187637284538} + m_Modifications: + - target: {fileID: 1164136568549368904, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_Name + value: Enemy + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalPosition.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: a4aeecfb369f0974490d158ef9489335, type: 3} +--- !u!4 &368318821130531976 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, + type: 3} + m_PrefabInstance: {fileID: 1819628990077898199} + m_PrefabAsset: {fileID: 0} +--- !u!1001 &8735699022713547399 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 3211721187637284538} + m_Modifications: + - target: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_Name + value: Player + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_Icon + value: + objectReference: {fileID: -5397416234189338067, guid: 0000000000000000d000000000000000, + type: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: e8ff38be23e53db40a793f6959c6f4ec, type: 3} +--- !u!4 &5874724150191971617 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + m_PrefabInstance: {fileID: 8735699022713547399} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab new file mode 100644 index 0000000..d5ee144 --- /dev/null +++ b/Assets/Prefabs/Player.prefab @@ -0,0 +1,49 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2935319493830293412 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2935319493830293414} + - component: {fileID: 2935319493830293413} + m_Layer: 0 + m_Name: Player + m_TagString: Player + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2935319493830293414 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2935319493830293412} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2935319493830293413 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2935319493830293412} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4de6b97c3d785d146a0df2c1c078fe91, type: 3} + m_Name: + m_EditorClassIdentifier: + exp: 0 + level: 0 + hpMax: 0 + hp: 0 diff --git a/Assets/Prefabs/Player.prefab.meta b/Assets/Prefabs/Player.prefab.meta new file mode 100644 index 0000000..87e72f3 --- /dev/null +++ b/Assets/Prefabs/Player.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e8ff38be23e53db40a793f6959c6f4ec +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Steffo.unity b/Assets/Scenes/Steffo.unity index 7dd5a86..3c5f20b 100644 --- a/Assets/Scenes/Steffo.unity +++ b/Assets/Scenes/Steffo.unity @@ -201,9 +201,9 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &5874724150884597007 +--- !u!1001 &1591665583 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 @@ -218,32 +218,32 @@ PrefabInstance: - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalPosition.x - value: 0.18855336 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalPosition.y - value: 0.26111984 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalPosition.z - value: 34.533203 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalRotation.x - value: -0 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalRotation.y - value: -0 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalRotation.z - value: -0 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} @@ -253,7 +253,7 @@ PrefabInstance: - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_RootOrder - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} @@ -339,45 +339,5 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: floorSprites.Array.size - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: roomsToGenerate - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: floorSprites.Array.data[2] - value: - objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, - type: 3} - - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: floorSprites.Array.data[3] - value: - objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, - type: 3} - - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: floorSprites.Array.data[4] - value: - objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, - type: 3} - - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: floorSprites.Array.data[5] - value: - objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, - type: 3} - - target: {fileID: 6907631410461015020, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: floorSprites.Array.data[1] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: cd714ea41cb7c454994bf0f5ad99abd1, type: 3} diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index 7267d2f..d8ec176 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -120,7 +120,7 @@ public class Map : MonoBehaviour Tile tile = GetTile(position); tile.walkable = walkable; tile.sprite = tileSprite; - tile.roomPart = roomPart; + tile.roomPart |= roomPart; } private void FillWithWalls() { diff --git a/Assets/Sounds.meta b/Assets/Sounds.meta new file mode 100644 index 0000000..5fd147f --- /dev/null +++ b/Assets/Sounds.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 19c0d85909aede34bb371863f187b9e0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From e9d1f2edb55d86f4466ca86d2b672c868d19f175 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 22:19:35 +0200 Subject: [PATCH 10/10] Quite a lot of stuff --- Assets/Prefabs/Enemy.prefab | 51 ---- Assets/Prefabs/GameController.prefab | 272 ++++++++---------- Assets/Prefabs/Main Camera.prefab | 85 ++++++ ...ap.prefab.meta => Main Camera.prefab.meta} | 2 +- Assets/Prefabs/Map.prefab | 66 ----- Assets/Prefabs/Player.prefab | 134 ++++++++- Assets/Prefabs/Slime.prefab | 114 ++++++++ .../{Enemy.prefab.meta => Slime.prefab.meta} | 0 Assets/Prefabs/Tile.prefab | 5 +- Assets/Scenes/Steffo.unity | 180 +----------- Assets/Scripts/AI.cs | 10 + .../{Consumabile.cs.meta => AI.cs.meta} | 2 +- Assets/Scripts/AISlime.cs | 44 +++ .../{Object.cs.meta => AISlime.cs.meta} | 2 +- Assets/Scripts/Consumabile.cs | 34 --- Assets/Scripts/Entity.cs | 35 +++ Assets/Scripts/Entity.cs.meta | 11 + Assets/Scripts/Map.cs | 47 ++- Assets/Scripts/Map.cs.meta | 2 +- Assets/Scripts/Monster.cs | 47 +-- Assets/Scripts/Object.cs | 20 -- Assets/Scripts/Player.cs | 31 +- Assets/Scripts/TurnHandler.cs | 23 ++ Assets/Scripts/TurnHandler.cs.meta | 11 + ProjectSettings/TagManager.asset | 9 +- 25 files changed, 657 insertions(+), 580 deletions(-) delete mode 100644 Assets/Prefabs/Enemy.prefab create mode 100644 Assets/Prefabs/Main Camera.prefab rename Assets/Prefabs/{Map.prefab.meta => Main Camera.prefab.meta} (74%) delete mode 100644 Assets/Prefabs/Map.prefab create mode 100644 Assets/Prefabs/Slime.prefab rename Assets/Prefabs/{Enemy.prefab.meta => Slime.prefab.meta} (100%) create mode 100644 Assets/Scripts/AI.cs rename Assets/Scripts/{Consumabile.cs.meta => AI.cs.meta} (83%) create mode 100644 Assets/Scripts/AISlime.cs rename Assets/Scripts/{Object.cs.meta => AISlime.cs.meta} (83%) delete mode 100644 Assets/Scripts/Consumabile.cs create mode 100644 Assets/Scripts/Entity.cs create mode 100644 Assets/Scripts/Entity.cs.meta delete mode 100644 Assets/Scripts/Object.cs create mode 100644 Assets/Scripts/TurnHandler.cs create mode 100644 Assets/Scripts/TurnHandler.cs.meta diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab deleted file mode 100644 index 6f6dade..0000000 --- a/Assets/Prefabs/Enemy.prefab +++ /dev/null @@ -1,51 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &1164136568549368904 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2043533519980591455} - - component: {fileID: 7440667849060313208} - m_Layer: 0 - m_Name: Enemy - m_TagString: Untagged - m_Icon: {fileID: 7174288486110832750, guid: 0000000000000000d000000000000000, type: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &2043533519980591455 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1164136568549368904} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 1.7943853, y: 1.0483005, z: -91.41211} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &7440667849060313208 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1164136568549368904} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a72ad0eb2136f284bab78f19fa561bb8, type: 3} - m_Name: - m_EditorClassIdentifier: - hpMax: 0 - hp: 0 - isUndead: 0 - movesPerTurn: 0 - hasSpottedPlayer: 0 - sprite: {fileID: 0} diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab index 9bfde67..785b082 100644 --- a/Assets/Prefabs/GameController.prefab +++ b/Assets/Prefabs/GameController.prefab @@ -1,6 +1,6 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1 &2866215097817665852 +--- !u!1 &1792584738874209504 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -8,7 +8,7 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 3211721187637284538} + - component: {fileID: 1419775483983031142} m_Layer: 0 m_Name: GameController m_TagString: GameController @@ -16,175 +16,131 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &3211721187637284538 +--- !u!4 &1419775483983031142 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2866215097817665852} + m_GameObject: {fileID: 1792584738874209504} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 5874724150191971617} - - {fileID: 368318821130531976} + - {fileID: 8897064855631282258} + - {fileID: 3789201758602335435} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &1819628990077898199 -PrefabInstance: +--- !u!1 &5605884945823581445 +GameObject: m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 3211721187637284538} - m_Modifications: - - target: {fileID: 1164136568549368904, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_Name - value: Enemy - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalPosition.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_RootOrder - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: a4aeecfb369f0974490d158ef9489335, type: 3} ---- !u!4 &368318821130531976 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 2043533519980591455, guid: a4aeecfb369f0974490d158ef9489335, - type: 3} - m_PrefabInstance: {fileID: 1819628990077898199} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} ---- !u!1001 &8735699022713547399 -PrefabInstance: + serializedVersion: 6 + m_Component: + - component: {fileID: 3789201758602335435} + - component: {fileID: 5602184811824951751} + m_Layer: 0 + m_Name: Map + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3789201758602335435 +Transform: m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 3211721187637284538} - m_Modifications: - - target: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_Name - value: Player - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_Icon - value: - objectReference: {fileID: -5397416234189338067, guid: 0000000000000000d000000000000000, - type: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_RootOrder - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: e8ff38be23e53db40a793f6959c6f4ec, type: 3} ---- !u!4 &5874724150191971617 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 2935319493830293414, guid: e8ff38be23e53db40a793f6959c6f4ec, - type: 3} - m_PrefabInstance: {fileID: 8735699022713547399} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5605884945823581445} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1419775483983031142} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5602184811824951751 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5605884945823581445} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 052bc569472779a429bfc51246f723d4, type: 3} + m_Name: + m_EditorClassIdentifier: + mapSize: 40 + roomsToGenerate: 8 + minRoomSize: 2 + maxRoomSize: 8 + maxRoomIterations: 100 + wallSprite: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3} + floorSprites: + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} + - {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, type: 3} + tilePrefab: {fileID: 3219556109866242471, guid: 0e0b618b5499bbb40b076c0291d55487, + type: 3} + playerPrefab: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec, + type: 3} + enemyPrefabs: + - {fileID: 1164136568549368904, guid: a4aeecfb369f0974490d158ef9489335, type: 3} + enemiesToSpawn: 10 +--- !u!1 &8733140679003710819 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8897064855631282258} + - component: {fileID: 6815253418672446008} + m_Layer: 0 + m_Name: Entities + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8897064855631282258 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8733140679003710819} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1419775483983031142} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &6815253418672446008 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8733140679003710819} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2447171af2ad9634498f2d769d7f5200, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefabs/Main Camera.prefab b/Assets/Prefabs/Main Camera.prefab new file mode 100644 index 0000000..a69623d --- /dev/null +++ b/Assets/Prefabs/Main Camera.prefab @@ -0,0 +1,85 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7475959774386308610 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7475959774386308609} + - component: {fileID: 7475959774386308608} + - component: {fileID: 7475959774386308611} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7475959774386308609 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7475959774386308610} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &7475959774386308608 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7475959774386308610} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 1, g: 1, b: 1, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &7475959774386308611 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7475959774386308610} + m_Enabled: 1 diff --git a/Assets/Prefabs/Map.prefab.meta b/Assets/Prefabs/Main Camera.prefab.meta similarity index 74% rename from Assets/Prefabs/Map.prefab.meta rename to Assets/Prefabs/Main Camera.prefab.meta index f5813e2..03dd195 100644 --- a/Assets/Prefabs/Map.prefab.meta +++ b/Assets/Prefabs/Main Camera.prefab.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cd714ea41cb7c454994bf0f5ad99abd1 +guid: 04409c352bfbdea4b9830f11d7b4d40e PrefabImporter: externalObjects: {} userData: diff --git a/Assets/Prefabs/Map.prefab b/Assets/Prefabs/Map.prefab deleted file mode 100644 index a7687dc..0000000 --- a/Assets/Prefabs/Map.prefab +++ /dev/null @@ -1,66 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &7249059666095778526 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 7249059666095778521} - - component: {fileID: 6907631410461015020} - m_Layer: 0 - m_Name: Map - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &7249059666095778521 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7249059666095778526} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &6907631410461015020 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7249059666095778526} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 052bc569472779a429bfc51246f723d4, type: 3} - m_Name: - m_EditorClassIdentifier: - mapSize: 30 - roomsToGenerate: 5 - minRoomSize: 2 - maxRoomSize: 6 - maxRoomIterations: 100 - wallSprite: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3} - floorSprites: - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - - {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, type: 3} - tilePrefab: {fileID: 3219556109866242471, guid: 0e0b618b5499bbb40b076c0291d55487, - type: 3} diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index d5ee144..e43f461 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -10,6 +10,7 @@ GameObject: m_Component: - component: {fileID: 2935319493830293414} - component: {fileID: 2935319493830293413} + - component: {fileID: -5893075763862095451} m_Layer: 0 m_Name: Player m_TagString: Player @@ -24,10 +25,11 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2935319493830293412} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] + m_Children: + - {fileID: 2894367173346332699} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -43,7 +45,131 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4de6b97c3d785d146a0df2c1c078fe91, type: 3} m_Name: m_EditorClassIdentifier: - exp: 0 - level: 0 hpMax: 0 hp: 0 + sprite: {fileID: 21300000, guid: fe9c8eab186d5004eaad446d8e220800, type: 3} + exp: 0 + level: 0 +--- !u!212 &-5893075763862095451 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2935319493830293412} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: -522733599 + m_SortingLayer: 1 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: fe9c8eab186d5004eaad446d8e220800, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!1001 &5734536248370648602 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 2935319493830293414} + m_Modifications: + - target: {fileID: 7475959774386308610, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_Name + value: Main Camera + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalPosition.z + value: -10 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 04409c352bfbdea4b9830f11d7b4d40e, type: 3} +--- !u!4 &2894367173346332699 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 7475959774386308609, guid: 04409c352bfbdea4b9830f11d7b4d40e, + type: 3} + m_PrefabInstance: {fileID: 5734536248370648602} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/Prefabs/Slime.prefab b/Assets/Prefabs/Slime.prefab new file mode 100644 index 0000000..ae102a3 --- /dev/null +++ b/Assets/Prefabs/Slime.prefab @@ -0,0 +1,114 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1164136568549368904 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2043533519980591455} + - component: {fileID: 7440667849060313208} + - component: {fileID: 571363246873614695} + - component: {fileID: 1351652798109185028} + m_Layer: 0 + m_Name: Slime + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2043533519980591455 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164136568549368904} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7440667849060313208 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164136568549368904} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a72ad0eb2136f284bab78f19fa561bb8, type: 3} + m_Name: + m_EditorClassIdentifier: + hpMax: 0 + hp: 0 + sprite: {fileID: 21300000, guid: 0121970e693ee0a4d987bd5fe694ad67, type: 3} +--- !u!114 &571363246873614695 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164136568549368904} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2fcfe4b94620b234fb7a294bf4453a69, type: 3} + m_Name: + m_EditorClassIdentifier: + hpMax: 0 + hp: 0 + sprite: {fileID: 21300000, guid: 0121970e693ee0a4d987bd5fe694ad67, type: 3} + visionRange: 4 +--- !u!212 &1351652798109185028 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164136568549368904} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: -522733599 + m_SortingLayer: 1 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 0121970e693ee0a4d987bd5fe694ad67, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 diff --git a/Assets/Prefabs/Enemy.prefab.meta b/Assets/Prefabs/Slime.prefab.meta similarity index 100% rename from Assets/Prefabs/Enemy.prefab.meta rename to Assets/Prefabs/Slime.prefab.meta diff --git a/Assets/Prefabs/Tile.prefab b/Assets/Prefabs/Tile.prefab index 7104d56..0095f28 100644 --- a/Assets/Prefabs/Tile.prefab +++ b/Assets/Prefabs/Tile.prefab @@ -45,6 +45,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: walkable: 0 + roomPart: 0 sprite: {fileID: 0} --- !u!212 &1691311275711631131 SpriteRenderer: @@ -80,8 +81,8 @@ SpriteRenderer: m_AutoUVMaxDistance: 0.5 m_AutoUVMaxAngle: 89 m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 + m_SortingLayerID: -23662865 + m_SortingLayer: -1 m_SortingOrder: 0 m_Sprite: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Scenes/Steffo.unity b/Assets/Scenes/Steffo.unity index 3c5f20b..ed248a3 100644 --- a/Assets/Scenes/Steffo.unity +++ b/Assets/Scenes/Steffo.unity @@ -120,224 +120,72 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &1386694424 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1386694427} - - component: {fileID: 1386694426} - - component: {fileID: 1386694425} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1386694425 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1386694424} - m_Enabled: 1 ---- !u!20 &1386694426 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1386694424} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 1 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &1386694427 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1386694424} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &1591665583 +--- !u!1001 &3195245191303068541 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 2866215097817665852, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1792584738874209504, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_Name value: GameController objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalRotation.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalRotation.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalRotation.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_RootOrder - value: 1 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 3211721187637284538, guid: 4c25f33cb89f6624db48fc49d353a7f2, + - target: {fileID: 1419775483983031142, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} ---- !u!1001 &7249059666254997933 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 7249059666095778526, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_Name - value: Map - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7249059666095778521, guid: cd714ea41cb7c454994bf0f5ad99abd1, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: cd714ea41cb7c454994bf0f5ad99abd1, type: 3} diff --git a/Assets/Scripts/AI.cs b/Assets/Scripts/AI.cs new file mode 100644 index 0000000..fd30b46 --- /dev/null +++ b/Assets/Scripts/AI.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AI : Entity +{ + public virtual void OnTurn(){ + Debug.LogWarning("OnTurn() not overridden"); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Consumabile.cs.meta b/Assets/Scripts/AI.cs.meta similarity index 83% rename from Assets/Scripts/Consumabile.cs.meta rename to Assets/Scripts/AI.cs.meta index 26b1684..438e77b 100644 --- a/Assets/Scripts/Consumabile.cs.meta +++ b/Assets/Scripts/AI.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: db5a27c0009da214088bb4a3c08b76db +guid: e694420377849854db7a2686ff36420c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/AISlime.cs b/Assets/Scripts/AISlime.cs new file mode 100644 index 0000000..eaa3584 --- /dev/null +++ b/Assets/Scripts/AISlime.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AISlime : AI +{ + public float visionRange = 4; + protected Player player; + + protected new void Start() { + base.Start(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + } + + public override void OnTurn(){ + if (CanSeePlayer()){ + //TODO + } + else { + int direction = Random.Range(0, 4); + if (direction == 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){ + transform.Translate(Vector3.left); + } + else if (direction == 1 && map.CanMoveTo(MapPosition + Vector2Int.right)){ + transform.Translate(Vector3.right); + } + else if (direction == 2 && map.CanMoveTo(MapPosition + Vector2Int.up)){ + transform.Translate(Vector3.up); + } + else if (direction == 3 && map.CanMoveTo(MapPosition + Vector2Int.down)){ + transform.Translate(Vector3.down); + } + } + } + + public bool CanSeePlayer(){ + return Vector3.Distance(player.transform.position, transform.position) < visionRange; + } + + private void OnDrawGizmosSelected() { + Gizmos.color = Color.cyan; + Gizmos.DrawWireSphere(transform.position, visionRange); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Object.cs.meta b/Assets/Scripts/AISlime.cs.meta similarity index 83% rename from Assets/Scripts/Object.cs.meta rename to Assets/Scripts/AISlime.cs.meta index ec349c0..9c04775 100644 --- a/Assets/Scripts/Object.cs.meta +++ b/Assets/Scripts/AISlime.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 49be0f8468bff6249b7befdf02bc8ec9 +guid: 2fcfe4b94620b234fb7a294bf4453a69 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Consumabile.cs b/Assets/Scripts/Consumabile.cs deleted file mode 100644 index 9121f40..0000000 --- a/Assets/Scripts/Consumabile.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/* -public class Consumabile : Object -{ - // Start is called before the first frame update - public enum Tipo {Cura, Danno}; - public GameObject player; - public Player player; - public int valore; - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } - - void use(){ - if (Tipo == Tipo.Cura){ - player.hp += valore; - if (player.hp >= player.maxhp) player.hp = player.maxhp; - } - if (Tipo == Tipo.Danno){ - player.hp -= valore; - } - } -} -*/ \ No newline at end of file diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs new file mode 100644 index 0000000..f9549f1 --- /dev/null +++ b/Assets/Scripts/Entity.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Entity : MonoBehaviour +{ + public int hpMax; + + [AfterStartAttribute] + public int hp; + + [BeforeStartAttribute] + public Sprite sprite; + + public Vector2Int MapPosition { + get { + return new Vector2Int((int)transform.position.x, (int)transform.position.y); + } + } + + protected GameObject gameController; + protected SpriteRenderer spriteRenderer; + protected TurnHandler turnHandler; + protected Map map; + + protected void Start() + { + spriteRenderer = GetComponent(); + spriteRenderer.sprite = sprite; + gameController = GameObject.FindGameObjectWithTag("GameController"); + turnHandler = gameController.GetComponentInChildren(); + map = gameController.GetComponentInChildren(); + hp = hpMax; + } +} diff --git a/Assets/Scripts/Entity.cs.meta b/Assets/Scripts/Entity.cs.meta new file mode 100644 index 0000000..20fc693 --- /dev/null +++ b/Assets/Scripts/Entity.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 09a0fcf071a3b6244b6339cd122566fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index d8ec176..f8eaa52 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -96,22 +96,32 @@ public class Map : MonoBehaviour [BeforeStartAttribute] public GameObject tilePrefab; + [BeforeStartAttribute] + public GameObject playerPrefab; + + [BeforeStartAttribute] + public List enemyPrefabs; + + [BeforeStartAttribute] + public int enemiesToSpawn = 10; + private GameObject[,] tiles; private List rooms; - private System.Random rnd; + private TurnHandler turnHandler; public Tile GetTile(Vector2Int position) { GameObject tileObject = tiles[position.x, position.y]; - Tile tile = tileObject.GetComponent(); - return tile; + return tileObject.GetComponent(); } - public bool CanMoveTo(Vector2Int direction) + public bool CanMoveTo(Vector2Int position) { try { - return GetTile(direction).walkable; + bool walkable = GetTile(position).walkable; + bool free = !(bool)turnHandler.GetEntityAtPosition(position); + return walkable && free; } - catch(System.ArgumentOutOfRangeException) { + catch(System.IndexOutOfRangeException) { return false; } } @@ -212,6 +222,25 @@ public class Map : MonoBehaviour } } + private void PlacePlayer() { + MapRoom room = rooms[Random.Range(0, rooms.Count)]; + Vector2Int point = room.RandomPoint(); + GameObject playerObject = Instantiate(playerPrefab, turnHandler.transform); + playerObject.name = "Player"; + playerObject.transform.position = new Vector3(point.x, point.y, 0); + } + + private void PlaceEnemies() { + for(int i = 0; i < enemiesToSpawn; i++) { + MapRoom room = rooms[Random.Range(0, rooms.Count)]; + Vector2Int point = room.RandomPoint(); + GameObject enemyPrefab = enemyPrefabs[Random.Range(0, enemyPrefabs.Count)]; + GameObject enemyObject = Instantiate(enemyPrefab, turnHandler.transform); + enemyObject.name = "Enemy " + i.ToString(); + enemyObject.transform.position = new Vector3(point.x, point.y, 0); + } + } + private Sprite GetFloorTileSprite() { return floorSprites[Random.Range(0, floorSprites.Count)]; } @@ -221,8 +250,10 @@ public class Map : MonoBehaviour //Initialize everything tiles = new GameObject[mapSize, mapSize]; rooms = new List(); - rnd = new System.Random(); - //Generate the map + turnHandler = GameObject.FindGameObjectWithTag("GameController").GetComponentInChildren(); + GenerateMap(); + PlacePlayer(); + PlaceEnemies(); } } diff --git a/Assets/Scripts/Map.cs.meta b/Assets/Scripts/Map.cs.meta index 2695166..d2f3f16 100644 --- a/Assets/Scripts/Map.cs.meta +++ b/Assets/Scripts/Map.cs.meta @@ -8,7 +8,7 @@ MonoImporter: - roomSprite: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - corridorSprite: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3} - tilePrefab: {instanceID: 0} - executionOrder: 0 + executionOrder: -50 icon: {instanceID: 0} userData: assetBundleName: diff --git a/Assets/Scripts/Monster.cs b/Assets/Scripts/Monster.cs index 976a1d3..604daad 100644 --- a/Assets/Scripts/Monster.cs +++ b/Assets/Scripts/Monster.cs @@ -5,54 +5,19 @@ using UnityEngine; public class Monster : MonoBehaviour { public int hpMax; + + [AfterStartAttribute] public int hp; - public bool isUndead; - public int movesPerTurn; - public bool hasSpottedPlayer; [BeforeStartAttribute] public Sprite sprite; - private Map map; + private SpriteRenderer spriteRenderer; - private Player player; - - // Start is called before the first frame update private void Start() { - map = GameObject.FindGameObjectWithTag("Map").GetComponent(); - player = GameObject.FindGameObjectWithTag("Player").GetComponent(); - hasSpottedPlayer = false; - } - - void Turn(){ - IsPlayerNear(); - if (!hasSpottedPlayer){ - int direction = Random.Range(0, 4); - if (direction == 0 && map.CanMoveTo(Vector2Int.left)){ - transform.Translate(Vector3.left); - } - else if (direction == 1 && map.CanMoveTo(Vector2Int.right)){ - transform.Translate(Vector3.right); - } - else if (direction == 2 && map.CanMoveTo(Vector2Int.up)){ - transform.Translate(Vector3.up); - } - else if (direction == 3 && map.CanMoveTo(Vector2Int.left)){ - transform.Translate(Vector3.left); - } - } - else{ - //Put here pathfinding code - } - } - - void IsPlayerNear(){ - if ((player.transform.position.x-transform.position.x)<=3 || (transform.position.x-player.transform.position.x)>=-3){ - hasSpottedPlayer=true; - } - if ((player.transform.position.y-transform.position.y)<=3 || (transform.position.y-player.transform.position.y)>=-3){ - hasSpottedPlayer=true; - } + spriteRenderer = GetComponent(); + spriteRenderer.sprite = sprite; + hp = hpMax; } } diff --git a/Assets/Scripts/Object.cs b/Assets/Scripts/Object.cs deleted file mode 100644 index e01fcdb..0000000 --- a/Assets/Scripts/Object.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Object : MonoBehaviour -{ - public string nome; - public int costo; - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 0a2d84c..8c1b16c 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -2,24 +2,10 @@ using System.Collections.Generic; using UnityEngine; -public class Player : MonoBehaviour +public class Player : Entity { public int exp; - public int level; - public int hpMax; - - [AfterStartAttribute] - public int hp; - - private Map map; - private GameObject gameController; - - void Start() - { - map = GameObject.FindGameObjectWithTag("Map").GetComponent(); - gameController = GameObject.FindGameObjectWithTag("GameController"); - hp = hpMax; - } + public int level; void Update() { @@ -29,39 +15,36 @@ public class Player : MonoBehaviour void CheckForMovementInput() { bool hasMoved = false; - Vector2Int posizione = new Vector2Int(); - posizione.x = (int)transform.position.x+1; - posizione.y = (int)transform.position.y+1; if (Input.GetKeyDown(KeyCode.A)) { - if (map.CanMoveTo(posizione + Vector2Int.left)) { + if (map.CanMoveTo(MapPosition + Vector2Int.left)) { transform.Translate(Vector3.left); hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.D)) { - if (map.CanMoveTo(posizione + Vector2Int.right)) { + if (map.CanMoveTo(MapPosition + Vector2Int.right)) { transform.Translate(Vector3.right); hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.W)) { - if (map.CanMoveTo(posizione + Vector2Int.up)) { + if (map.CanMoveTo(MapPosition + Vector2Int.up)) { transform.Translate(Vector3.up); hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.S)) { - if (map.CanMoveTo(posizione + Vector2Int.down)) { + if (map.CanMoveTo(MapPosition + Vector2Int.down)) { transform.Translate(Vector3.down); hasMoved = true; } } if(hasMoved) { - gameController.BroadcastMessage("Turn"); + turnHandler.OnTurn(); } } } diff --git a/Assets/Scripts/TurnHandler.cs b/Assets/Scripts/TurnHandler.cs new file mode 100644 index 0000000..2e42807 --- /dev/null +++ b/Assets/Scripts/TurnHandler.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TurnHandler : MonoBehaviour +{ + public void OnTurn() { + AI[] ais = gameObject.GetComponentsInChildren(); + foreach(AI ai in ais) { + ai.OnTurn(); + } + } + + public Entity GetEntityAtPosition(Vector2Int position) { + Entity[] entities = GetComponentsInChildren(); + foreach(Entity entity in entities) { + if(entity.MapPosition == position) { + return entity; + } + } + return null; + } +} \ No newline at end of file diff --git a/Assets/Scripts/TurnHandler.cs.meta b/Assets/Scripts/TurnHandler.cs.meta new file mode 100644 index 0000000..1142ab1 --- /dev/null +++ b/Assets/Scripts/TurnHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2447171af2ad9634498f2d769d7f5200 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 82e2d19..73c55a1 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -3,8 +3,7 @@ --- !u!78 &1 TagManager: serializedVersion: 2 - tags: - - Map + tags: [] layers: - Default - TransparentFX @@ -39,6 +38,12 @@ TagManager: - - m_SortingLayers: + - name: Tiles + uniqueID: 4271304431 + locked: 0 - name: Default uniqueID: 0 locked: 0 + - name: Entities + uniqueID: 3772233697 + locked: 0