From 8af505138f6223006c13801610f2cf5cdced7b73 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 27 Apr 2019 17:28:38 +0200 Subject: [PATCH] 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: