From ce348545dfd77151cd66e712be4404262c286418 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 14:11:21 +0200 Subject: [PATCH 01/10] Update things --- Assets/Prefabs/GameController.prefab | 22 ++-- .../{Main Camera.prefab => MainCamera.prefab} | 2 +- ...era.prefab.meta => MainCamera.prefab.meta} | 0 Assets/Prefabs/Player.prefab | 4 +- Assets/Prefabs/TEST Item.prefab | 98 +++++++++++++++ Assets/Prefabs/TEST Item.prefab.meta | 7 ++ Assets/Scripts/Entity.cs | 1 + Assets/Scripts/Item.cs | 14 +++ Assets/Scripts/Item.cs.meta | 11 ++ Assets/Scripts/Map.cs | 6 +- Assets/Scripts/Player.cs | 11 ++ Assets/Scripts/TurnHandler.cs | 7 +- Assets/Sprites/PurpleTileset.png.meta | 2 +- Assets/Sprites/PurpleTileset2.png.meta | 2 +- Assets/Sprites/PurpleWall.png.meta | 2 +- Assets/Sprites/PurpleWall_BOT.png.meta | 2 +- Assets/Sprites/PurpleWall_BOT2.png.meta | 2 +- Assets/Sprites/PurpleWall_BOTL.png.meta | 2 +- Assets/Sprites/PurpleWall_BOTR.png.meta | 2 +- Assets/Sprites/PurpleWall_BOTSteffo.png.meta | 2 +- Assets/Sprites/PurpleWall_LEFT.png.meta | 2 +- Assets/Sprites/PurpleWall_RIGHT.png.meta | 2 +- Assets/Sprites/PurpleWall_UP.png.meta | 2 +- Assets/Sprites/PurpleWall_UP2.png.meta | 2 +- Assets/Sprites/PurpleWall_UPL.png.meta | 2 +- Assets/Sprites/PurpleWall_UPR.png.meta | 2 +- Assets/Sprites/Slime.png.meta | 2 +- Assets/Sprites/pg.png.meta | 112 ++++++++++++++++++ 28 files changed, 295 insertions(+), 30 deletions(-) rename Assets/Prefabs/{Main Camera.prefab => MainCamera.prefab} (98%) rename Assets/Prefabs/{Main Camera.prefab.meta => MainCamera.prefab.meta} (100%) create mode 100644 Assets/Prefabs/TEST Item.prefab create mode 100644 Assets/Prefabs/TEST Item.prefab.meta create mode 100644 Assets/Scripts/Item.cs create mode 100644 Assets/Scripts/Item.cs.meta create mode 100644 Assets/Sprites/pg.png.meta diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab index bd412a4..931e916 100644 --- a/Assets/Prefabs/GameController.prefab +++ b/Assets/Prefabs/GameController.prefab @@ -82,21 +82,27 @@ MonoBehaviour: maxRoomIterations: 100 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: fa4c9841fd8a5fb4f94ff78c95301065, type: 3} topWallSprites: - - {fileID: 21300000, guid: a6548c20c0b36384f9ba55aac5cd513d, type: 3} - - {fileID: 21300000, guid: de53d30fbdcfc2e458577832376fddc7, type: 3} + - {fileID: 0} botWallSprites: - - {fileID: 21300000, guid: 9c493dd4f06f0e6448ca0485a0aec85b, type: 3} - - {fileID: 21300000, guid: 9f7113f83f58bbc4b80539190bfc99b8, type: 3} + - {fileID: 21300000, guid: 82ccea6ce8f2edf4cae6f99e1127b0c3, type: 3} leftWallSprites: - - {fileID: 21300000, guid: 1c1ab193bd23fde40a1d3400075ccd26, type: 3} + - {fileID: 0} rightWallSprites: - - {fileID: 21300000, guid: 47816dfcc9e4290499aa0189a04a5560, type: 3} + - {fileID: 0} lCornerWallSprites: - - {fileID: 21300000, guid: 1f464248b697d4b459679fd8c4215983, type: 3} + - {fileID: 0} rCornerWallSprites: - - {fileID: 21300000, guid: 424d116bfc9d297468486f10739cb1b3, type: 3} + - {fileID: 0} tilePrefab: {fileID: 2955896503201886234, guid: 0e0b618b5499bbb40b076c0291d55487, type: 3} playerPrefab: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec, diff --git a/Assets/Prefabs/Main Camera.prefab b/Assets/Prefabs/MainCamera.prefab similarity index 98% rename from Assets/Prefabs/Main Camera.prefab rename to Assets/Prefabs/MainCamera.prefab index 572e376..a1cac78 100644 --- a/Assets/Prefabs/Main Camera.prefab +++ b/Assets/Prefabs/MainCamera.prefab @@ -59,7 +59,7 @@ Camera: far clip plane: 1000 field of view: 60 orthographic: 1 - orthographic size: 7 + orthographic size: 8 m_Depth: -1 m_CullingMask: serializedVersion: 2 diff --git a/Assets/Prefabs/Main Camera.prefab.meta b/Assets/Prefabs/MainCamera.prefab.meta similarity index 100% rename from Assets/Prefabs/Main Camera.prefab.meta rename to Assets/Prefabs/MainCamera.prefab.meta diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index e43f461..0082d9d 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -47,7 +47,7 @@ MonoBehaviour: m_EditorClassIdentifier: hpMax: 0 hp: 0 - sprite: {fileID: 21300000, guid: fe9c8eab186d5004eaad446d8e220800, type: 3} + sprite: {fileID: 21300000, guid: 88f4c277892ae9449a57b321cd810bce, type: 3} exp: 0 level: 0 --- !u!212 &-5893075763862095451 @@ -87,7 +87,7 @@ SpriteRenderer: m_SortingLayerID: -522733599 m_SortingLayer: 1 m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: fe9c8eab186d5004eaad446d8e220800, type: 3} + m_Sprite: {fileID: 21300000, guid: 88f4c277892ae9449a57b321cd810bce, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 diff --git a/Assets/Prefabs/TEST Item.prefab b/Assets/Prefabs/TEST Item.prefab new file mode 100644 index 0000000..d91ed64 --- /dev/null +++ b/Assets/Prefabs/TEST Item.prefab @@ -0,0 +1,98 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &470211819356819165 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 470211819356819163} + - component: {fileID: 470211819356819162} + - component: {fileID: 7501912107144583665} + m_Layer: 0 + m_Name: TEST_ Item + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &470211819356819163 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 470211819356819165} + 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 &470211819356819162 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 470211819356819165} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1f0883433553dbb4fa23a815949f596b, type: 3} + m_Name: + m_EditorClassIdentifier: + hpMax: 0 + overlappable: 0 + hp: 0 + sprite: {fileID: 21300000, guid: 5e4d29e1adc2ea0429b199b82253416c, type: 3} +--- !u!212 &7501912107144583665 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 470211819356819165} + 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: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 5e4d29e1adc2ea0429b199b82253416c, 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/TEST Item.prefab.meta b/Assets/Prefabs/TEST Item.prefab.meta new file mode 100644 index 0000000..0ef57ec --- /dev/null +++ b/Assets/Prefabs/TEST Item.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1bd6e08f590fdd844854a34504aeaa4a +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index f9549f1..a86ffad 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -5,6 +5,7 @@ using UnityEngine; public class Entity : MonoBehaviour { public int hpMax; + public bool overlappable = false; [AfterStartAttribute] public int hp; diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/Item.cs new file mode 100644 index 0000000..875349e --- /dev/null +++ b/Assets/Scripts/Item.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Item : Entity +{ + private new void Start() { + overlappable = true; + } + + public virtual void OnPickup(Player player) { + Debug.LogWarning("OnPickup not overridden"); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Item.cs.meta b/Assets/Scripts/Item.cs.meta new file mode 100644 index 0000000..0b76504 --- /dev/null +++ b/Assets/Scripts/Item.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f0883433553dbb4fa23a815949f596b +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 4d21307..696e369 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -138,7 +138,11 @@ public class Map : MonoBehaviour { try { bool walkable = GetTile(position).walkable; - bool free = !(bool)turnHandler.GetEntityAtPosition(position); + List entities = turnHandler.GetEntityAtPosition(position); + bool free = true; + foreach(Entity entity in entities) { + free &= entity.overlappable; + } return walkable && free; } catch(System.IndexOutOfRangeException) { diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 8c1b16c..dd6ccc9 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -20,6 +20,7 @@ public class Player : Entity if (map.CanMoveTo(MapPosition + Vector2Int.left)) { transform.Translate(Vector3.left); hasMoved = true; + spriteRenderer.flipX = false; } } else if (Input.GetKeyDown(KeyCode.D)) @@ -27,6 +28,7 @@ public class Player : Entity if (map.CanMoveTo(MapPosition + Vector2Int.right)) { transform.Translate(Vector3.right); hasMoved = true; + spriteRenderer.flipX = true; } } else if (Input.GetKeyDown(KeyCode.W)) @@ -44,6 +46,15 @@ public class Player : Entity } } if(hasMoved) { + //Check for pickuppable items + List entities = turnHandler.GetEntityAtPosition(MapPosition); + foreach(Entity entity in entities) { + if(entity is Item) { + Item item = entity as Item; + item.OnPickup(this); + } + } + //Turn happens! turnHandler.OnTurn(); } } diff --git a/Assets/Scripts/TurnHandler.cs b/Assets/Scripts/TurnHandler.cs index 2e42807..343618a 100644 --- a/Assets/Scripts/TurnHandler.cs +++ b/Assets/Scripts/TurnHandler.cs @@ -11,13 +11,14 @@ public class TurnHandler : MonoBehaviour } } - public Entity GetEntityAtPosition(Vector2Int position) { + public List GetEntityAtPosition(Vector2Int position) { Entity[] entities = GetComponentsInChildren(); + List found = new List(); foreach(Entity entity in entities) { if(entity.MapPosition == position) { - return entity; + found.Add(entity); } } - return null; + return found; } } \ No newline at end of file diff --git a/Assets/Sprites/PurpleTileset.png.meta b/Assets/Sprites/PurpleTileset.png.meta index 2135d63..d707c21 100644 --- a/Assets/Sprites/PurpleTileset.png.meta +++ b/Assets/Sprites/PurpleTileset.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleTileset2.png.meta b/Assets/Sprites/PurpleTileset2.png.meta index ead95e1..a917f1a 100644 --- a/Assets/Sprites/PurpleTileset2.png.meta +++ b/Assets/Sprites/PurpleTileset2.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall.png.meta b/Assets/Sprites/PurpleWall.png.meta index 0b247f6..69faf9a 100644 --- a/Assets/Sprites/PurpleWall.png.meta +++ b/Assets/Sprites/PurpleWall.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_BOT.png.meta b/Assets/Sprites/PurpleWall_BOT.png.meta index 9534277..e258997 100644 --- a/Assets/Sprites/PurpleWall_BOT.png.meta +++ b/Assets/Sprites/PurpleWall_BOT.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_BOT2.png.meta b/Assets/Sprites/PurpleWall_BOT2.png.meta index bdb9313..a48e01c 100644 --- a/Assets/Sprites/PurpleWall_BOT2.png.meta +++ b/Assets/Sprites/PurpleWall_BOT2.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_BOTL.png.meta b/Assets/Sprites/PurpleWall_BOTL.png.meta index f6924d5..17118dd 100644 --- a/Assets/Sprites/PurpleWall_BOTL.png.meta +++ b/Assets/Sprites/PurpleWall_BOTL.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_BOTR.png.meta b/Assets/Sprites/PurpleWall_BOTR.png.meta index 9ad0d81..51fa314 100644 --- a/Assets/Sprites/PurpleWall_BOTR.png.meta +++ b/Assets/Sprites/PurpleWall_BOTR.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_BOTSteffo.png.meta b/Assets/Sprites/PurpleWall_BOTSteffo.png.meta index 1f4dbb5..df27471 100644 --- a/Assets/Sprites/PurpleWall_BOTSteffo.png.meta +++ b/Assets/Sprites/PurpleWall_BOTSteffo.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_LEFT.png.meta b/Assets/Sprites/PurpleWall_LEFT.png.meta index 085a82b..a029815 100644 --- a/Assets/Sprites/PurpleWall_LEFT.png.meta +++ b/Assets/Sprites/PurpleWall_LEFT.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_RIGHT.png.meta b/Assets/Sprites/PurpleWall_RIGHT.png.meta index 2f6a973..ff0d438 100644 --- a/Assets/Sprites/PurpleWall_RIGHT.png.meta +++ b/Assets/Sprites/PurpleWall_RIGHT.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_UP.png.meta b/Assets/Sprites/PurpleWall_UP.png.meta index c27a2af..81adde7 100644 --- a/Assets/Sprites/PurpleWall_UP.png.meta +++ b/Assets/Sprites/PurpleWall_UP.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_UP2.png.meta b/Assets/Sprites/PurpleWall_UP2.png.meta index 96c6eb9..cd5900c 100644 --- a/Assets/Sprites/PurpleWall_UP2.png.meta +++ b/Assets/Sprites/PurpleWall_UP2.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_UPL.png.meta b/Assets/Sprites/PurpleWall_UPL.png.meta index bf4dc99..38ecc4b 100644 --- a/Assets/Sprites/PurpleWall_UPL.png.meta +++ b/Assets/Sprites/PurpleWall_UPL.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/PurpleWall_UPR.png.meta b/Assets/Sprites/PurpleWall_UPR.png.meta index b86fc61..15929a6 100644 --- a/Assets/Sprites/PurpleWall_UPR.png.meta +++ b/Assets/Sprites/PurpleWall_UPR.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/Slime.png.meta b/Assets/Sprites/Slime.png.meta index 531e9f7..00088d7 100644 --- a/Assets/Sprites/Slime.png.meta +++ b/Assets/Sprites/Slime.png.meta @@ -31,7 +31,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: -1 mipBias: -100 wrapU: 1 diff --git a/Assets/Sprites/pg.png.meta b/Assets/Sprites/pg.png.meta new file mode 100644 index 0000000..7c72237 --- /dev/null +++ b/Assets/Sprites/pg.png.meta @@ -0,0 +1,112 @@ +fileFormatVersion: 2 +guid: 88f4c277892ae9449a57b321cd810bce +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: 2 + 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: 30 + 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 + - 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: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: ed1284666de20434aaac0772ac619792 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: From 33347480f6cc1f9e2307b98dda10faf4ba86b8ad Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 14:41:28 +0200 Subject: [PATCH 02/10] Add life bar --- Assets/Prefabs/GameController.prefab | 287 +++++++++++++++++- Assets/Prefabs/Player.prefab | 5 +- Assets/Scenes/Steffo.unity | 132 -------- Assets/Scripts/Entity.cs | 4 +- Assets/Scripts/FillAmountFromPlayerHP.cs | 19 ++ Assets/Scripts/FillAmountFromPlayerHP.cs.meta | 11 + Assets/Sprites/WhiteSquare.png.meta | 22 ++ ProjectSettings/TagManager.asset | 4 +- 8 files changed, 346 insertions(+), 138 deletions(-) create mode 100644 Assets/Scripts/FillAmountFromPlayerHP.cs create mode 100644 Assets/Scripts/FillAmountFromPlayerHP.cs.meta diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab index 931e916..6f07262 100644 --- a/Assets/Prefabs/GameController.prefab +++ b/Assets/Prefabs/GameController.prefab @@ -1,5 +1,202 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &1591973060 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1591973061} + - component: {fileID: 1591973064} + - component: {fileID: 1591973063} + - component: {fileID: 1591973062} + m_Layer: 5 + m_Name: Canvas + m_TagString: Canvas + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1591973061 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1591973060} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 5737868752126517729} + m_Father: {fileID: 1651829514} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!223 &1591973064 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1591973060} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!114 &1591973063 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1591973060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!114 &1591973062 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1591973060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!1 &1651829513 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1651829514} + m_Layer: 0 + m_Name: UI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1651829514 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1651829513} + 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: 1591973061} + - {fileID: 1816923098} + m_Father: {fileID: 1419775483983031142} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1816923097 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1816923098} + - component: {fileID: 1816923100} + - component: {fileID: 1816923099} + m_Layer: 0 + m_Name: EventSystem + m_TagString: EventSystem + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1816923098 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816923097} + 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: 1651829514} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1816923100 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816923097} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!114 &1816923099 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816923097} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 --- !u!1 &1792584738874209504 GameObject: m_ObjectHideFlags: 0 @@ -29,9 +226,97 @@ Transform: m_Children: - {fileID: 8897064855631282258} - {fileID: 3789201758602335435} + - {fileID: 1651829514} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &4498264905375096437 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5737868752126517729} + - component: {fileID: 1444371758723586612} + - component: {fileID: 377224390999592314} + - component: {fileID: 964787956205872362} + m_Layer: 5 + m_Name: HP Bar + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5737868752126517729 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4498264905375096437} + 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: 1591973061} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0, y: 0} +--- !u!222 &1444371758723586612 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4498264905375096437} + m_CullTransparentMesh: 0 +--- !u!114 &377224390999592314 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4498264905375096437} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3} + m_Type: 3 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 2 + m_FillAmount: 1 + m_FillClockwise: 0 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &964787956205872362 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4498264905375096437} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cbf8b0d2fd980e14f9956f5345d82ddc, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &5605884945823581445 GameObject: m_ObjectHideFlags: 0 @@ -108,7 +393,7 @@ MonoBehaviour: playerPrefab: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec, type: 3} enemyPrefabs: - - {fileID: 1164136568549368904, guid: a4aeecfb369f0974490d158ef9489335, type: 3} + - {fileID: 470211819356819165, guid: 1bd6e08f590fdd844854a34504aeaa4a, type: 3} enemiesToSpawn: 10 --- !u!1 &8733140679003710819 GameObject: diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 0082d9d..d9785e0 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -45,8 +45,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4de6b97c3d785d146a0df2c1c078fe91, type: 3} m_Name: m_EditorClassIdentifier: - hpMax: 0 - hp: 0 + hpMax: 10 + overlappable: 0 + hp: 10 sprite: {fileID: 21300000, guid: 88f4c277892ae9449a57b321cd810bce, type: 3} exp: 0 level: 0 diff --git a/Assets/Scenes/Steffo.unity b/Assets/Scenes/Steffo.unity index 1df960c..ed248a3 100644 --- a/Assets/Scenes/Steffo.unity +++ b/Assets/Scenes/Steffo.unity @@ -187,137 +187,5 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: leftWallSprites.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: rightWallSprites.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: topWallSprites.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: lCornerWallSprites.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: rCornerWallSprites.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: botWallSprites.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.size - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: rightWallSprites.Array.data[0] - value: - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: leftWallSprites.Array.data[0] - value: - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: lCornerWallSprites.Array.data[0] - value: - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: rCornerWallSprites.Array.data[0] - value: - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: topWallSprites.Array.data[0] - value: - objectReference: {fileID: 0} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: topWallSprites.Array.data[1] - value: - objectReference: {fileID: 21300000, guid: de53d30fbdcfc2e458577832376fddc7, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: botWallSprites.Array.data[0] - value: - objectReference: {fileID: 21300000, guid: 82ccea6ce8f2edf4cae6f99e1127b0c3, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[0] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[1] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[2] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[3] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[4] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[5] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[6] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[7] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[8] - value: - objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, - type: 3} - - target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2, - type: 3} - propertyPath: floorSprites.Array.data[9] - value: - objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, - type: 3} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index a86ffad..e1bd183 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -4,11 +4,11 @@ using UnityEngine; public class Entity : MonoBehaviour { - public int hpMax; + public float hpMax; public bool overlappable = false; [AfterStartAttribute] - public int hp; + public float hp; [BeforeStartAttribute] public Sprite sprite; diff --git a/Assets/Scripts/FillAmountFromPlayerHP.cs b/Assets/Scripts/FillAmountFromPlayerHP.cs new file mode 100644 index 0000000..db83a6c --- /dev/null +++ b/Assets/Scripts/FillAmountFromPlayerHP.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class FillAmountFromPlayerHP : MonoBehaviour +{ + private Player player; + private Image image; + + private void Start() { + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + image = GetComponent(); + } + + private void Update() { + image.fillAmount = player.hp / player.hpMax; + } +} diff --git a/Assets/Scripts/FillAmountFromPlayerHP.cs.meta b/Assets/Scripts/FillAmountFromPlayerHP.cs.meta new file mode 100644 index 0000000..73cadf6 --- /dev/null +++ b/Assets/Scripts/FillAmountFromPlayerHP.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cbf8b0d2fd980e14f9956f5345d82ddc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 100 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/WhiteSquare.png.meta b/Assets/Sprites/WhiteSquare.png.meta index 712c525..c8e935e 100644 --- a/Assets/Sprites/WhiteSquare.png.meta +++ b/Assets/Sprites/WhiteSquare.png.meta @@ -69,6 +69,28 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 4 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 4 + 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 73c55a1..819cd6d 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -3,7 +3,9 @@ --- !u!78 &1 TagManager: serializedVersion: 2 - tags: [] + tags: + - Canvas + - EventSystem layers: - Default - TransparentFX From 8250f7446d58d1ba949ddd39a84fab83b2b0f1de Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 15:29:17 +0200 Subject: [PATCH 03/10] Add fonts and message bar --- Assets/Fonts.meta | 8 + Assets/Fonts/Font License.txt | 47 ++++ Assets/Fonts/Font License.txt.meta | 7 + Assets/Fonts/Pixel NES.otf | Bin 0 -> 21036 bytes Assets/Fonts/Pixel NES.otf.meta | 22 ++ Assets/Prefabs/GameController.prefab | 358 +++++++++++++++++++------- Assets/Scenes/Steffo.unity | 12 +- Assets/Scripts/Entity.cs | 2 +- Assets/Scripts/Item.cs | 5 +- Assets/Scripts/MessageBar.cs | 32 +++ Assets/Scripts/MessageBar.cs.meta | 11 + Assets/Scripts/TurnHandler.cs | 11 + ProjectSettings/InputManager.asset | 290 +-------------------- ProjectSettings/QualitySettings.asset | 181 ++----------- 14 files changed, 449 insertions(+), 537 deletions(-) create mode 100644 Assets/Fonts.meta create mode 100644 Assets/Fonts/Font License.txt create mode 100644 Assets/Fonts/Font License.txt.meta create mode 100644 Assets/Fonts/Pixel NES.otf create mode 100644 Assets/Fonts/Pixel NES.otf.meta create mode 100644 Assets/Scripts/MessageBar.cs create mode 100644 Assets/Scripts/MessageBar.cs.meta diff --git a/Assets/Fonts.meta b/Assets/Fonts.meta new file mode 100644 index 0000000..ee51604 --- /dev/null +++ b/Assets/Fonts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bc27f32bee5227b498f00e41f8d46138 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fonts/Font License.txt b/Assets/Fonts/Font License.txt new file mode 100644 index 0000000..5535f76 --- /dev/null +++ b/Assets/Fonts/Font License.txt @@ -0,0 +1,47 @@ +Shareware/ Font License + +Pixel Sagas Freeware Fonts EULA (End User License Agreement) and Software Inclusion Agreement + +"Purchaser" and "User" may be used interchangeably in this agreement. + +"Pixel Sagas" and "Neale Davidson" may be used interchangeably in this agreement. These all refer to the intellectual and legal property of Neale Davidson. + +Usage + +Pixel Saga's Shareware Fonts are free to use for personal, non-commercial purposes. No payment is necessary to use Pixel Saga's Freeware Fonts for personal use, and there is no limit to the amount of prints, pages, or other medium to be produced using them. However, you cannot offer the font for commercial sale, or offer for direct download. The inclusion of the font name and/or site URL in the credits or documentation when it is used is appreciated, but this is not mandatory. + +Payment + +Payment is not required for the use of Pixel Saga's Shareware Fonts. Commercial use requires a modest fee which can be paid through the pixelsagas.com web site through Paypal.com's services. The transaction receipt for any shareware "commercial license" purchase will suffice as proof of license. + +Support + +Font installation help is available at http://www.pixelsagas.com. If you experience problems with any Pixel Saga's Freeware font (such as spacing issues or missing characters), please verify that you have the correct and current version of the fonts. In the case of Freeware fonts, downloading the font directly from the Pixel Sagas site will ensure that the font files have not been altered. + +Software Inclusion Agreement + +Pixel Saga's software products are protected by copyright laws and International copyright treaties, as well as other intellectual property laws and treaties. All Pixel Saga's software products are licensed, not sold. + +1) GRANT OF LICENSE + +This document grants the user the following rights: + +Installation and Use. The user may install and use an unlimited number of copies of the software product. The user may not offer Pixel Sagas freeware fonts for direct download unless the user has received explicit, written permission from Neale Davidson. Otherwise please direct users to the http://www.pixelsagas.com website. Pixel Sagas freeware fonts may, however, be embedded for web, publication, or general software use. + +2) WARRANTIES + +None + +Pixel Sagas expressly disclaims any warranty for the software product. The software product and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of use or performance of the software product remains with the user. + +No Liability For Consequential Damages. + +In no event shall Neale Davidson or Pixel Sagas be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this product, even if Pixel Sagas has been advised of the possibility of such damages. + +3) MISCELLANEOUS + +Should the user have any questions concerning this document or you desire to contact Neale Davidson for any reason, please email jaynz@pixelsagas.com . + +Governing Law + +This agreement is governed by and subject to the laws of the United States of America. diff --git a/Assets/Fonts/Font License.txt.meta b/Assets/Fonts/Font License.txt.meta new file mode 100644 index 0000000..7c83289 --- /dev/null +++ b/Assets/Fonts/Font License.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: beeec18f10e42f742a316d4c2699c30f +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fonts/Pixel NES.otf b/Assets/Fonts/Pixel NES.otf new file mode 100644 index 0000000000000000000000000000000000000000..b0d8b1484f2bfc975895fe51246e805c7793f3b3 GIT binary patch literal 21036 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 VFj#XKxM@R`pTPemD7BzG@?Tyk3o8Hs literal 0 HcmV?d00001 diff --git a/Assets/Fonts/Pixel NES.otf.meta b/Assets/Fonts/Pixel NES.otf.meta new file mode 100644 index 0000000..db8632c --- /dev/null +++ b/Assets/Fonts/Pixel NES.otf.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: feeeba28bb1da554f908645dd468e2ad +TrueTypeFontImporter: + externalObjects: {} + serializedVersion: 4 + fontSize: 16 + forceTextureCase: -2 + characterSpacing: 0 + characterPadding: 1 + includeFontData: 1 + fontName: Pixel NES + fontNames: + - Pixel NES + fallbackFontReferences: [] + customCharacters: + fontRenderingMode: 0 + ascentCalculationMode: 1 + useLegacyBoundsCalculation: 0 + shouldRoundAdvanceValue: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab index 6f07262..0ba0dce 100644 --- a/Assets/Prefabs/GameController.prefab +++ b/Assets/Prefabs/GameController.prefab @@ -30,7 +30,9 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0} m_Children: - - {fileID: 5737868752126517729} + - {fileID: 8182065397885380581} + - {fileID: 1331449797751746845} + - {fileID: 6763073704789207265} m_Father: {fileID: 1651829514} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -230,93 +232,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &4498264905375096437 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5737868752126517729} - - component: {fileID: 1444371758723586612} - - component: {fileID: 377224390999592314} - - component: {fileID: 964787956205872362} - m_Layer: 5 - m_Name: HP Bar - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5737868752126517729 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4498264905375096437} - 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: 1591973061} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0, y: 0} ---- !u!222 &1444371758723586612 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4498264905375096437} - m_CullTransparentMesh: 0 ---- !u!114 &377224390999592314 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4498264905375096437} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 0 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3} - m_Type: 3 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 2 - m_FillAmount: 1 - m_FillClockwise: 0 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 ---- !u!114 &964787956205872362 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4498264905375096437} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cbf8b0d2fd980e14f9956f5345d82ddc, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &5605884945823581445 GameObject: m_ObjectHideFlags: 0 @@ -395,6 +310,273 @@ MonoBehaviour: enemyPrefabs: - {fileID: 470211819356819165, guid: 1bd6e08f590fdd844854a34504aeaa4a, type: 3} enemiesToSpawn: 10 +--- !u!1 &6763073704789207264 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6763073704789207265} + - component: {fileID: 6763073704789207267} + - component: {fileID: 6763073704789207266} + - component: {fileID: 6763073704789207260} + m_Layer: 5 + m_Name: Message Bar + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6763073704789207265 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6763073704789207264} + 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: 1591973061} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 30} + m_Pivot: {x: 0.5, y: 1} +--- !u!222 &6763073704789207267 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6763073704789207264} + m_CullTransparentMesh: 0 +--- !u!114 &6763073704789207266 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6763073704789207264} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: feeeba28bb1da554f908645dd468e2ad, type: 3} + m_FontSize: 18 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 40 + m_Alignment: 1 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: PICKED UP 1000G. +--- !u!114 &6763073704789207260 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6763073704789207264} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9584516e85b5cb54eab0c7dafa1094f1, type: 3} + m_Name: + m_EditorClassIdentifier: + disappearanceSpeed: 0.3 +--- !u!1 &7185017849687019145 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1331449797751746845} + - component: {fileID: 5318808085005978312} + - component: {fileID: 6406203509107481990} + - component: {fileID: 5816643265615328278} + m_Layer: 5 + m_Name: Filled HP Bar + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1331449797751746845 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7185017849687019145} + 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: 1591973061} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0, y: 0} +--- !u!222 &5318808085005978312 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7185017849687019145} + m_CullTransparentMesh: 0 +--- !u!114 &6406203509107481990 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7185017849687019145} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 1, b: 0, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3} + m_Type: 3 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 2 + m_FillAmount: 1 + m_FillClockwise: 0 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &5816643265615328278 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7185017849687019145} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cbf8b0d2fd980e14f9956f5345d82ddc, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &8182065397885380578 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8182065397885380581} + - component: {fileID: 8182065397885380582} + - component: {fileID: 8182065397885380583} + - component: {fileID: 8182065397885380580} + m_Layer: 5 + m_Name: Empty HP Bar + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8182065397885380581 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8182065397885380578} + 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: 1591973061} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0, y: 0} +--- !u!222 &8182065397885380582 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8182065397885380578} + m_CullTransparentMesh: 0 +--- !u!114 &8182065397885380583 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8182065397885380578} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0, b: 0, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 2 + m_FillAmount: 1 + m_FillClockwise: 0 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &8182065397885380580 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8182065397885380578} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cbf8b0d2fd980e14f9956f5345d82ddc, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &8733140679003710819 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Steffo.unity b/Assets/Scenes/Steffo.unity index ed248a3..04255fb 100644 --- a/Assets/Scenes/Steffo.unity +++ b/Assets/Scenes/Steffo.unity @@ -120,7 +120,7 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1001 &3195245191303068541 +--- !u!1001 &8182065398405294977 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 @@ -187,5 +187,15 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 6763073704789207266, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_Text + value: Text goes here. + objectReference: {fileID: 0} + - target: {fileID: 6763073704789207266, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_FontData.m_RichText + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index e1bd183..bae1035 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -24,7 +24,7 @@ public class Entity : MonoBehaviour protected TurnHandler turnHandler; protected Map map; - protected void Start() + protected virtual void Start() { spriteRenderer = GetComponent(); spriteRenderer.sprite = sprite; diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/Item.cs index 875349e..5d99cf6 100644 --- a/Assets/Scripts/Item.cs +++ b/Assets/Scripts/Item.cs @@ -4,11 +4,14 @@ using UnityEngine; public class Item : Entity { - private new void Start() { + protected override void Start() { + base.Start(); overlappable = true; } public virtual void OnPickup(Player player) { Debug.LogWarning("OnPickup not overridden"); + turnHandler.WriteToMessageBar("Picked up [NULL]."); + Destroy(gameObject); } } \ No newline at end of file diff --git a/Assets/Scripts/MessageBar.cs b/Assets/Scripts/MessageBar.cs new file mode 100644 index 0000000..e70ffe8 --- /dev/null +++ b/Assets/Scripts/MessageBar.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class MessageBar : MonoBehaviour +{ + public float disappearanceSpeed = 0.3f; + private float opacity; + + private Text text; + + // Start is called before the first frame update + void Start() + { + text = GetComponent(); + opacity = 0f; + } + + public void Write(string message) { + text.text = message; + opacity = 1f; + } + + void Update() + { + if(opacity > 0f) { + opacity -= disappearanceSpeed * Time.deltaTime; + } + text.color = new Color(text.color.r, text.color.g, text.color.b, opacity); + } +} diff --git a/Assets/Scripts/MessageBar.cs.meta b/Assets/Scripts/MessageBar.cs.meta new file mode 100644 index 0000000..d67dcf1 --- /dev/null +++ b/Assets/Scripts/MessageBar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9584516e85b5cb54eab0c7dafa1094f1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/TurnHandler.cs b/Assets/Scripts/TurnHandler.cs index 343618a..4493018 100644 --- a/Assets/Scripts/TurnHandler.cs +++ b/Assets/Scripts/TurnHandler.cs @@ -4,6 +4,17 @@ using UnityEngine; public class TurnHandler : MonoBehaviour { + private MessageBar messageBar; + + private void Start() { + GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); + messageBar = canvas.GetComponentInChildren(); + } + + public void WriteToMessageBar(string message) { + messageBar.Write(message); + } + public void OnTurn() { AI[] ais = gameObject.GetComponentsInChildren(); foreach(AI ai in ais) { diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 17c8f53..bdc6795 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -4,292 +4,4 @@ InputManager: m_ObjectHideFlags: 0 serializedVersion: 2 - m_Axes: - - serializedVersion: 3 - m_Name: Horizontal - descriptiveName: - descriptiveNegativeName: - negativeButton: left - positiveButton: right - altNegativeButton: a - altPositiveButton: d - gravity: 3 - dead: 0.001 - sensitivity: 3 - snap: 1 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Vertical - descriptiveName: - descriptiveNegativeName: - negativeButton: down - positiveButton: up - altNegativeButton: s - altPositiveButton: w - gravity: 3 - dead: 0.001 - sensitivity: 3 - snap: 1 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left ctrl - altNegativeButton: - altPositiveButton: mouse 0 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left alt - altNegativeButton: - altPositiveButton: mouse 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left shift - altNegativeButton: - altPositiveButton: mouse 2 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Jump - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: space - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse X - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse Y - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse ScrollWheel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 2 - joyNum: 0 - - serializedVersion: 3 - m_Name: Horizontal - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Vertical - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 1 - type: 2 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 0 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 1 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 2 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Jump - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 3 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: return - altNegativeButton: - altPositiveButton: joystick button 0 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: enter - altNegativeButton: - altPositiveButton: space - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Cancel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: escape - altNegativeButton: - altPositiveButton: joystick button 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 + m_Axes: [] diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 4ae8c38..931c141 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -4,94 +4,10 @@ QualitySettings: m_ObjectHideFlags: 0 serializedVersion: 5 - m_CurrentQuality: 3 + m_CurrentQuality: 0 m_QualitySettings: - serializedVersion: 2 - name: Very Low - pixelLightCount: 0 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 15 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 1 - textureQuality: 1 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 0 - lodBias: 0.3 - maximumLODLevel: 0 - particleRaycastBudget: 4 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Low - pixelLightCount: 0 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 20 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 0 - lodBias: 0.4 - maximumLODLevel: 0 - particleRaycastBudget: 16 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Medium - pixelLightCount: 1 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 20 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 1 - lodBias: 0.7 - maximumLODLevel: 0 - particleRaycastBudget: 64 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: High + name: Yes pixelLightCount: 2 shadows: 0 shadowResolution: 1 @@ -102,7 +18,7 @@ QualitySettings: shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} shadowmaskMode: 1 - blendWeights: 2 + skinWeights: 2 textureQuality: 0 anisotropicTextures: 0 antiAliasing: 0 @@ -113,79 +29,30 @@ QualitySettings: vSyncCount: 1 lodBias: 1 maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 256 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 16 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Very High - pixelLightCount: 3 - shadows: 0 - shadowResolution: 2 - shadowProjection: 1 - shadowCascades: 2 - shadowDistance: 70 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 1 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 1 - lodBias: 1.5 - maximumLODLevel: 0 - particleRaycastBudget: 1024 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Ultra - pixelLightCount: 4 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 4 - shadowDistance: 150 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 1 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 1 - lodBias: 2 - maximumLODLevel: 0 - particleRaycastBudget: 4096 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 resolutionScalingFixedDPIFactor: 1 excludedTargetPlatforms: [] m_PerPlatformDefaultQuality: - Android: 2 - Nintendo 3DS: 5 - Nintendo Switch: 5 - PS4: 5 - PSM: 5 - PSP2: 2 - Standalone: 5 - Tizen: 2 - WebGL: 3 - WiiU: 5 - Windows Store Apps: 5 - XboxOne: 5 - iPhone: 2 - tvOS: 2 + Android: 0 + Nintendo 3DS: 0 + Nintendo Switch: 0 + PS4: 0 + PSM: 0 + PSP2: 0 + Standalone: 0 + Tizen: 0 + WebGL: 0 + WiiU: 0 + Windows Store Apps: 0 + XboxOne: 0 + iPhone: 0 + tvOS: 0 From fe80dc2a0f864cf8a046e51cf3b9866bf77ae4ad Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 15:37:37 +0200 Subject: [PATCH 04/10] Update gamecontroller prefab --- Assets/Prefabs/GameController.prefab | 38 +++++++--------------------- Assets/Scenes/Steffo.unity | 37 ++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab index 0ba0dce..7d30b1c 100644 --- a/Assets/Prefabs/GameController.prefab +++ b/Assets/Prefabs/GameController.prefab @@ -143,7 +143,6 @@ GameObject: m_Component: - component: {fileID: 1816923098} - component: {fileID: 1816923100} - - component: {fileID: 1816923099} m_Layer: 0 m_Name: EventSystem m_TagString: EventSystem @@ -180,25 +179,6 @@ MonoBehaviour: m_FirstSelected: {fileID: 0} m_sendNavigationEvents: 1 m_DragThreshold: 10 ---- !u!114 &1816923099 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1816923097} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 --- !u!1 &1792584738874209504 GameObject: m_ObjectHideFlags: 0 @@ -385,11 +365,11 @@ MonoBehaviour: m_MaxSize: 40 m_Alignment: 1 m_AlignByGeometry: 0 - m_RichText: 1 + m_RichText: 0 m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: PICKED UP 1000G. + m_Text: Hello! I'm THE MESSAGE BAR! --- !u!114 &6763073704789207260 MonoBehaviour: m_ObjectHideFlags: 0 @@ -436,11 +416,11 @@ RectTransform: m_Father: {fileID: 1591973061} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0, y: 0} + m_Pivot: {x: 1, y: 0} --- !u!222 &5318808085005978312 CanvasRenderer: m_ObjectHideFlags: 0 @@ -475,7 +455,7 @@ MonoBehaviour: m_FillCenter: 1 m_FillMethod: 2 m_FillAmount: 1 - m_FillClockwise: 0 + m_FillClockwise: 1 m_FillOrigin: 0 m_UseSpriteMesh: 0 --- !u!114 &5816643265615328278 @@ -523,11 +503,11 @@ RectTransform: m_Father: {fileID: 1591973061} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0, y: 0} + m_Pivot: {x: 1, y: 0} --- !u!222 &8182065397885380582 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Steffo.unity b/Assets/Scenes/Steffo.unity index 04255fb..3a74977 100644 --- a/Assets/Scenes/Steffo.unity +++ b/Assets/Scenes/Steffo.unity @@ -187,10 +187,45 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 8182065397885380581, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_AnchorMin.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8182065397885380581, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8182065397885380581, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_Pivot.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1331449797751746845, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_AnchorMin.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1331449797751746845, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1331449797751746845, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_Pivot.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6406203509107481990, guid: 4c25f33cb89f6624db48fc49d353a7f2, + type: 3} + propertyPath: m_FillClockwise + value: 1 + objectReference: {fileID: 0} - target: {fileID: 6763073704789207266, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} propertyPath: m_Text - value: Text goes here. + value: Hello! I'm THE MESSAGE BAR! objectReference: {fileID: 0} - target: {fileID: 6763073704789207266, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3} From 67817addb9d8e8210e426d8f9cd1060fd9be97dd Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Sun, 28 Apr 2019 16:12:39 +0200 Subject: [PATCH 05/10] Add flask server for online functionalities --- Flask-Server/dummy.py | 3 +++ Flask-Server/server.py | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Flask-Server/dummy.py create mode 100644 Flask-Server/server.py diff --git a/Flask-Server/dummy.py b/Flask-Server/dummy.py new file mode 100644 index 0000000..da31816 --- /dev/null +++ b/Flask-Server/dummy.py @@ -0,0 +1,3 @@ +import requests +r = requests.post("http://127.0.0.1:5000/message/2", data={'content':'Piano 2'}) +print(r.text) \ No newline at end of file diff --git a/Flask-Server/server.py b/Flask-Server/server.py new file mode 100644 index 0000000..287fec6 --- /dev/null +++ b/Flask-Server/server.py @@ -0,0 +1,58 @@ +from flask import Flask, session, url_for, redirect, request, render_template, abort, flash, Markup, json +from datetime import datetime +from flask_sqlalchemy import SQLAlchemy +import random +import os +from sqlalchemy.sql.expression import func + +app = Flask(__name__) +app.secret_key = "debug-attivo" +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite' +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +db = SQLAlchemy(app) +app.config.from_object(__name__) + + +# Database Classes go beyond this line + +class Message(db.Model): + mid = db.Column(db.Integer, primary_key=True) + floor = db.Column(db.Integer, nullable=False) + content = db.Column(db.String, nullable=False) + + def toJSON(self): + return {"Message": {'floor': self.floor, + 'content': self.content}} + + def __init__(self, content, floor): + self.content = content + self.floor = floor + + def __repr__(self): + return self.content + + +def give_json_response(floor): + messages = Message.query.filter_by(floor=floor).order_by(func.random()).limit(5).all() + return json.dumps([message.toJSON() for message in messages]) + + +# Website pages and API functions go beyond this line +@app.route("/message/", methods=["GET", "POST"]) +def page_message(floor): + if request.method == "GET": + return give_json_response(floor) + newmessage = Message(request.form['content'], floor) + db.session.add(newmessage) + db.session.commit() + return "Success." + + +if __name__ == "__main__": + # Se non esiste il database viene creato + if not os.path.isfile("db.sqlite"): + newmessage = Message("Welcome to the dungeon, mortal.", 1) + db.create_all() + db.session.add(newmessage) + db.session.commit() + app.run(debug=True) From 1ac4d2866bb179376a915a7ddd025f437b3bd98c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 16:28:31 +0200 Subject: [PATCH 06/10] Commit a lot of stuff --- Assets/Prefabs/Player.prefab | 14 +++++ Assets/Prefabs/Slime.prefab | 4 +- Assets/Prefabs/TEST Item.prefab | 4 +- Assets/Scripts/Entity.cs | 8 +++ Assets/Scripts/Item.cs | 9 ++- Assets/Scripts/Map.cs | 2 +- Assets/Scripts/MessageBar.cs | 3 +- Assets/Scripts/Player.cs | 67 ++++++++++++++++++++--- Assets/Scripts/PlayerAttack.cs | 24 ++++++++ Assets/Scripts/PlayerAttack.cs.meta | 11 ++++ Assets/Scripts/PlayerAttack_Melee.cs | 18 ++++++ Assets/Scripts/PlayerAttack_Melee.cs.meta | 11 ++++ Assets/Scripts/TurnHandler.cs | 27 ++++----- 13 files changed, 172 insertions(+), 30 deletions(-) create mode 100644 Assets/Scripts/PlayerAttack.cs create mode 100644 Assets/Scripts/PlayerAttack.cs.meta create mode 100644 Assets/Scripts/PlayerAttack_Melee.cs create mode 100644 Assets/Scripts/PlayerAttack_Melee.cs.meta diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index d9785e0..b04f372 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -11,6 +11,7 @@ GameObject: - component: {fileID: 2935319493830293414} - component: {fileID: 2935319493830293413} - component: {fileID: -5893075763862095451} + - component: {fileID: 8856581523727923621} m_Layer: 0 m_Name: Player m_TagString: Player @@ -99,6 +100,19 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!114 &8856581523727923621 +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: 05a8e698d12930547a9e83f369e506d2, type: 3} + m_Name: + m_EditorClassIdentifier: + damage: 1 --- !u!1001 &5734536248370648602 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Slime.prefab b/Assets/Prefabs/Slime.prefab index 30a9177..e687bba 100644 --- a/Assets/Prefabs/Slime.prefab +++ b/Assets/Prefabs/Slime.prefab @@ -44,9 +44,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2fcfe4b94620b234fb7a294bf4453a69, type: 3} m_Name: m_EditorClassIdentifier: - hpMax: 0 + hpMax: 2 + overlappable: 0 hp: 0 sprite: {fileID: 21300000, guid: ee7ef72c830dc204c9df0595e161f049, type: 3} + moveChance: 0.5 visionRange: 4 --- !u!212 &1351652798109185028 SpriteRenderer: diff --git a/Assets/Prefabs/TEST Item.prefab b/Assets/Prefabs/TEST Item.prefab index d91ed64..00c5c0f 100644 --- a/Assets/Prefabs/TEST Item.prefab +++ b/Assets/Prefabs/TEST Item.prefab @@ -12,7 +12,7 @@ GameObject: - component: {fileID: 470211819356819162} - component: {fileID: 7501912107144583665} m_Layer: 0 - m_Name: TEST_ Item + m_Name: TEST Item m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -44,7 +44,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1f0883433553dbb4fa23a815949f596b, type: 3} m_Name: m_EditorClassIdentifier: - hpMax: 0 + hpMax: 1 overlappable: 0 hp: 0 sprite: {fileID: 21300000, guid: 5e4d29e1adc2ea0429b199b82253416c, type: 3} diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index bae1035..fc30c76 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -23,6 +23,7 @@ public class Entity : MonoBehaviour protected SpriteRenderer spriteRenderer; protected TurnHandler turnHandler; protected Map map; + protected MessageBar messageBar; protected virtual void Start() { @@ -31,6 +32,13 @@ public class Entity : MonoBehaviour gameController = GameObject.FindGameObjectWithTag("GameController"); turnHandler = gameController.GetComponentInChildren(); map = gameController.GetComponentInChildren(); + GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); + messageBar = canvas.GetComponentInChildren(); hp = hpMax; } + + public virtual void Die() { + Debug.LogWarning("Die not overridden"); + Destroy(gameObject); + } } diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/Item.cs index 5d99cf6..d115ecc 100644 --- a/Assets/Scripts/Item.cs +++ b/Assets/Scripts/Item.cs @@ -4,6 +4,8 @@ using UnityEngine; public class Item : Entity { + public static string itemName = "White Triangle"; + protected override void Start() { base.Start(); overlappable = true; @@ -11,7 +13,12 @@ public class Item : Entity public virtual void OnPickup(Player player) { Debug.LogWarning("OnPickup not overridden"); - turnHandler.WriteToMessageBar("Picked up [NULL]."); + messageBar.Write("Picked up: " + itemName, Color.yellow); + Destroy(gameObject); + } + + public override void Die() { + messageBar.Write("Destroyed: " + itemName, Color.red); Destroy(gameObject); } } \ No newline at end of file diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index 696e369..8afa7d2 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -138,7 +138,7 @@ public class Map : MonoBehaviour { try { bool walkable = GetTile(position).walkable; - List entities = turnHandler.GetEntityAtPosition(position); + List entities = turnHandler.GetEntitiesAtPosition(position); bool free = true; foreach(Entity entity in entities) { free &= entity.overlappable; diff --git a/Assets/Scripts/MessageBar.cs b/Assets/Scripts/MessageBar.cs index e70ffe8..1c2fc3d 100644 --- a/Assets/Scripts/MessageBar.cs +++ b/Assets/Scripts/MessageBar.cs @@ -17,7 +17,8 @@ public class MessageBar : MonoBehaviour opacity = 0f; } - public void Write(string message) { + public void Write(string message, Color color) { + text.color = color; text.text = message; opacity = 1f; } diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index dd6ccc9..6f57ee4 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -2,20 +2,69 @@ using System.Collections.Generic; using UnityEngine; +public enum ControlMode { + Move, + Attack +} + public class Player : Entity { public int exp; public int level; - void Update() - { - CheckForMovementInput(); + protected ControlMode controlMode; + + protected override void Start() { + base.Start(); + controlMode = ControlMode.Move; } - void CheckForMovementInput() + protected void Update() + { + CheckForControlModeChange(); + if(controlMode == ControlMode.Move) CheckForMovementInput(); + if(controlMode == ControlMode.Attack) CheckForAttackInput(); + } + + protected void CheckForControlModeChange() { + if(Input.GetKeyDown(KeyCode.Escape)) { + controlMode = ControlMode.Move; + messageBar.Write("Control mode: Move", Color.cyan); + } + if(Input.GetKeyDown(KeyCode.A)) { + controlMode = ControlMode.Attack; + messageBar.Write("Control mode: Attack", Color.cyan); + } + } + + protected void CheckForAttackInput() { + bool hasAttacked = false; + if (Input.GetKeyDown(KeyCode.LeftArrow)) + { + hasAttacked = GetComponent().Attack(MapPosition + Vector2Int.left); + } + else if (Input.GetKeyDown(KeyCode.RightArrow)) + { + hasAttacked = GetComponent().Attack(MapPosition + Vector2Int.right); + } + else if (Input.GetKeyDown(KeyCode.UpArrow)) + { + hasAttacked = GetComponent().Attack(MapPosition + Vector2Int.up); + } + else if (Input.GetKeyDown(KeyCode.DownArrow)) + { + hasAttacked = GetComponent().Attack(MapPosition + Vector2Int.down); + } + if(hasAttacked) { + //Turn happens! + turnHandler.OnTurn(); + } + } + + protected void CheckForMovementInput() { bool hasMoved = false; - if (Input.GetKeyDown(KeyCode.A)) + if (Input.GetKeyDown(KeyCode.LeftArrow)) { if (map.CanMoveTo(MapPosition + Vector2Int.left)) { transform.Translate(Vector3.left); @@ -23,7 +72,7 @@ public class Player : Entity spriteRenderer.flipX = false; } } - else if (Input.GetKeyDown(KeyCode.D)) + else if (Input.GetKeyDown(KeyCode.RightArrow)) { if (map.CanMoveTo(MapPosition + Vector2Int.right)) { transform.Translate(Vector3.right); @@ -31,14 +80,14 @@ public class Player : Entity spriteRenderer.flipX = true; } } - else if (Input.GetKeyDown(KeyCode.W)) + else if (Input.GetKeyDown(KeyCode.UpArrow)) { if (map.CanMoveTo(MapPosition + Vector2Int.up)) { transform.Translate(Vector3.up); hasMoved = true; } } - else if (Input.GetKeyDown(KeyCode.S)) + else if (Input.GetKeyDown(KeyCode.DownArrow)) { if (map.CanMoveTo(MapPosition + Vector2Int.down)) { transform.Translate(Vector3.down); @@ -47,7 +96,7 @@ public class Player : Entity } if(hasMoved) { //Check for pickuppable items - List entities = turnHandler.GetEntityAtPosition(MapPosition); + List entities = turnHandler.GetEntitiesAtPosition(MapPosition); foreach(Entity entity in entities) { if(entity is Item) { Item item = entity as Item; diff --git a/Assets/Scripts/PlayerAttack.cs b/Assets/Scripts/PlayerAttack.cs new file mode 100644 index 0000000..2f33699 --- /dev/null +++ b/Assets/Scripts/PlayerAttack.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerAttack : MonoBehaviour +{ + protected Player player; + protected GameObject gameController; + protected TurnHandler turnHandler; + protected Map map; + + protected void Start() { + player = GetComponent(); + gameController = GameObject.FindGameObjectWithTag("GameController"); + turnHandler = gameController.GetComponentInChildren(); + map = gameController.GetComponentInChildren(); + } + + public virtual bool Attack(Vector2Int target) { + //Returns if the attack was successful. + Debug.LogWarning("Attack not overridden"); + return false; + } +} \ No newline at end of file diff --git a/Assets/Scripts/PlayerAttack.cs.meta b/Assets/Scripts/PlayerAttack.cs.meta new file mode 100644 index 0000000..86ea067 --- /dev/null +++ b/Assets/Scripts/PlayerAttack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1bb56d02d177e9e4e9146940057ba1ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlayerAttack_Melee.cs b/Assets/Scripts/PlayerAttack_Melee.cs new file mode 100644 index 0000000..81f67d6 --- /dev/null +++ b/Assets/Scripts/PlayerAttack_Melee.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerAttack_Melee : PlayerAttack +{ + public float damage = 1f; + + public override bool Attack(Vector2Int target) { + List targetEntities = turnHandler.GetEntitiesAtPosition(target); + if(targetEntities.Count == 0) { + return false; + } + Entity targetEntity = targetEntities[0]; + targetEntity.hp -= damage; + return true; + } +} \ No newline at end of file diff --git a/Assets/Scripts/PlayerAttack_Melee.cs.meta b/Assets/Scripts/PlayerAttack_Melee.cs.meta new file mode 100644 index 0000000..ad531d2 --- /dev/null +++ b/Assets/Scripts/PlayerAttack_Melee.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 05a8e698d12930547a9e83f369e506d2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/TurnHandler.cs b/Assets/Scripts/TurnHandler.cs index 4493018..bd41358 100644 --- a/Assets/Scripts/TurnHandler.cs +++ b/Assets/Scripts/TurnHandler.cs @@ -4,25 +4,22 @@ using UnityEngine; public class TurnHandler : MonoBehaviour { - private MessageBar messageBar; - - private void Start() { - GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); - messageBar = canvas.GetComponentInChildren(); - } - - public void WriteToMessageBar(string message) { - messageBar.Write(message); - } - public void OnTurn() { - AI[] ais = gameObject.GetComponentsInChildren(); - foreach(AI ai in ais) { - ai.OnTurn(); + Entity[] entities = gameObject.GetComponentsInChildren(); + foreach(Entity entity in entities) { + //Check for deaths + if(entity.hp <= 0) { + entity.Die(); + } + //Move AIs + if(entity is AI) { + AI ai = entity as AI; + ai.OnTurn(); + } } } - public List GetEntityAtPosition(Vector2Int position) { + public List GetEntitiesAtPosition(Vector2Int position) { Entity[] entities = GetComponentsInChildren(); List found = new List(); foreach(Entity entity in entities) { From 09333ab4dd79e7bee5cdfc622b98c62a2810f88b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 16:34:50 +0200 Subject: [PATCH 07/10] Abuse of the refactor function --- Assets/Prefabs/MainCamera.prefab | 85 -------- Assets/Prefabs/MainCamera.prefab.meta | 7 - Assets/Prefabs/Player.prefab | 198 +++++++++--------- Assets/Prefabs/Slime.prefab | 38 ++-- Assets/Prefabs/TEST Item.prefab | 6 +- Assets/Scripts/{Item.cs => EntityItem.cs} | 4 +- .../{AISlime.cs.meta => EntityItem.cs.meta} | 2 +- Assets/Scripts/{AI.cs => EntityMonster.cs} | 2 +- .../{Player.cs.meta => EntityMonster.cs.meta} | 2 +- .../{AISlime.cs => EntityMonsterSlime.cs} | 6 +- ...tem.cs.meta => EntityMonsterSlime.cs.meta} | 2 +- Assets/Scripts/{Player.cs => EntityPlayer.cs} | 6 +- .../{AI.cs.meta => EntityPlayer.cs.meta} | 2 +- Assets/Scripts/FillAmountFromPlayerHP.cs | 4 +- Assets/Scripts/Map.cs | 12 +- Assets/Scripts/{Tile.cs => MapTile.cs} | 2 +- .../Scripts/{Tile.cs.meta => MapTile.cs.meta} | 0 Assets/Scripts/PlayerAttack.cs | 4 +- ...erAttack_Melee.cs => PlayerAttackMelee.cs} | 2 +- Assets/Scripts/PlayerAttackMelee.cs.meta | 11 + Assets/Scripts/PlayerAttack_Melee.cs.meta | 11 - Assets/Scripts/TurnHandler.cs | 4 +- 22 files changed, 163 insertions(+), 247 deletions(-) delete mode 100644 Assets/Prefabs/MainCamera.prefab delete mode 100644 Assets/Prefabs/MainCamera.prefab.meta rename Assets/Scripts/{Item.cs => EntityItem.cs} (85%) rename Assets/Scripts/{AISlime.cs.meta => EntityItem.cs.meta} (83%) rename Assets/Scripts/{AI.cs => EntityMonster.cs} (83%) rename Assets/Scripts/{Player.cs.meta => EntityMonster.cs.meta} (83%) rename Assets/Scripts/{AISlime.cs => EntityMonsterSlime.cs} (94%) rename Assets/Scripts/{Item.cs.meta => EntityMonsterSlime.cs.meta} (83%) rename Assets/Scripts/{Player.cs => EntityPlayer.cs} (95%) rename Assets/Scripts/{AI.cs.meta => EntityPlayer.cs.meta} (83%) rename Assets/Scripts/{Tile.cs => MapTile.cs} (90%) rename Assets/Scripts/{Tile.cs.meta => MapTile.cs.meta} (100%) rename Assets/Scripts/{PlayerAttack_Melee.cs => PlayerAttackMelee.cs} (90%) create mode 100644 Assets/Scripts/PlayerAttackMelee.cs.meta delete mode 100644 Assets/Scripts/PlayerAttack_Melee.cs.meta diff --git a/Assets/Prefabs/MainCamera.prefab b/Assets/Prefabs/MainCamera.prefab deleted file mode 100644 index a1cac78..0000000 --- a/Assets/Prefabs/MainCamera.prefab +++ /dev/null @@ -1,85 +0,0 @@ -%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: 0, g: 0, b: 0, 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: 8 - 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/MainCamera.prefab.meta b/Assets/Prefabs/MainCamera.prefab.meta deleted file mode 100644 index 03dd195..0000000 --- a/Assets/Prefabs/MainCamera.prefab.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 04409c352bfbdea4b9830f11d7b4d40e -PrefabImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index b04f372..54512d2 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -1,5 +1,88 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &2894367173346332696 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2894367173346332699} + - component: {fileID: 2894367173346332698} + - component: {fileID: 2894367173346332697} + 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 &2894367173346332699 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2894367173346332696} + 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: 2935319493830293414} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &2894367173346332698 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2894367173346332696} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, 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: 8 + 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 &2894367173346332697 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2894367173346332696} + m_Enabled: 1 --- !u!1 &2935319493830293412 GameObject: m_ObjectHideFlags: 0 @@ -9,8 +92,8 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2935319493830293414} - - component: {fileID: 2935319493830293413} - component: {fileID: -5893075763862095451} + - component: {fileID: 2935319493830293413} - component: {fileID: 8856581523727923621} m_Layer: 0 m_Name: Player @@ -34,24 +117,6 @@ Transform: 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: - hpMax: 10 - overlappable: 0 - hp: 10 - sprite: {fileID: 21300000, guid: 88f4c277892ae9449a57b321cd810bce, type: 3} - exp: 0 - level: 0 --- !u!212 &-5893075763862095451 SpriteRenderer: m_ObjectHideFlags: 0 @@ -100,6 +165,24 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 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: f16e1b4841b0d4546a52853aafbb7d85, type: 3} + m_Name: + m_EditorClassIdentifier: + hpMax: 0 + overlappable: 0 + hp: 0 + sprite: {fileID: 0} + exp: 0 + level: 0 --- !u!114 &8856581523727923621 MonoBehaviour: m_ObjectHideFlags: 0 @@ -109,82 +192,7 @@ MonoBehaviour: m_GameObject: {fileID: 2935319493830293412} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 05a8e698d12930547a9e83f369e506d2, type: 3} + m_Script: {fileID: 11500000, guid: 0cb881aee511ed643880a50159d731b7, type: 3} m_Name: m_EditorClassIdentifier: damage: 1 ---- !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 index e687bba..b3bc9aa 100644 --- a/Assets/Prefabs/Slime.prefab +++ b/Assets/Prefabs/Slime.prefab @@ -9,8 +9,8 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2043533519980591455} - - component: {fileID: 571363246873614695} - component: {fileID: 1351652798109185028} + - component: {fileID: 571363246873614695} m_Layer: 0 m_Name: Slime m_TagString: Untagged @@ -32,24 +32,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !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: 2 - overlappable: 0 - hp: 0 - sprite: {fileID: 21300000, guid: ee7ef72c830dc204c9df0595e161f049, type: 3} - moveChance: 0.5 - visionRange: 4 --- !u!212 &1351652798109185028 SpriteRenderer: m_ObjectHideFlags: 0 @@ -98,3 +80,21 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !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: 1ce1b6adc640d6f46bbf4d7072735b7f, type: 3} + m_Name: + m_EditorClassIdentifier: + hpMax: 0 + overlappable: 0 + hp: 0 + sprite: {fileID: 0} + moveChance: 0.5 + visionRange: 4 diff --git a/Assets/Prefabs/TEST Item.prefab b/Assets/Prefabs/TEST Item.prefab index 00c5c0f..ea25af2 100644 --- a/Assets/Prefabs/TEST Item.prefab +++ b/Assets/Prefabs/TEST Item.prefab @@ -41,13 +41,13 @@ MonoBehaviour: m_GameObject: {fileID: 470211819356819165} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 1f0883433553dbb4fa23a815949f596b, type: 3} + m_Script: {fileID: 11500000, guid: cfb3c44da9ebb1840b5a2bcdfd5e2730, type: 3} m_Name: m_EditorClassIdentifier: - hpMax: 1 + hpMax: 0 overlappable: 0 hp: 0 - sprite: {fileID: 21300000, guid: 5e4d29e1adc2ea0429b199b82253416c, type: 3} + sprite: {fileID: 0} --- !u!212 &7501912107144583665 SpriteRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/EntityItem.cs similarity index 85% rename from Assets/Scripts/Item.cs rename to Assets/Scripts/EntityItem.cs index d115ecc..c68562e 100644 --- a/Assets/Scripts/Item.cs +++ b/Assets/Scripts/EntityItem.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -public class Item : Entity +public class EntityItem : Entity { public static string itemName = "White Triangle"; @@ -11,7 +11,7 @@ public class Item : Entity overlappable = true; } - public virtual void OnPickup(Player player) { + public virtual void OnPickup(EntityPlayer player) { Debug.LogWarning("OnPickup not overridden"); messageBar.Write("Picked up: " + itemName, Color.yellow); Destroy(gameObject); diff --git a/Assets/Scripts/AISlime.cs.meta b/Assets/Scripts/EntityItem.cs.meta similarity index 83% rename from Assets/Scripts/AISlime.cs.meta rename to Assets/Scripts/EntityItem.cs.meta index 9c04775..45a55ad 100644 --- a/Assets/Scripts/AISlime.cs.meta +++ b/Assets/Scripts/EntityItem.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2fcfe4b94620b234fb7a294bf4453a69 +guid: cfb3c44da9ebb1840b5a2bcdfd5e2730 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/AI.cs b/Assets/Scripts/EntityMonster.cs similarity index 83% rename from Assets/Scripts/AI.cs rename to Assets/Scripts/EntityMonster.cs index fd30b46..d724cd9 100644 --- a/Assets/Scripts/AI.cs +++ b/Assets/Scripts/EntityMonster.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class AI : Entity +public class EntityMonster : Entity { public virtual void OnTurn(){ Debug.LogWarning("OnTurn() not overridden"); diff --git a/Assets/Scripts/Player.cs.meta b/Assets/Scripts/EntityMonster.cs.meta similarity index 83% rename from Assets/Scripts/Player.cs.meta rename to Assets/Scripts/EntityMonster.cs.meta index 4cba488..1e746d3 100644 --- a/Assets/Scripts/Player.cs.meta +++ b/Assets/Scripts/EntityMonster.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4de6b97c3d785d146a0df2c1c078fe91 +guid: aec5e971190b4b544a78be24566f9e6c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/AISlime.cs b/Assets/Scripts/EntityMonsterSlime.cs similarity index 94% rename from Assets/Scripts/AISlime.cs rename to Assets/Scripts/EntityMonsterSlime.cs index 85306a3..f1234de 100644 --- a/Assets/Scripts/AISlime.cs +++ b/Assets/Scripts/EntityMonsterSlime.cs @@ -2,15 +2,15 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class AISlime : AI +public class EntityMonsterSlime : EntityMonster { public float moveChance = 0.5f; public float visionRange = 4; - protected Player player; + protected EntityPlayer player; protected new void Start() { base.Start(); - player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); } public override void OnTurn(){ diff --git a/Assets/Scripts/Item.cs.meta b/Assets/Scripts/EntityMonsterSlime.cs.meta similarity index 83% rename from Assets/Scripts/Item.cs.meta rename to Assets/Scripts/EntityMonsterSlime.cs.meta index 0b76504..3495293 100644 --- a/Assets/Scripts/Item.cs.meta +++ b/Assets/Scripts/EntityMonsterSlime.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1f0883433553dbb4fa23a815949f596b +guid: 1ce1b6adc640d6f46bbf4d7072735b7f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/EntityPlayer.cs similarity index 95% rename from Assets/Scripts/Player.cs rename to Assets/Scripts/EntityPlayer.cs index 6f57ee4..f30698d 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/EntityPlayer.cs @@ -7,7 +7,7 @@ public enum ControlMode { Attack } -public class Player : Entity +public class EntityPlayer : Entity { public int exp; public int level; @@ -98,8 +98,8 @@ public class Player : Entity //Check for pickuppable items List entities = turnHandler.GetEntitiesAtPosition(MapPosition); foreach(Entity entity in entities) { - if(entity is Item) { - Item item = entity as Item; + if(entity is EntityItem) { + EntityItem item = entity as EntityItem; item.OnPickup(this); } } diff --git a/Assets/Scripts/AI.cs.meta b/Assets/Scripts/EntityPlayer.cs.meta similarity index 83% rename from Assets/Scripts/AI.cs.meta rename to Assets/Scripts/EntityPlayer.cs.meta index 438e77b..370a2be 100644 --- a/Assets/Scripts/AI.cs.meta +++ b/Assets/Scripts/EntityPlayer.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e694420377849854db7a2686ff36420c +guid: f16e1b4841b0d4546a52853aafbb7d85 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/FillAmountFromPlayerHP.cs b/Assets/Scripts/FillAmountFromPlayerHP.cs index db83a6c..be01f33 100644 --- a/Assets/Scripts/FillAmountFromPlayerHP.cs +++ b/Assets/Scripts/FillAmountFromPlayerHP.cs @@ -5,11 +5,11 @@ using UnityEngine.UI; public class FillAmountFromPlayerHP : MonoBehaviour { - private Player player; + private EntityPlayer player; private Image image; private void Start() { - player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); image = GetComponent(); } diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index 8afa7d2..a5f6c3d 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -124,10 +124,10 @@ public class Map : MonoBehaviour private List rooms; private TurnHandler turnHandler; - public Tile GetTile(Vector2Int position) { + public MapTile GetTile(Vector2Int position) { try { GameObject tileObject = tiles[position.x, position.y]; - return tileObject.GetComponent(); + return tileObject.GetComponent(); } catch(System.IndexOutOfRangeException) { return null; @@ -151,7 +151,7 @@ public class Map : MonoBehaviour } private void EditTile(Vector2Int position, bool walkable, bool roomPart) { - Tile tile = GetTile(position); + MapTile tile = GetTile(position); tile.walkable = walkable; tile.roomPart |= roomPart; } @@ -163,7 +163,7 @@ public class Map : MonoBehaviour tileObject.transform.position = new Vector3(x, y, 0); tiles[x, y] = tileObject; tileObject.name = "Tile [" + x.ToString() + ", " + y.ToString() + "]"; - Tile tile = tileObject.GetComponent(); + MapTile tile = tileObject.GetComponent(); tile.walkable = false; } } @@ -270,8 +270,8 @@ public class Map : MonoBehaviour public void GenerateTileSprites() { for(int x = 0; x < mapSize; x++) { for(int y = 0; y < mapSize; y++) { - Tile tile = GetTile(new Vector2Int(x, y)); - Tile otherTile; + MapTile tile = GetTile(new Vector2Int(x, y)); + MapTile otherTile; if(tile.walkable) tile.sprite = SampleSprite(floorSprites); else if((bool)(otherTile = GetTile(new Vector2Int(x, y+1))) && otherTile.walkable) tile.sprite = SampleSprite(botWallSprites); else if((bool)(otherTile = GetTile(new Vector2Int(x, y+1))) && otherTile.walkable) tile.sprite = SampleSprite(topWallSprites); diff --git a/Assets/Scripts/Tile.cs b/Assets/Scripts/MapTile.cs similarity index 90% rename from Assets/Scripts/Tile.cs rename to Assets/Scripts/MapTile.cs index 04dec14..847627a 100644 --- a/Assets/Scripts/Tile.cs +++ b/Assets/Scripts/MapTile.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -public class Tile : MonoBehaviour +public class MapTile : MonoBehaviour { public bool walkable; public bool roomPart; diff --git a/Assets/Scripts/Tile.cs.meta b/Assets/Scripts/MapTile.cs.meta similarity index 100% rename from Assets/Scripts/Tile.cs.meta rename to Assets/Scripts/MapTile.cs.meta diff --git a/Assets/Scripts/PlayerAttack.cs b/Assets/Scripts/PlayerAttack.cs index 2f33699..b9b5d11 100644 --- a/Assets/Scripts/PlayerAttack.cs +++ b/Assets/Scripts/PlayerAttack.cs @@ -4,13 +4,13 @@ using UnityEngine; public class PlayerAttack : MonoBehaviour { - protected Player player; + protected EntityPlayer player; protected GameObject gameController; protected TurnHandler turnHandler; protected Map map; protected void Start() { - player = GetComponent(); + player = GetComponent(); gameController = GameObject.FindGameObjectWithTag("GameController"); turnHandler = gameController.GetComponentInChildren(); map = gameController.GetComponentInChildren(); diff --git a/Assets/Scripts/PlayerAttack_Melee.cs b/Assets/Scripts/PlayerAttackMelee.cs similarity index 90% rename from Assets/Scripts/PlayerAttack_Melee.cs rename to Assets/Scripts/PlayerAttackMelee.cs index 81f67d6..936f9da 100644 --- a/Assets/Scripts/PlayerAttack_Melee.cs +++ b/Assets/Scripts/PlayerAttackMelee.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class PlayerAttack_Melee : PlayerAttack +public class PlayerAttackMelee : PlayerAttack { public float damage = 1f; diff --git a/Assets/Scripts/PlayerAttackMelee.cs.meta b/Assets/Scripts/PlayerAttackMelee.cs.meta new file mode 100644 index 0000000..9a4a586 --- /dev/null +++ b/Assets/Scripts/PlayerAttackMelee.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0cb881aee511ed643880a50159d731b7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlayerAttack_Melee.cs.meta b/Assets/Scripts/PlayerAttack_Melee.cs.meta deleted file mode 100644 index ad531d2..0000000 --- a/Assets/Scripts/PlayerAttack_Melee.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 05a8e698d12930547a9e83f369e506d2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/TurnHandler.cs b/Assets/Scripts/TurnHandler.cs index bd41358..3165f09 100644 --- a/Assets/Scripts/TurnHandler.cs +++ b/Assets/Scripts/TurnHandler.cs @@ -12,8 +12,8 @@ public class TurnHandler : MonoBehaviour entity.Die(); } //Move AIs - if(entity is AI) { - AI ai = entity as AI; + if(entity is EntityMonster) { + EntityMonster ai = entity as EntityMonster; ai.OnTurn(); } } From c1925499ffa62e7abe854b7a66c519f1077d4cce Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 16:35:37 +0200 Subject: [PATCH 08/10] Remove unused exp and player --- Assets/Scripts/EntityPlayer.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Assets/Scripts/EntityPlayer.cs b/Assets/Scripts/EntityPlayer.cs index f30698d..2b04105 100644 --- a/Assets/Scripts/EntityPlayer.cs +++ b/Assets/Scripts/EntityPlayer.cs @@ -9,9 +9,6 @@ public enum ControlMode { public class EntityPlayer : Entity { - public int exp; - public int level; - protected ControlMode controlMode; protected override void Start() { From 55df0367ce01c05ac029b72fea320a86e6350003 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Apr 2019 16:44:16 +0200 Subject: [PATCH 09/10] Give a name to things --- Assets/Prefabs/GameController.prefab | 3 ++- Assets/Prefabs/Player.prefab | 2 +- Assets/Prefabs/Slime.prefab | 2 +- Assets/Prefabs/TEST Item.prefab | 2 +- Assets/Scripts/Entity.cs | 4 ---- Assets/Scripts/EntityItem.cs | 11 ++++++++--- Assets/Scripts/EntityMonster.cs | 12 ++++++++++++ Assets/Scripts/EntityMonsterSlime.cs | 6 ++++++ 8 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab index 7d30b1c..835ca33 100644 --- a/Assets/Prefabs/GameController.prefab +++ b/Assets/Prefabs/GameController.prefab @@ -289,7 +289,8 @@ MonoBehaviour: type: 3} enemyPrefabs: - {fileID: 470211819356819165, guid: 1bd6e08f590fdd844854a34504aeaa4a, type: 3} - enemiesToSpawn: 10 + - {fileID: 1164136568549368904, guid: a4aeecfb369f0974490d158ef9489335, type: 3} + enemiesToSpawn: 15 --- !u!1 &6763073704789207264 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 54512d2..0e27d8e 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -177,7 +177,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f16e1b4841b0d4546a52853aafbb7d85, type: 3} m_Name: m_EditorClassIdentifier: - hpMax: 0 + hpMax: 10 overlappable: 0 hp: 0 sprite: {fileID: 0} diff --git a/Assets/Prefabs/Slime.prefab b/Assets/Prefabs/Slime.prefab index b3bc9aa..40d7ddf 100644 --- a/Assets/Prefabs/Slime.prefab +++ b/Assets/Prefabs/Slime.prefab @@ -92,7 +92,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1ce1b6adc640d6f46bbf4d7072735b7f, type: 3} m_Name: m_EditorClassIdentifier: - hpMax: 0 + hpMax: 2 overlappable: 0 hp: 0 sprite: {fileID: 0} diff --git a/Assets/Prefabs/TEST Item.prefab b/Assets/Prefabs/TEST Item.prefab index ea25af2..fc955a3 100644 --- a/Assets/Prefabs/TEST Item.prefab +++ b/Assets/Prefabs/TEST Item.prefab @@ -44,7 +44,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: cfb3c44da9ebb1840b5a2bcdfd5e2730, type: 3} m_Name: m_EditorClassIdentifier: - hpMax: 0 + hpMax: 1 overlappable: 0 hp: 0 sprite: {fileID: 0} diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index fc30c76..c2cfe15 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -10,9 +10,6 @@ public class Entity : MonoBehaviour [AfterStartAttribute] public float hp; - [BeforeStartAttribute] - public Sprite sprite; - public Vector2Int MapPosition { get { return new Vector2Int((int)transform.position.x, (int)transform.position.y); @@ -28,7 +25,6 @@ public class Entity : MonoBehaviour protected virtual void Start() { spriteRenderer = GetComponent(); - spriteRenderer.sprite = sprite; gameController = GameObject.FindGameObjectWithTag("GameController"); turnHandler = gameController.GetComponentInChildren(); map = gameController.GetComponentInChildren(); diff --git a/Assets/Scripts/EntityItem.cs b/Assets/Scripts/EntityItem.cs index c68562e..1d62286 100644 --- a/Assets/Scripts/EntityItem.cs +++ b/Assets/Scripts/EntityItem.cs @@ -4,7 +4,12 @@ using UnityEngine; public class EntityItem : Entity { - public static string itemName = "White Triangle"; + public virtual string Name { + get { + Debug.LogWarning("No name given to an item"); + return ""; + } + } protected override void Start() { base.Start(); @@ -13,12 +18,12 @@ public class EntityItem : Entity public virtual void OnPickup(EntityPlayer player) { Debug.LogWarning("OnPickup not overridden"); - messageBar.Write("Picked up: " + itemName, Color.yellow); + messageBar.Write("Picked up: " + Name, Color.yellow); Destroy(gameObject); } public override void Die() { - messageBar.Write("Destroyed: " + itemName, Color.red); + messageBar.Write("Destroyed: " + Name, Color.red); Destroy(gameObject); } } \ No newline at end of file diff --git a/Assets/Scripts/EntityMonster.cs b/Assets/Scripts/EntityMonster.cs index d724cd9..1a130b5 100644 --- a/Assets/Scripts/EntityMonster.cs +++ b/Assets/Scripts/EntityMonster.cs @@ -4,7 +4,19 @@ using UnityEngine; public class EntityMonster : Entity { + public virtual string Name { + get { + Debug.LogWarning("No name given to a monster"); + return ""; + } + } + public virtual void OnTurn(){ Debug.LogWarning("OnTurn() not overridden"); } + + public override void Die() { + messageBar.Write("Killed: " + Name, Color.red); + Destroy(gameObject); + } } \ No newline at end of file diff --git a/Assets/Scripts/EntityMonsterSlime.cs b/Assets/Scripts/EntityMonsterSlime.cs index f1234de..7b49a38 100644 --- a/Assets/Scripts/EntityMonsterSlime.cs +++ b/Assets/Scripts/EntityMonsterSlime.cs @@ -4,6 +4,12 @@ using UnityEngine; public class EntityMonsterSlime : EntityMonster { + public override string Name { + get { + return "Slime"; + } + } + public float moveChance = 0.5f; public float visionRange = 4; protected EntityPlayer player; From d943add3eae1e6a8bcd787f44982f9a3a056ce8b Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Sun, 28 Apr 2019 17:22:08 +0200 Subject: [PATCH 10/10] Add Heart Item --- Assets/Scripts/EntityItemHeart.cs | 27 ++++++++++++++++++++++++++ Assets/Scripts/EntityItemHeart.cs.meta | 11 +++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Assets/Scripts/EntityItemHeart.cs create mode 100644 Assets/Scripts/EntityItemHeart.cs.meta diff --git a/Assets/Scripts/EntityItemHeart.cs b/Assets/Scripts/EntityItemHeart.cs new file mode 100644 index 0000000..00f3983 --- /dev/null +++ b/Assets/Scripts/EntityItemHeart.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EntityItemHeart : EntityItem +{ + public int regen; + protected EntityPlayer player; + public override string Name { + get { + return "Heart"; + } + } + // Start is called before the first frame update + protected new void Start() { + base.Start(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + } + + // Update is called once per frame + public override void OnPickup(EntityPlayer player) { + messageBar.Write("You used: " + Name, Color.yellow); + player.hp+=regen; + if (player.hp > player.hpMax) player.hp = player.hpMax; + Destroy(gameObject); + } +} diff --git a/Assets/Scripts/EntityItemHeart.cs.meta b/Assets/Scripts/EntityItemHeart.cs.meta new file mode 100644 index 0000000..57e6a34 --- /dev/null +++ b/Assets/Scripts/EntityItemHeart.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c07fddfe35675304f92b18a213875e74 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: