diff --git a/Assets/Scripts/Command/InputHandler.cs b/Assets/Scripts/Command/InputHandler.cs index 112bf3e4153c8d3835bc8e1dcb9acbdac70c14c7..e32c0fb2707247c626f03f2c6e5970c586c017c8 100644 --- a/Assets/Scripts/Command/InputHandler.cs +++ b/Assets/Scripts/Command/InputHandler.cs @@ -6,7 +6,7 @@ public class InputHandler : MonoBehaviour { public PlayerMovement playerMovement; public PlayerShooting playerShooting; - private bool isSaving = true; + private bool inactive = true; //Queue untuk menyimpan list command Queue<Command> commands = new Queue<Command>(); @@ -15,7 +15,7 @@ public class InputHandler : MonoBehaviour { //Menghandle input movement Command moveCommand = InputMovementHandling(); - if (moveCommand != null && !isSaving) + if (moveCommand != null && !inactive) { commands.Enqueue(moveCommand); @@ -27,7 +27,7 @@ public class InputHandler : MonoBehaviour { //Mengahndle shoot Command shootCommand = InputShootHandling(); - if (shootCommand != null && !isSaving) + if (shootCommand != null && !inactive) { shootCommand.Execute(); } @@ -87,8 +87,8 @@ public class InputHandler : MonoBehaviour } } - public void setIsSaving(bool isSaving) + public void setInactive(bool inactive) { - this.isSaving = isSaving; + this.inactive = inactive; } } diff --git a/Assets/Scripts/Enemy/EnemyHealth.cs b/Assets/Scripts/Enemy/EnemyHealth.cs index 6001c90471198ef051fb1db3a58104d680667488..8248bc108ee1c7406ee4e5ee343ad86e190e7b56 100644 --- a/Assets/Scripts/Enemy/EnemyHealth.cs +++ b/Assets/Scripts/Enemy/EnemyHealth.cs @@ -52,7 +52,6 @@ public class EnemyHealth : MonoBehaviour, Attackable //Set rigisbody ke kinematic GetComponent<Rigidbody>().isKinematic = true; isSinking = true; - ScoreManager.score += scoreValue; Destroy(gameObject, 2f); } @@ -122,6 +121,7 @@ public class EnemyHealth : MonoBehaviour, Attackable if (!bySystem) { questManager.monsterDeadNotification(monsterType, scoreValue); + ScoreManager.score += scoreValue; } } } \ No newline at end of file diff --git a/Assets/Scripts/Quest/QuestManager.cs b/Assets/Scripts/Quest/QuestManager.cs index 15c46b9ed62ceeef82ca213add481ff9fc1c5c0f..5416a5bdbe611c95e56973d7eee50198322f5fee 100644 --- a/Assets/Scripts/Quest/QuestManager.cs +++ b/Assets/Scripts/Quest/QuestManager.cs @@ -4,6 +4,7 @@ using System; using UnityEngine; using UnityEngine.UI; using TMPro; +using UnityEngine.SceneManagement; public class QuestManager : MonoBehaviour { @@ -47,15 +48,7 @@ public class QuestManager : MonoBehaviour anim = GetComponent<Animator>(); timeProgress.text = "00:00:00"; time = 0f; - - questItems.Add(new QuestItem( - "Kill a Zombunny", - new List<string> { "Kill a Zombunny"}, - QuestItem.QuestType.KILL, - new List<float> { 1f}, - new List<MonsterType> { MonsterType.ZOMBUNNY}, - 1000 - )); + questItems.Add(new QuestItem( "Kill 5 Zombunnies and 4 Zombears", new List<string> { "Kill 5 Zombunnies", "Kill 4 Zombears" }, @@ -73,15 +66,15 @@ public class QuestManager : MonoBehaviour 100 )); questItems.Add(new QuestItem( - "Earn 100 Scores", - new List<string> { "Earn 500 Score" }, - QuestItem.QuestType.SCORE, - new List<float> { 500f }, + "Earn 500 Scores", + new List<string> { "Earn 500 Score" }, + QuestItem.QuestType.SCORE, + new List<float> { 500f }, new List<MonsterType>(), 100 )); questItems.Add(new QuestItem( - "Kill the Dragon", + "Kill the Soul Eater", new List<string> { "Kill 1 Soul Eater" }, QuestItem.QuestType.KILL, new List<float> { 1f }, @@ -117,8 +110,8 @@ public class QuestManager : MonoBehaviour playerGold.increaseGoldAmount(questItems[activeQuestIdx].getGoldReward()); enemyManager.killAllEnemies(); isTransitioning = true; - inputHandler.setIsSaving(true); - StartCoroutine(SaveGameActivation()); + inputHandler.setInactive(true); + StartCoroutine(SaveGameActivation()); // pausing the game, resume by saving / cancelling StartCoroutine(ShopActivation()); activeQuestIdx++; StartCoroutine(nextQuest()); @@ -165,10 +158,18 @@ public class QuestManager : MonoBehaviour isQuestFinish = true; nameInput.SetActive(true); Time.timeScale = 0f; - Debug.Log("Quest Finish"); + + enemyManager.killAllEnemies(); + StartCoroutine(LoadVictoryScene()); } } + private IEnumerator LoadVictoryScene() + { + yield return new WaitForSeconds(3); + SceneManager.LoadScene("Victory"); + } + private IEnumerator nextQuest() { yield return new WaitForSeconds(3); diff --git a/Assets/Scripts/Story/ScriptPlayer.cs b/Assets/Scripts/Story/ScriptPlayer.cs index 22cd3d0e1648a00d44f128382f96a988b96de79c..acb297be96382a91f08f12d8ed6066bf76efbf20 100644 --- a/Assets/Scripts/Story/ScriptPlayer.cs +++ b/Assets/Scripts/Story/ScriptPlayer.cs @@ -26,6 +26,8 @@ public class ScriptPlayer : MonoBehaviour private bool isShowingAsh = false; + private bool isFinished = false; + [SerializeField] private SceneType sceneType; @@ -56,14 +58,14 @@ public class ScriptPlayer : MonoBehaviour void Update() { - if (Input.GetKeyDown(KeyCode.Space) && isTextCompleted && !getIsScriptsCompleted()) + if (Input.GetKeyDown(KeyCode.Space) && isTextCompleted && !getIsScriptsCompleted() && !isFinished) { sentenceIdx++; StartCoroutine(TypeText(scripts[sentenceIdx].text)); textName.text = scripts[sentenceIdx].characterName; checkAsh(); } - else if (Input.GetKeyDown(KeyCode.Space) && isTextCompleted && getIsScriptsCompleted()) + else if (Input.GetKeyDown(KeyCode.Space) && isTextCompleted && getIsScriptsCompleted() && !isFinished) { if (sceneType == SceneType.OPENING) { @@ -76,6 +78,7 @@ public class ScriptPlayer : MonoBehaviour else { canvasAnimator.SetTrigger("Finish"); + isFinished = true; // end game } }