From 60d6d0bad3bac542eedc6b105bea0317d71ef11c Mon Sep 17 00:00:00 2001 From: Maximillian Lukman <13519153@std.stei.itb.ac.id> Date: Sun, 10 Apr 2022 15:20:25 +0700 Subject: [PATCH] fix: winning condition --- Assets/Animation/PlayerAC.controller | 2 +- Assets/Prefabs/Bomber.prefab | 2 +- Assets/Prefabs/Devil.prefab | 4 +- Assets/Prefabs/Shooter.prefab | 2 +- Assets/Scenes/Wave.unity | 15 +++++++ Assets/Scripts/Managers/WeaponManagerZen.cs | 2 +- Assets/Scripts/Managers/WinningManager.cs | 40 +++++++++++++++++++ .../Scripts/Managers/WinningManager.cs.meta | 11 +++++ Assets/Scripts/Spawner/EnemySpawnerWave.cs | 16 +++++--- 9 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 Assets/Scripts/Managers/WinningManager.cs create mode 100644 Assets/Scripts/Managers/WinningManager.cs.meta diff --git a/Assets/Animation/PlayerAC.controller b/Assets/Animation/PlayerAC.controller index fd1675e..66b182b 100644 --- a/Assets/Animation/PlayerAC.controller +++ b/Assets/Animation/PlayerAC.controller @@ -215,6 +215,6 @@ AnimatorStateMachine: m_StateMachineBehaviours: [] m_AnyStatePosition: {x: 276, y: 96, z: 0} m_EntryPosition: {x: 50, y: 120, z: 0} - m_ExitPosition: {x: 800, y: 120, z: 0} + m_ExitPosition: {x: 510, y: 120, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_DefaultState: {fileID: 1102589369875474630} diff --git a/Assets/Prefabs/Bomber.prefab b/Assets/Prefabs/Bomber.prefab index 816355e..d3b0bda 100644 --- a/Assets/Prefabs/Bomber.prefab +++ b/Assets/Prefabs/Bomber.prefab @@ -330,7 +330,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: timeBetweenAttacks: 0.5 - attackDamage: 80 + attackDamage: 30 --- !u!114 &3079155484348339423 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Devil.prefab b/Assets/Prefabs/Devil.prefab index 51855bd..570ac6a 100644 --- a/Assets/Prefabs/Devil.prefab +++ b/Assets/Prefabs/Devil.prefab @@ -416,7 +416,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: timeBetweenAttacks: 0.5 - attackDamage: 10 + attackDamage: 60 --- !u!114 &2950657676947281860 MonoBehaviour: m_ObjectHideFlags: 0 @@ -429,7 +429,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a9b9d14572410594cb85d40eedfb150c, type: 3} m_Name: m_EditorClassIdentifier: - startingHealth: 100 + startingHealth: 200 currentHealth: 0 sinkSpeed: 2.5 scoreValue: 10 diff --git a/Assets/Prefabs/Shooter.prefab b/Assets/Prefabs/Shooter.prefab index 10b2497..eaee769 100644 --- a/Assets/Prefabs/Shooter.prefab +++ b/Assets/Prefabs/Shooter.prefab @@ -5578,7 +5578,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: timeBetweenAttacks: 0.5 - attackDamage: 5 + attackDamage: 15 range: 100 --- !u!1 &6289126872513703861 GameObject: diff --git a/Assets/Scenes/Wave.unity b/Assets/Scenes/Wave.unity index f662fd0..852e9e7 100644 --- a/Assets/Scenes/Wave.unity +++ b/Assets/Scenes/Wave.unity @@ -590,6 +590,7 @@ GameObject: - component: {fileID: 38786125} - component: {fileID: 38786129} - component: {fileID: 38786130} + - component: {fileID: 38786131} m_Layer: 5 m_Name: HUDCanvas m_TagString: Untagged @@ -725,6 +726,20 @@ MonoBehaviour: warningText: {fileID: 839222784} playerHealth: {fileID: 33458251} restartDelay: 5 +--- !u!114 &38786131 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 38786124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5aae897c7720a954ebb33405b668a61e, type: 3} + m_Name: + m_EditorClassIdentifier: + restartDelay: 5 + spawner: {fileID: 240257952} --- !u!1 &180263584 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Managers/WeaponManagerZen.cs b/Assets/Scripts/Managers/WeaponManagerZen.cs index 3ee0a47..b08736d 100644 --- a/Assets/Scripts/Managers/WeaponManagerZen.cs +++ b/Assets/Scripts/Managers/WeaponManagerZen.cs @@ -51,7 +51,7 @@ public class WeaponManagerZen : MonoBehaviour void CheckUpgrade() { - if ((int)(TimerController.elapsedTime / 60) == 1) + if (((int)TimerController.elapsedTime % 15) == 0 && (int)TimerController.elapsedTime != 0) { enabledUpgrade = true; } diff --git a/Assets/Scripts/Managers/WinningManager.cs b/Assets/Scripts/Managers/WinningManager.cs new file mode 100644 index 0000000..bccc8a4 --- /dev/null +++ b/Assets/Scripts/Managers/WinningManager.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.SceneManagement; + +public class WinningManager : MonoBehaviour +{ + public float restartDelay = 5f; + + Animator anim; + float restartTimer; + + public EnemySpawnerWave spawner; + + void Awake() + { + anim = GetComponent<Animator>(); + } + + + void Update() + { + if (spawner.waveCount > spawner.maxWave) + { + anim.SetTrigger("Winning"); + + restartTimer += Time.deltaTime; + + if (restartTimer >= restartDelay) + { + if (SceneManager.GetActiveScene().buildIndex == 2) + { + ScoreManagerLBWave.scoreManagerLBWave.AddScoreWave(new ScoreWave(PlayerPrefs.GetString("player_name"), WaveManager.wave, ScoreManager.score)); + } + SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - SceneManager.GetActiveScene().buildIndex); + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Managers/WinningManager.cs.meta b/Assets/Scripts/Managers/WinningManager.cs.meta new file mode 100644 index 0000000..34653f7 --- /dev/null +++ b/Assets/Scripts/Managers/WinningManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5aae897c7720a954ebb33405b668a61e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Spawner/EnemySpawnerWave.cs b/Assets/Scripts/Spawner/EnemySpawnerWave.cs index 52f0425..1807be7 100644 --- a/Assets/Scripts/Spawner/EnemySpawnerWave.cs +++ b/Assets/Scripts/Spawner/EnemySpawnerWave.cs @@ -19,7 +19,7 @@ public class EnemySpawnerWave : MonoBehaviour private int devilCount = 0; public int enemyAlive = 5; - Animator anim; + //Animator anim; [SerializeField] public MonoBehaviour factory; IFactory Factory { get { return factory as IFactory; } } @@ -35,11 +35,11 @@ public class EnemySpawnerWave : MonoBehaviour { NextWave(); } - else if( waveCount == maxWave) - { - anim.SetTrigger("Winning"); - SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - SceneManager.GetActiveScene().buildIndex); - } + //else if( waveCount == maxWave) + //{ + // anim.SetTrigger("Winning"); + // SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - SceneManager.GetActiveScene().buildIndex); + //} } void Spawn() @@ -58,6 +58,10 @@ public class EnemySpawnerWave : MonoBehaviour void NextWave() { waveCount++; + if (waveCount > maxWave) + { + return; + } zombunnyCount += 4; zombearCount += 2; -- GitLab