diff --git a/Assets/Prefabs/NPCIdle.prefab b/Assets/Prefabs/NPCIdle.prefab index 8f8057c..573e714 100644 --- a/Assets/Prefabs/NPCIdle.prefab +++ b/Assets/Prefabs/NPCIdle.prefab @@ -166,6 +166,8 @@ MonoBehaviour: m_GameObject: {fileID: 4918528717594724652} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 87ac36bb4d63c7b4f901ce681578ca4b, type: 3} + m_Script: {fileID: 11500000, guid: 502dfdd16cfb094a89708a6d31f80af2, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} + isEnemy: 1 diff --git a/Assets/Prefabs/Rock_1.prefab b/Assets/Prefabs/Rock_1.prefab index 6068235..4d5cb26 100644 --- a/Assets/Prefabs/Rock_1.prefab +++ b/Assets/Prefabs/Rock_1.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 6365990307743021963} - component: {fileID: 6952935615892918535} - component: {fileID: 2329328608366088264} + - component: {fileID: 3373736657539295389} m_Layer: 0 m_Name: Rock_1 m_TagString: Object:Stone @@ -134,3 +135,16 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 122 m_CollisionDetection: 0 +--- !u!114 &3373736657539295389 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4852758362040146526} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fc88a9ab15a9238baf100c2fd070aa7, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2} diff --git a/Assets/Prefabs/Rock_2.prefab b/Assets/Prefabs/Rock_2.prefab index 663e2bb..07dca88 100644 --- a/Assets/Prefabs/Rock_2.prefab +++ b/Assets/Prefabs/Rock_2.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 3216712892522360414} - component: {fileID: 1477549268999423186} - component: {fileID: 3850889906121968706} + - component: {fileID: 3470364473752288912} m_Layer: 0 m_Name: Rock_2 m_TagString: Object:Stone @@ -134,3 +135,16 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 122 m_CollisionDetection: 0 +--- !u!114 &3470364473752288912 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4009596908532748171} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fc88a9ab15a9238baf100c2fd070aa7, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2} diff --git a/Assets/Prefabs/SlimeBaseIdle.prefab b/Assets/Prefabs/SlimeBaseIdle.prefab index a405269..dcb1537 100644 --- a/Assets/Prefabs/SlimeBaseIdle.prefab +++ b/Assets/Prefabs/SlimeBaseIdle.prefab @@ -211,9 +211,10 @@ MonoBehaviour: m_GameObject: {fileID: 4972404453844040047} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3} + m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} --- !u!64 &-3685426353244344161 MeshCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/SlimeBossIdle.prefab b/Assets/Prefabs/SlimeBossIdle.prefab index d580213..456a23a 100644 --- a/Assets/Prefabs/SlimeBossIdle.prefab +++ b/Assets/Prefabs/SlimeBossIdle.prefab @@ -295,9 +295,10 @@ MonoBehaviour: m_GameObject: {fileID: 7422307534756093511} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3} + m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} --- !u!64 &2645811048282726494 MeshCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/SlimeForestIdle.prefab b/Assets/Prefabs/SlimeForestIdle.prefab index 6c1c264..142ac38 100644 --- a/Assets/Prefabs/SlimeForestIdle.prefab +++ b/Assets/Prefabs/SlimeForestIdle.prefab @@ -306,9 +306,10 @@ MonoBehaviour: m_GameObject: {fileID: 9127354857402186281} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3} + m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} --- !u!64 &-1326613566692478026 MeshCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/SlimeMageIdle.prefab b/Assets/Prefabs/SlimeMageIdle.prefab index 6b80c04..bec8711 100644 --- a/Assets/Prefabs/SlimeMageIdle.prefab +++ b/Assets/Prefabs/SlimeMageIdle.prefab @@ -295,9 +295,10 @@ MonoBehaviour: m_GameObject: {fileID: 8445085162624319281} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3} + m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} --- !u!64 &3048554505669354710 MeshCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/SlimeMetalIdle.prefab b/Assets/Prefabs/SlimeMetalIdle.prefab index 7acbb34..d54015c 100644 --- a/Assets/Prefabs/SlimeMetalIdle.prefab +++ b/Assets/Prefabs/SlimeMetalIdle.prefab @@ -129,9 +129,10 @@ MonoBehaviour: m_GameObject: {fileID: 1452497377981145769} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3} + m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} --- !u!64 &3661858136180210843 MeshCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/SlimeMiniBossIdle.prefab b/Assets/Prefabs/SlimeMiniBossIdle.prefab index 83abd1e..b389b22 100644 --- a/Assets/Prefabs/SlimeMiniBossIdle.prefab +++ b/Assets/Prefabs/SlimeMiniBossIdle.prefab @@ -129,9 +129,10 @@ MonoBehaviour: m_GameObject: {fileID: 419805594404797990} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3} + m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} --- !u!64 &-4696269184063814604 MeshCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/SlimeWarriorIdle.prefab b/Assets/Prefabs/SlimeWarriorIdle.prefab index 049c294..0adaa23 100644 --- a/Assets/Prefabs/SlimeWarriorIdle.prefab +++ b/Assets/Prefabs/SlimeWarriorIdle.prefab @@ -297,9 +297,10 @@ MonoBehaviour: m_GameObject: {fileID: 7815009759384241731} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3} + m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3} m_Name: m_EditorClassIdentifier: + clip: {fileID: 0} --- !u!64 &6523941094505267678 MeshCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Tree_1.prefab b/Assets/Prefabs/Tree_1.prefab index 57db0bd..322d5dd 100644 --- a/Assets/Prefabs/Tree_1.prefab +++ b/Assets/Prefabs/Tree_1.prefab @@ -15,6 +15,7 @@ GameObject: - component: {fileID: 1658981204574654673} - component: {fileID: 6099884091545410372} - component: {fileID: 645566918292761053} + - component: {fileID: 3674917119847316386} m_Layer: 0 m_Name: Tree_1 m_TagString: Object:Tree @@ -4992,3 +4993,16 @@ ParticleSystemRenderer: m_MeshWeighting2: 1 m_MeshWeighting3: 1 m_MaskInteraction: 0 +--- !u!114 &3674917119847316386 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8867824946895199964} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9d069bae9082b7b60a2a05060a98424e, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: 4522681ee7a4e1196af04c3f4fc704d6, type: 2} diff --git a/Assets/Prefabs/Tree_2.prefab b/Assets/Prefabs/Tree_2.prefab index 0bed074..dfd95f7 100644 --- a/Assets/Prefabs/Tree_2.prefab +++ b/Assets/Prefabs/Tree_2.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 7366098166761564472} - component: {fileID: 6781544929942635444} - component: {fileID: 8075644600998223849} + - component: {fileID: 1343859431540429002} m_Layer: 0 m_Name: Tree_2 m_TagString: Object:Tree @@ -135,3 +136,16 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 122 m_CollisionDetection: 0 +--- !u!114 &1343859431540429002 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9023347993894783213} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9d069bae9082b7b60a2a05060a98424e, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: 4522681ee7a4e1196af04c3f4fc704d6, type: 2} diff --git a/Assets/Prefabs/copperOre.prefab b/Assets/Prefabs/copperOre.prefab index d9f7c3a..f18d8bf 100644 --- a/Assets/Prefabs/copperOre.prefab +++ b/Assets/Prefabs/copperOre.prefab @@ -94,6 +94,7 @@ GameObject: - component: {fileID: 4848850860749154617} - component: {fileID: -2572412590075727139} - component: {fileID: 4483093259101442725} + - component: {fileID: 5418233419134080367} m_Layer: 0 m_Name: copperOre m_TagString: Object:Ore @@ -167,6 +168,19 @@ MeshCollider: m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3} +--- !u!114 &5418233419134080367 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5188503590062044035} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2} --- !u!1 &8310517336631356992 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/goldOre.prefab b/Assets/Prefabs/goldOre.prefab index 753201d..ea0fb51 100644 --- a/Assets/Prefabs/goldOre.prefab +++ b/Assets/Prefabs/goldOre.prefab @@ -94,6 +94,7 @@ GameObject: - component: {fileID: 5321737818351179594} - component: {fileID: 8145716631555738662} - component: {fileID: 7075289032286914303} + - component: {fileID: 7599337776987165547} m_Layer: 0 m_Name: goldOre m_TagString: Object:Ore @@ -167,6 +168,19 @@ MeshCollider: m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3} +--- !u!114 &7599337776987165547 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4796699693279464944} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2} --- !u!1 &8774396427657433139 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/ironOre.prefab b/Assets/Prefabs/ironOre.prefab index 586d18b..b8a6532 100644 --- a/Assets/Prefabs/ironOre.prefab +++ b/Assets/Prefabs/ironOre.prefab @@ -94,6 +94,7 @@ GameObject: - component: {fileID: 6744453271754949240} - component: {fileID: 215655860811652073} - component: {fileID: 6576777228973474439} + - component: {fileID: 6437085144792087181} m_Layer: 0 m_Name: ironOre m_TagString: Object:Ore @@ -167,6 +168,19 @@ MeshCollider: m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3} +--- !u!114 &6437085144792087181 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6256287307790063810} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2} --- !u!1 &7892395422436754689 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/pnlQuest.prefab b/Assets/Prefabs/pnlQuest.prefab index 62e39f4..c2f1f4a 100644 --- a/Assets/Prefabs/pnlQuest.prefab +++ b/Assets/Prefabs/pnlQuest.prefab @@ -61,7 +61,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.27058825, g: 0.4117647, b: 0.5647059, a: 1} + m_Color: {r: 0.24313726, g: 0.53333336, b: 0.35686275, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 diff --git a/Assets/Prefabs/tinOre.prefab b/Assets/Prefabs/tinOre.prefab index 71d5de7..59e2b24 100644 --- a/Assets/Prefabs/tinOre.prefab +++ b/Assets/Prefabs/tinOre.prefab @@ -94,6 +94,7 @@ GameObject: - component: {fileID: 6024848534698070052} - component: {fileID: 70974923766122465} - component: {fileID: 6135128249415564205} + - component: {fileID: 8624121310591208666} m_Layer: 0 m_Name: tinOre m_TagString: Object:Ore @@ -167,6 +168,19 @@ MeshCollider: m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3} +--- !u!114 &8624121310591208666 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6401690393767201438} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3} + m_Name: + m_EditorClassIdentifier: + clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2} --- !u!1 &7170566803458479965 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index 7e8e1a6..b010fd2 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -13187,7 +13187,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 800x600 + m_Text: German --- !u!222 &722907595 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Controls.cs b/Assets/Scripts/Controls.cs index f16d4bb..28516da 100644 --- a/Assets/Scripts/Controls.cs +++ b/Assets/Scripts/Controls.cs @@ -6,6 +6,7 @@ using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.UI; using Assets.Scripts.Player; +using Assets.Scripts.InteractableObjects; public class Controls : MonoBehaviour { @@ -141,22 +142,17 @@ public class Controls : MonoBehaviour fight.GetComponent().startFight(worldGen.GetComponent().getCurrentTile(), target, player); break; case "Tree": - StartCoroutine(playAnimation(target, "Chopping")); player.GetComponent().getPlayer().getStat("TreeCount").changeAmount(1); GameObject.Find("Inventory").GetComponent().addItem(new Item("Wood")); break; case "Stone": - StartCoroutine(playAnimation(target, "Mining")); GameObject.Find("Inventory").GetComponent().addItem(new Item("Rock")); break; case "NPC": - target.GetComponent().interact(); break; case "Door": - target.GetComponent().interact(); break; case "Chest": - target.GetComponent().interact(); break; case "Ore": if (target.name.ToLower().Contains("iron")) @@ -176,44 +172,13 @@ public class Controls : MonoBehaviour GameObject.Find("Inventory").GetComponent().addItem(new Item("Tin ore")); } player.GetComponent().getPlayer().getStat("OreCount").changeAmount(1); - StartCoroutine(playAnimation(target, "Mining")); break; } + target.GetComponent().OnInteraction(player); } } } - IEnumerator playParticle(GameObject target) - { - Vector3 playerPos = player.transform.position; - playerPos.y = target.transform.position.y; - Quaternion newRotation = Quaternion.LookRotation(playerPos - target.transform.position, target.transform.TransformDirection(Vector3.up)); - ParticleSystem particleSystem = target.GetComponent(); - ParticleSystem.ShapeModule shape = particleSystem.shape; - shape.rotation = newRotation.eulerAngles; - particleSystem.Play(); - yield return new WaitUntil(() => !particleSystem.isPlaying); - Destroy(target); - } - - IEnumerator playAnimation(GameObject target, string key) - { - player.GetComponent().Play(key); - Animator animator = player.GetComponent(); - AnimationClip[] clips = animator.runtimeAnimatorController.animationClips; - float length = 0; - foreach (AnimationClip clip in clips) - { - if (clip.name.ToLower() == key.ToLower()) - { - length = clip.length; - break; - } - } - yield return new WaitForSeconds(length); - Destroy(target); - } - public void OnInventory() { uihandler.switchInventory(); diff --git a/Assets/Scripts/Fight.cs b/Assets/Scripts/Fight.cs index c58f807..8ab99cc 100644 --- a/Assets/Scripts/Fight.cs +++ b/Assets/Scripts/Fight.cs @@ -5,6 +5,7 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using Assets.Scripts.Player; +using Assets.Scripts.InteractableObjects; public class Fight : MonoBehaviour { diff --git a/Assets/Scripts/Handler/UIHandler.cs b/Assets/Scripts/Handler/UIHandler.cs index cb039bf..8a13014 100644 --- a/Assets/Scripts/Handler/UIHandler.cs +++ b/Assets/Scripts/Handler/UIHandler.cs @@ -7,6 +7,7 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Localization.Settings; using UnityEngine.UI; +using Assets.Scripts.InteractableObjects; namespace Assets.Scripts { diff --git a/Assets/Scripts/InteractableObjects.meta b/Assets/Scripts/InteractableObjects.meta new file mode 100644 index 0000000..c2328ba --- /dev/null +++ b/Assets/Scripts/InteractableObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: abcb4e1f5010a0bde9b4bdc47563e496 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Chest.cs b/Assets/Scripts/InteractableObjects/Chest.cs similarity index 78% rename from Assets/Scripts/Chest.cs rename to Assets/Scripts/InteractableObjects/Chest.cs index 0fefb34..eaa0a49 100644 --- a/Assets/Scripts/Chest.cs +++ b/Assets/Scripts/InteractableObjects/Chest.cs @@ -4,24 +4,13 @@ using UnityEngine; using System; using Assets.Scripts.Player; -namespace Assets.Scripts +namespace Assets.Scripts.InteractableObjects { - public class Chest : MonoBehaviour + public class Chest : InteractableObject { bool gotItem = false; - // Start is called before the first frame update - void Start() - { - } - - // Update is called once per frame - void Update() - { - - } - - public void interact(){ + public override void handleInteraction(GameObject player){ if (gotItem) { GameObject.Find("UIHandler").GetComponent().showMessage("ERROR;"+TextHandler.getText("alreadyLooted")); @@ -30,7 +19,7 @@ namespace Assets.Scripts { gameObject.transform.Find("Lid").GetComponent().Play("ChestOpen"); Item item; - int luck = GameObject.Find("Player").GetComponent().getPlayerStat("Luck").getAmount(); + int luck = player.GetComponent().getPlayerStat("Luck").getAmount(); int type = new System.Random().Next(3); switch (type) { diff --git a/Assets/Scripts/Chest.cs.meta b/Assets/Scripts/InteractableObjects/Chest.cs.meta similarity index 83% rename from Assets/Scripts/Chest.cs.meta rename to Assets/Scripts/InteractableObjects/Chest.cs.meta index 3f06ecb..901cee4 100644 --- a/Assets/Scripts/Chest.cs.meta +++ b/Assets/Scripts/InteractableObjects/Chest.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 542700d30d7f9c98a910fb33e30c4174 +guid: 3a68095ee650a0b5eaefd210c9641289 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/InteractableObjects/Door.cs similarity index 87% rename from Assets/Scripts/Door.cs rename to Assets/Scripts/InteractableObjects/Door.cs index b60d0b7..92965b4 100644 --- a/Assets/Scripts/Door.cs +++ b/Assets/Scripts/InteractableObjects/Door.cs @@ -4,26 +4,14 @@ using UnityEngine; using System; using Newtonsoft.Json.Linq; -namespace Assets.Scripts +namespace Assets.Scripts.InteractableObjects { - public class Door : MonoBehaviour + public class Door : InteractableObject { public bool hasInteracted = false; bool isOpen = false; - - // Start is called before the first frame update - void Start() - { - - } - // Update is called once per frame - void Update() - { - - } - - public void interact() + public override void handleInteraction(GameObject player) { if (hasInteracted) { diff --git a/Assets/Scripts/Door.cs.meta b/Assets/Scripts/InteractableObjects/Door.cs.meta similarity index 83% rename from Assets/Scripts/Door.cs.meta rename to Assets/Scripts/InteractableObjects/Door.cs.meta index b153382..6d09f62 100644 --- a/Assets/Scripts/Door.cs.meta +++ b/Assets/Scripts/InteractableObjects/Door.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 14e8c3bbd04c0574da570d1bc8d00649 +guid: 5ae65e9f2852fc2fbb96d7c9ec9cafe0 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Enemy.cs b/Assets/Scripts/InteractableObjects/Enemy.cs similarity index 93% rename from Assets/Scripts/Enemy.cs rename to Assets/Scripts/InteractableObjects/Enemy.cs index e8cb7b3..cc7ca8b 100644 --- a/Assets/Scripts/Enemy.cs +++ b/Assets/Scripts/InteractableObjects/Enemy.cs @@ -6,17 +6,15 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Assets.Scripts +namespace Assets.Scripts.InteractableObjects { - public class Enemy : MonoBehaviour + public class Enemy : InteractableObject { string enemyname; System.Random rand = new System.Random(); BasicSlime slime; SlimeFactory factory = new SlimeFactory(); - - // Start is called before the first frame update void Start() { enemyname = gameObject.name; @@ -28,10 +26,9 @@ namespace Assets.Scripts renameEnemy(); } - // Update is called once per frame - void Update() + public override void handleInteraction(GameObject player) { - + keepAlive = true; } private void renameEnemy() @@ -115,7 +112,7 @@ namespace Assets.Scripts public bool takeDamage(int amount) { - return slime.takeDamage(amount,rand); + return slime.takeDamage(amount, rand); } public int getExperience() diff --git a/Assets/Scripts/Enemy.cs.meta b/Assets/Scripts/InteractableObjects/Enemy.cs.meta similarity index 83% rename from Assets/Scripts/Enemy.cs.meta rename to Assets/Scripts/InteractableObjects/Enemy.cs.meta index 6e8a4e6..f21dfa1 100644 --- a/Assets/Scripts/Enemy.cs.meta +++ b/Assets/Scripts/InteractableObjects/Enemy.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cc3c1c0815bce34498b5dc8b199d0118 +guid: 2fe18bcd2d3d0d752ae519027875df8f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/InteractableObjects/InteractableObject.cs b/Assets/Scripts/InteractableObjects/InteractableObject.cs new file mode 100644 index 0000000..c536b73 --- /dev/null +++ b/Assets/Scripts/InteractableObjects/InteractableObject.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Assets.Scripts.InteractableObjects +{ + public abstract class InteractableObject : MonoBehaviour + { + public AnimationClip clip; + private bool particlePlayed; + private bool animationPlayed; + public bool keepAlive; + // Start is called before the first frame update + void Start() + { + particlePlayed = false; + animationPlayed = false; + keepAlive = false; + } + + // Update is called once per frame + void Update() + { + destroyObject(); + } + + public void OnInteraction(GameObject player) + { + StartCoroutine(playParticle(player)); + StartCoroutine(playAnimation(player)); + handleInteraction(player); + } + + public abstract void handleInteraction(GameObject player); + + IEnumerator playParticle(GameObject player) + { + if (GetComponent() != null) + { + Vector3 playerPos = player.transform.position; + playerPos.y = transform.position.y; + Quaternion newRotation = Quaternion.LookRotation(playerPos - transform.position, transform.TransformDirection(Vector3.up)); + ParticleSystem particleSystem = GetComponent(); + ParticleSystem.ShapeModule shape = particleSystem.shape; + shape.rotation = newRotation.eulerAngles; + particleSystem.Play(); + yield return new WaitUntil(() => !particleSystem.isPlaying); + } + particlePlayed = true; + } + + IEnumerator playAnimation(GameObject player) + { + if (clip != null) + { + player.GetComponent().Play(clip.name); + yield return new WaitForSeconds(clip.length); + } + animationPlayed = true; + } + + public void destroyObject() + { + if (particlePlayed && animationPlayed && !keepAlive) + { + Destroy(gameObject); + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/InteractableObjects/InteractableObject.cs.meta b/Assets/Scripts/InteractableObjects/InteractableObject.cs.meta new file mode 100644 index 0000000..bb59af0 --- /dev/null +++ b/Assets/Scripts/InteractableObjects/InteractableObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4e98ea4e0e891353aa6bdff9dfb8ead8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NPC.cs b/Assets/Scripts/InteractableObjects/NPC.cs similarity index 81% rename from Assets/Scripts/NPC.cs rename to Assets/Scripts/InteractableObjects/NPC.cs index 5f161b1..4708193 100644 --- a/Assets/Scripts/NPC.cs +++ b/Assets/Scripts/InteractableObjects/NPC.cs @@ -2,25 +2,15 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Assets.Scripts +namespace Assets.Scripts.InteractableObjects { - public class NPC : MonoBehaviour + public class NPC : InteractableObject { bool hasQuest = true; - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } - - public void interact() + + public override void handleInteraction(GameObject player) { + keepAlive = true; if (hasQuest) { GameObject.Find("UIHandler").GetComponent().showMessage("SUCCESS;"+TextHandler.getText("gotQuest")); diff --git a/Assets/Scripts/NPC.cs.meta b/Assets/Scripts/InteractableObjects/NPC.cs.meta similarity index 83% rename from Assets/Scripts/NPC.cs.meta rename to Assets/Scripts/InteractableObjects/NPC.cs.meta index 82b37c2..1445643 100644 --- a/Assets/Scripts/NPC.cs.meta +++ b/Assets/Scripts/InteractableObjects/NPC.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 87ac36bb4d63c7b4f901ce681578ca4b +guid: 502dfdd16cfb094a89708a6d31f80af2 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/InteractableObjects/Ore.cs b/Assets/Scripts/InteractableObjects/Ore.cs new file mode 100644 index 0000000..2692203 --- /dev/null +++ b/Assets/Scripts/InteractableObjects/Ore.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Assets.Scripts.InteractableObjects +{ + public class Ore : InteractableObject + { + public override void handleInteraction(GameObject player) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/InteractableObjects/Ore.cs.meta b/Assets/Scripts/InteractableObjects/Ore.cs.meta new file mode 100644 index 0000000..d2beb1b --- /dev/null +++ b/Assets/Scripts/InteractableObjects/Ore.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ab6955d1e578ef1b88f1ee3b6fa83051 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/InteractableObjects/Stone.cs b/Assets/Scripts/InteractableObjects/Stone.cs new file mode 100644 index 0000000..bd9e126 --- /dev/null +++ b/Assets/Scripts/InteractableObjects/Stone.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Assets.Scripts.InteractableObjects +{ + public class Stone : InteractableObject + { + public override void handleInteraction(GameObject player) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/InteractableObjects/Stone.cs.meta b/Assets/Scripts/InteractableObjects/Stone.cs.meta new file mode 100644 index 0000000..af883a4 --- /dev/null +++ b/Assets/Scripts/InteractableObjects/Stone.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4fc88a9ab15a9238baf100c2fd070aa7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/InteractableObjects/Tree.cs b/Assets/Scripts/InteractableObjects/Tree.cs new file mode 100644 index 0000000..8994c32 --- /dev/null +++ b/Assets/Scripts/InteractableObjects/Tree.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Assets.Scripts.InteractableObjects +{ + public class Tree : InteractableObject + { + public override void handleInteraction(GameObject player) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/InteractableObjects/Tree.cs.meta b/Assets/Scripts/InteractableObjects/Tree.cs.meta new file mode 100644 index 0000000..2d1cfc5 --- /dev/null +++ b/Assets/Scripts/InteractableObjects/Tree.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9d069bae9082b7b60a2a05060a98424e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player/PlayerCamera.cs b/Assets/Scripts/Player/PlayerCamera.cs index c343881..96518f6 100644 --- a/Assets/Scripts/Player/PlayerCamera.cs +++ b/Assets/Scripts/Player/PlayerCamera.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using Assets.Scripts.InteractableObjects; namespace Assets.Scripts.Player { diff --git a/Assets/Scripts/Player/PlayerGameObject.cs b/Assets/Scripts/Player/PlayerGameObject.cs index 2c5e9b8..a5afe34 100644 --- a/Assets/Scripts/Player/PlayerGameObject.cs +++ b/Assets/Scripts/Player/PlayerGameObject.cs @@ -9,6 +9,7 @@ using Assets.Scripts.Classes; using Assets.Scripts.Races; using Newtonsoft.Json.Linq; using UnityEngine.InputSystem; +using Assets.Scripts.InteractableObjects; namespace Assets.Scripts.Player { @@ -88,7 +89,7 @@ namespace Assets.Scripts.Player { now = DateTime.Now; player.regainSecondary(inventory.getEquipmentBonus()["MPR"], inventory.getEquipmentBonus()["MP"]); - player.healPlayer(/*4 - difficulty * 2*/-20, inventory.getEquipmentBonus()["HP"]); + player.healPlayer(4 - difficulty * 2, inventory.getEquipmentBonus()["HP"]); } } } diff --git a/Assets/Scripts/Quests/KillQuest.cs b/Assets/Scripts/Quests/KillQuest.cs index 0a6e6d7..45157f9 100644 --- a/Assets/Scripts/Quests/KillQuest.cs +++ b/Assets/Scripts/Quests/KillQuest.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json.Linq; using System.Collections; using System.Collections.Generic; using UnityEngine; +using Assets.Scripts.InteractableObjects; namespace Assets.Scripts { diff --git a/Assets/Scripts/Tile.cs b/Assets/Scripts/Tile.cs index a2ce355..cfd4e43 100644 --- a/Assets/Scripts/Tile.cs +++ b/Assets/Scripts/Tile.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; +using Assets.Scripts.InteractableObjects; public class Tile : MonoBehaviour {