diff --git a/.vscode/settings.json b/.vscode/settings.json index b24499237864e05d8f6480039ce84dc15b47ef3c..daa9bf8ff2c64d09b2a41257222553cd234a17dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -51,5 +51,5 @@ "temp/": true, "Temp/": true }, - "dotnet.defaultSolution": "if3210-2024-unity-ngk.sln" + "dotnet.defaultSolution": "GamePBD.sln" } \ No newline at end of file diff --git a/Assets/Audio/Effects/mario-power-up-epic-sound-fx.mp3 b/Assets/Audio/Effects/mario-power-up-epic-sound-fx.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..52eafc5cb58eb6b06778eabf271063a8646ed80c Binary files /dev/null and b/Assets/Audio/Effects/mario-power-up-epic-sound-fx.mp3 differ diff --git a/Assets/Audio/Effects/mario-power-up-epic-sound-fx.mp3.meta b/Assets/Audio/Effects/mario-power-up-epic-sound-fx.mp3.meta new file mode 100644 index 0000000000000000000000000000000000000000..f65e5ed6e4ef0964f9c8be0e7e8c25352b76c0e3 --- /dev/null +++ b/Assets/Audio/Effects/mario-power-up-epic-sound-fx.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 51b9dccfd554bf947867209b8233cd27 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/AudioManager.prefab b/Assets/Prefabs/AudioManager.prefab index 2ee76aae57f99be9b685cf2b3d4f1a4efa5ce316..6e70474ffa822bb4bc4b48ea671802028527b3bc 100644 --- a/Assets/Prefabs/AudioManager.prefab +++ b/Assets/Prefabs/AudioManager.prefab @@ -52,24 +52,40 @@ MonoBehaviour: Pitch: 1 Loop: 1 FadeDuration: 2 + Type: 0 + AudioSource: {fileID: 0} - Name: Night Clip: {fileID: 8300000, guid: cd824cba38f4bb847884440ffc6d9614, type: 3} Volume: 0.04 Pitch: 1 Loop: 1 FadeDuration: 1.1 + Type: 0 + AudioSource: {fileID: 0} - Name: Doom Clip: {fileID: 8300000, guid: b265e1e2dc139eb49be6288b8f9b145b, type: 3} Volume: 0.5 Pitch: 1 Loop: 1 FadeDuration: 1.1 + Type: 0 + AudioSource: {fileID: 0} - Name: Termini Clip: {fileID: 8300000, guid: aab5b1d4ba129e446907daf7129d67f0, type: 3} Volume: 0.5 Pitch: 1 Loop: 1 FadeDuration: 1.1 + Type: 0 + AudioSource: {fileID: 0} + - Name: PowerUp + Clip: {fileID: 8300000, guid: 51b9dccfd554bf947867209b8233cd27, type: 3} + Volume: 0.5 + Pitch: 1 + Loop: 0 + FadeDuration: 1.1 + Type: 1 + AudioSource: {fileID: 0} --- !u!82 &3748856617707953316 AudioSource: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/UIs/Text Pop Up.prefab b/Assets/Prefabs/UIs/Text Pop Up.prefab new file mode 100644 index 0000000000000000000000000000000000000000..7995c0b1a19ba276f40cfaa97ee956861a77086a --- /dev/null +++ b/Assets/Prefabs/UIs/Text Pop Up.prefab @@ -0,0 +1,136 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5872306537687327695 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7088162887710753096} + - component: {fileID: 6718563646789644985} + - component: {fileID: 6649177100147590294} + m_Layer: 5 + m_Name: Text Pop Up + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7088162887710753096 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5872306537687327695} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 340, y: 320} + m_SizeDelta: {x: 500, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6718563646789644985 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5872306537687327695} + m_CullTransparentMesh: 1 +--- !u!114 &6649177100147590294 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5872306537687327695} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: + Health! + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: b84a314e2fd609d468e86fefe98285cb, type: 2} + m_sharedMaterial: {fileID: -4785108331157109069, guid: b84a314e2fd609d468e86fefe98285cb, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4288868779 + m_fontColor: {r: 0.6694455, g: 0.9433962, b: 0.6363475, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 36 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} diff --git a/Assets/Prefabs/UIs/Text Pop Up.prefab.meta b/Assets/Prefabs/UIs/Text Pop Up.prefab.meta new file mode 100644 index 0000000000000000000000000000000000000000..0ce5657a21c28cb1e40c8387a7c3f1fe5315533e --- /dev/null +++ b/Assets/Prefabs/UIs/Text Pop Up.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: eb993e4c91cffaf4c836e0b7419fa9a8 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Main 1.unity b/Assets/Scenes/Main 1.unity index 402d27a6e15c1c243009e431c2d2aac2723dd19d..5c16cf1d74360a3fab7f98e4f96c85b190143f6b 100644 --- a/Assets/Scenes/Main 1.unity +++ b/Assets/Scenes/Main 1.unity @@ -5838,6 +5838,55 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 428812970} m_CullTransparentMesh: 1 +--- !u!1 &430794421 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 430794422} + - component: {fileID: 430794423} + m_Layer: 5 + m_Name: TextPopUpManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &430794422 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 430794421} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 878613039} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &430794423 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 430794421} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 549d1446a0f7c4844b514c0e63b112c2, type: 3} + m_Name: + m_EditorClassIdentifier: + textPopUpPrefab: {fileID: 7088162887710753096, guid: eb993e4c91cffaf4c836e0b7419fa9a8, type: 3} --- !u!1 &436685819 GameObject: m_ObjectHideFlags: 0 @@ -11286,6 +11335,7 @@ RectTransform: m_LocalScale: {x: 0, y: 0, z: 0} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 430794422} - {fileID: 1612420044} - {fileID: 1560957795} - {fileID: 154434726} @@ -25075,6 +25125,17 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 861f98f7583822c4abf4e734c516b17b, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &1734600111 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 35636913108109566, guid: 4e5a0d387dc27394b81600988ad0216f, type: 3} + m_PrefabInstance: {fileID: 1734600097} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1734600098} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2f63ff02fc610a44b8a3af5fb2403b87, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1738628409 GameObject: m_ObjectHideFlags: 0 @@ -28327,6 +28388,18 @@ PrefabInstance: propertyPath: petSpawner value: objectReference: {fileID: 1668337493} + - target: {fileID: 4498850462545079711, guid: 52eff72d3b1cec44ebdcabc26791c5b6, type: 3} + propertyPath: ui.bagasText + value: + objectReference: {fileID: 35880654} + - target: {fileID: 4498850462545079711, guid: 52eff72d3b1cec44ebdcabc26791c5b6, type: 3} + propertyPath: playerBalance + value: + objectReference: {fileID: 1734600111} + - target: {fileID: 4498850462545079711, guid: 52eff72d3b1cec44ebdcabc26791c5b6, type: 3} + propertyPath: ui.javierText + value: + objectReference: {fileID: 1689318111} - target: {fileID: 5611320276677058579, guid: 52eff72d3b1cec44ebdcabc26791c5b6, type: 3} propertyPath: m_Name value: Table_with_weapon @@ -30044,6 +30117,7 @@ SceneRoots: m_ObjectHideFlags: 0 m_Roots: - {fileID: 1692862994} + - {fileID: 878613039} - {fileID: 1120270614} - {fileID: 1734600097} - {fileID: 2036252846} @@ -30054,5 +30128,4 @@ SceneRoots: - {fileID: 4401420999633289391} - {fileID: 1026069216} - {fileID: 797983394} - - {fileID: 878613039} - {fileID: 1668337494} diff --git a/Assets/Scripts/Audio/AudioManager.cs b/Assets/Scripts/Audio/AudioManager.cs index 6469eab7742b559be5d0bb6e7f69e4014702b76b..8c487aeec286907499815aef05913072af5b630b 100644 --- a/Assets/Scripts/Audio/AudioManager.cs +++ b/Assets/Scripts/Audio/AudioManager.cs @@ -2,6 +2,12 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +public enum AudioType +{ + BGM, + SFX +} + [System.Serializable] public class Sound { @@ -11,6 +17,8 @@ public class Sound [Range(0.1f, 3f)] public float Pitch = 1f; public bool Loop = true; public float FadeDuration = 4f; + public AudioType Type = AudioType.BGM; + [HideInInspector] public AudioSource AudioSource; } public class AudioManager : MonoBehaviour @@ -41,6 +49,22 @@ public class AudioManager : MonoBehaviour DontDestroyOnLoad(gameObject); audioSource = GetComponent<AudioSource>(); + + foreach (Sound sound in sounds) + { + sound.Clip.LoadAudioData(); + if (sound.Type == AudioType.SFX) + { + sound.AudioSource = gameObject.AddComponent<AudioSource>(); + sound.AudioSource.clip = sound.Clip; + sound.AudioSource.volume = sound.Volume; + sound.AudioSource.pitch = sound.Pitch; + sound.AudioSource.loop = sound.Loop; + } else + { + sound.AudioSource = audioSource; + } + } } public void PlayBGMOverwrite(string soundName) @@ -87,6 +111,18 @@ public class AudioManager : MonoBehaviour } } + public void PlaySFX(string soundName) + { + Sound sound = System.Array.Find(sounds, s => s.Name == soundName); + if (sound == null) + { + Debug.LogWarning("Sound: " + soundName + " not found!"); + return; + } + + sound.AudioSource.Play(); + } + private IEnumerator Crossfade(Sound sound) { Sound active = System.Array.Find(sounds, s => s.Name == activeBGM); diff --git a/Assets/Scripts/Cutscene/TimelineManager.cs b/Assets/Scripts/Cutscene/TimelineManager.cs index c55123d990763b3ef8bb285089ca35f862fb6a92..a5810658457e35512774a2b2d59f303b75cb9af9 100644 --- a/Assets/Scripts/Cutscene/TimelineManager.cs +++ b/Assets/Scripts/Cutscene/TimelineManager.cs @@ -62,7 +62,6 @@ public class TimelineManager : MonoBehaviour } public void NextTimeline() { - Debug.Log("Time: " + playableDirector.time); currentMarkIndex++; playableDirector.Resume(); isPlaying = true; diff --git a/Assets/Scripts/Orbs/Increase Damage/IncreaseDamage.cs b/Assets/Scripts/Orbs/Increase Damage/IncreaseDamage.cs index d402b7eb5f901d78c37118b3f827b8ab41d69f12..7d46b6ef0abbde9ff7e4ddfdbb5005812606150a 100644 --- a/Assets/Scripts/Orbs/Increase Damage/IncreaseDamage.cs +++ b/Assets/Scripts/Orbs/Increase Damage/IncreaseDamage.cs @@ -6,6 +6,7 @@ public class IncreaseDamage : Orb protected override void OnTriggerEnter(Collider other) { + base.OnTriggerEnter(other); if (other.gameObject.CompareTag("Player")) { // Attempt to get the PlayerEffectable component from the player object @@ -23,4 +24,9 @@ public class IncreaseDamage : Orb Destroy(gameObject); // Destroy the orb after applying the effect } } + + protected override string GetTextPopUpMessage() + { + return "+ Damage!"; + } } diff --git a/Assets/Scripts/Orbs/Increase Speed/IncreaseSpeed.cs b/Assets/Scripts/Orbs/Increase Speed/IncreaseSpeed.cs index c6d1f5ff4e145c58dcc66b899da25f62674b2810..4aa3ff29c1e2dc38a0b52356cbc948973a47e820 100644 --- a/Assets/Scripts/Orbs/Increase Speed/IncreaseSpeed.cs +++ b/Assets/Scripts/Orbs/Increase Speed/IncreaseSpeed.cs @@ -6,6 +6,7 @@ public class IncreaseSpeed : Orb protected override void OnTriggerEnter(Collider other) { + base.OnTriggerEnter(other); if (other.gameObject.CompareTag("Player")) { Debug.Log("Speed: "); @@ -14,4 +15,9 @@ public class IncreaseSpeed : Orb Destroy(gameObject); } } + + protected override string GetTextPopUpMessage() + { + return "+ Speed!"; + } } \ No newline at end of file diff --git a/Assets/Scripts/Orbs/Orb.cs b/Assets/Scripts/Orbs/Orb.cs index d0919a8535bc50325ada03b082dc47361daffe6a..f2382dc5a33399e8a1aa602d3d83757fc1d9aa65 100644 --- a/Assets/Scripts/Orbs/Orb.cs +++ b/Assets/Scripts/Orbs/Orb.cs @@ -17,9 +17,9 @@ public abstract class Orb : MonoBehaviour protected virtual void OnTriggerEnter(Collider other) { - if (other.gameObject.CompareTag("Player")) - { - Destroy(gameObject); - } + AudioManager.Instance.PlaySFX("PowerUp"); + TextPopUpManager.Instance.CreateTextPopUp(GetTextPopUpMessage(), 2f); } + + protected abstract string GetTextPopUpMessage(); } \ No newline at end of file diff --git a/Assets/Scripts/Orbs/Restore Health/RestoreHealth.cs b/Assets/Scripts/Orbs/Restore Health/RestoreHealth.cs index f5868a13b1e73d75a0d8176f9e5c920ab63bb89e..1684dce25236128c0234d3c12c3b32f2e533d7f8 100644 --- a/Assets/Scripts/Orbs/Restore Health/RestoreHealth.cs +++ b/Assets/Scripts/Orbs/Restore Health/RestoreHealth.cs @@ -8,6 +8,7 @@ public class RestoreHealth : Orb protected override void OnTriggerEnter(Collider other) { + base.OnTriggerEnter(other); if (other.gameObject.CompareTag("Player")) { Debug.Log("healthh"); @@ -25,4 +26,9 @@ public class RestoreHealth : Orb target.RemoveEffect(healEffect); } } + + protected override string GetTextPopUpMessage() + { + return "+ Health!"; + } } \ No newline at end of file diff --git a/Assets/Scripts/Quest/QuestManager.cs b/Assets/Scripts/Quest/QuestManager.cs index e1602bd1d3da635dd5c475573145560e6b2f06a4..687a908d69f3cbae4dea971f6bb86b495da1cd98 100644 --- a/Assets/Scripts/Quest/QuestManager.cs +++ b/Assets/Scripts/Quest/QuestManager.cs @@ -24,7 +24,6 @@ public class QuestManager : MonoBehaviour public SphereRadius ParentHouse; public SphereRadius Forest; public OrbsSpawner orbsSpawner; - public PlayerBalance Player; public static QuestManager Instance { get; private set; } public List<Quest> quests; @@ -93,10 +92,15 @@ public class QuestManager : MonoBehaviour } }, onQuestStarted: () => { TimelineManager.Instance.NextTimeline(); - OrbsSpawner.Instance.spawnFlag = true; + //OrbsSpawner.Instance.spawnFlag = true; }, onQuestCompleted: () => { + foreach (var item in GameObject.FindGameObjectsWithTag("Enemy")) + { + Destroy(item); + } + TimelineManager.Instance.NextTimeline(); AudioManager.Instance.PlayBGMCrossfade("Night"); - OrbsSpawner.Instance.spawnFlag = false; + //OrbsSpawner.Instance.spawnFlag = false; })); // QUEST 3 @@ -109,7 +113,7 @@ public class QuestManager : MonoBehaviour { new SpawnerData { - SpawnArea = new SpawnArea { Origin = spawnTransform, Radius = 50}, + SpawnArea = new SpawnArea { Origin = spawnTransform, Radius = 36}, Mob = General, MobCount = 5, SpawnInterval = 2f @@ -117,11 +121,11 @@ public class QuestManager : MonoBehaviour } }, onQuestStarted: () => { AudioManager.Instance.PlayBGMCrossfade("Doom"); - OrbsSpawner.Instance.spawnFlag = true; + //OrbsSpawner.Instance.spawnFlag = true; StartSpawning(); }, onQuestCompleted: () => { AudioManager.Instance.PlayBGMCrossfade("Night"); - OrbsSpawner.Instance.spawnFlag = false; + //OrbsSpawner.Instance.spawnFlag = false; })); // QUEST 4 @@ -129,11 +133,21 @@ public class QuestManager : MonoBehaviour new GoalKill("Kill The Genderuwo", 1, EnemyType.Boss) }, 200, new WaveData { + Spawners = new List<SpawnerData> + { + new SpawnerData + { + SpawnArea = new SpawnArea { Origin = spawnTransform, Radius = 36}, + Mob = General, + MobCount = 12, + SpawnInterval = 11f + }, + } }, onQuestStarted: () => { TimelineManager.Instance.NextTimeline(); }, onQuestCompleted: () => { AudioManager.Instance.PlayBGMCrossfade("Night"); - OrbsSpawner.Instance.spawnFlag = false; + //OrbsSpawner.Instance.spawnFlag = false; })); } @@ -141,7 +155,6 @@ public class QuestManager : MonoBehaviour public void StartQuest(int index) { GameObject.Find("Gameplay UI/GameOver UI/GameOverPanel").SetActive(false); - Debug.Log("Starting quest " + index); if (index < quests.Count) { Quest currentQuest = quests[index]; @@ -159,6 +172,7 @@ public class QuestManager : MonoBehaviour { waveSpawner.spawnFlag = true; waveSpawner.SpawnWave(quests[currentQuestIndex].waveData); + OrbsSpawner.Instance.spawnFlag = true; } @@ -188,10 +202,9 @@ public class QuestManager : MonoBehaviour QuestUI.Instance.ResetQuestUI(); waveSpawner.spawnFlag = false; waveSpawner.DestroyAllMobs(); - Player.AddBalance(currentQuest.reward); + OrbsSpawner.Instance.spawnFlag = false; + currentQuest.onQuestCompleted?.Invoke(); } - - currentQuest.onQuestCompleted?.Invoke(); } void Update() diff --git a/Assets/Scripts/UI/TextPopUpManager.cs b/Assets/Scripts/UI/TextPopUpManager.cs new file mode 100644 index 0000000000000000000000000000000000000000..e7ed40936b9985174ae14f4825272e7ba8242650 --- /dev/null +++ b/Assets/Scripts/UI/TextPopUpManager.cs @@ -0,0 +1,89 @@ +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEditor; +using UnityEngine; + +public class TextPopUpManager : MonoBehaviour +{ + public static TextPopUpManager Instance { get; private set; } + public RectTransform textPopUpPrefab; + + private void Awake() + { + if (Instance == null) + { + Instance = this; + } + else + { + Destroy(gameObject); + } + } + + public void CreateTextPopUp(string text, float duration = 1f) + { + StartCoroutine(CreateTextPopUpCoroutine(text, duration)); + } + + public IEnumerator CreateTextPopUpCoroutine(string text, float duration) + { + + GameObject textPopUp = Instantiate(textPopUpPrefab.gameObject, Vector3.zero, Quaternion.identity, transform); + TextMeshProUGUI textMesh = textPopUp.GetComponent<TextMeshProUGUI>(); + textMesh.text = text; + + Vector3 halfPosition = textPopUpPrefab.transform.position; + + Vector3 initialPosition = textPopUpPrefab.transform.position; + initialPosition.y -= 100; + + textPopUp.transform.position = initialPosition; + + Vector3 targetPosition = textPopUpPrefab.transform.position; + targetPosition.y += 100; + + float timer = 0; + float halfDuration = duration / 2; + float alpha; + + // First, fade in + while (timer < halfDuration) + { + timer += Time.deltaTime; + alpha = Mathf.Lerp(0, 1, timer / halfDuration); + textPopUp.transform.position = Vector3.Lerp(initialPosition, halfPosition, timer / halfDuration); + textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, alpha); + yield return null; + } + + // Then, fade out + timer = 0; + while (timer < halfDuration) + { + timer += Time.deltaTime; + alpha = Mathf.Lerp(1, 0, timer / halfDuration); + textPopUp.transform.position = Vector3.Lerp(halfPosition, targetPosition, timer / halfDuration); + textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, alpha); + yield return null; + } + + Destroy(textPopUp); + } +} + +#if UNITY_EDITOR +[CustomEditor(typeof(TextPopUpManager))] +public class TextPopUpManagerEditor : Editor +{ + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + TextPopUpManager textPopUpManager = (TextPopUpManager)target; + if (GUILayout.Button("Create Text Pop Up")) + { + textPopUpManager.CreateTextPopUp("Hello World"); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/Scripts/UI/TextPopUpManager.cs.meta b/Assets/Scripts/UI/TextPopUpManager.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..d521a1ee19fdf741dce628368b88288847f1bf9e --- /dev/null +++ b/Assets/Scripts/UI/TextPopUpManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 549d1446a0f7c4844b514c0e63b112c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: