From d73699a78dd6607e65d79ed23702e682e8759f33 Mon Sep 17 00:00:00 2001 From: Jesica <13519011@std.stei.itb.ac.id> Date: Fri, 8 Apr 2022 13:10:33 +0700 Subject: [PATCH] add max level for weapon upgrade --- Assets/Scenes/Wave_Mode.unity | 61 +++++++++---------- Assets/Scripts/Managers/GameOverManager.cs | 3 +- Assets/Scripts/Managers/WinManager.cs | 14 ----- Assets/Scripts/WeaponUpgrade/WeaponUpgrade.cs | 17 ++++-- .../WeaponUpgrade/WeaponUpgradeManager.cs | 9 +++ .../WeaponUpgradeManager.cs.meta | 11 ++++ .../Scripts/WeaponUpgrade/WeaponUpgradeUI.cs | 19 +++++- 7 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs create mode 100644 Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs.meta diff --git a/Assets/Scenes/Wave_Mode.unity b/Assets/Scenes/Wave_Mode.unity index 12e7f99..4035c82 100644 --- a/Assets/Scenes/Wave_Mode.unity +++ b/Assets/Scenes/Wave_Mode.unity @@ -8965,6 +8965,18 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 2089035395} + m_TargetAssemblyTypeName: UnityEngine.UI.Selectable, UnityEngine.UI + m_MethodName: set_interactable + m_Mode: 6 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!114 &2089035396 MonoBehaviour: m_ObjectHideFlags: 0 @@ -9035,67 +9047,50 @@ MonoBehaviour: bossPool: - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} + - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} waves: - - name: Wave 1 + - name: ya gitu enemyPool: - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} + - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} + - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} weight: 1 rate: 5 - - name: Wave 2 + - name: ya gitu enemyPool: - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} - weight: 1 - rate: 1.5 - - name: Wave 3 - enemyPool: - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} weight: 1 - rate: 10 - - name: Wave 4 + rate: 5 + - name: ya gitu enemyPool: - - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} - weight: 1 - rate: 2 - - name: Wave 5 - enemyPool: - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} weight: 1 - rate: 2 - - name: Wave 6 + rate: 5 + - name: ya gitu enemyPool: - - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} - weight: 1 - rate: 2 - - name: Wave 7 - enemyPool: - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} weight: 1 - rate: 2 - - name: Wave 8 + rate: 5 + - name: ya gitu enemyPool: + - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} weight: 1 - rate: 2 - - name: Wave 9 + rate: 5 + - name: ya gitu enemyPool: + - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} - {fileID: 1206665596, guid: f264ab47e25d0374ba89abced0b94b2a, type: 3} - - {fileID: 1914384318, guid: 3688f3f3f312c984fa78e00c09819e6c, type: 3} - {fileID: 2022850303, guid: 73871ddf5c8d02442be00d9671a9d510, type: 3} weight: 1 - rate: 2 + rate: 5 spawnPoints: - {fileID: 9083842937541373870, guid: 6bbf9ef8fcce5114482d813a9b680d17, type: 3} - {fileID: 304385461253102273, guid: c88f58001921a7a4a9a51563d60192e6, type: 3} diff --git a/Assets/Scripts/Managers/GameOverManager.cs b/Assets/Scripts/Managers/GameOverManager.cs index e06ffa5..3735a60 100644 --- a/Assets/Scripts/Managers/GameOverManager.cs +++ b/Assets/Scripts/Managers/GameOverManager.cs @@ -23,7 +23,6 @@ public class GameOverManager : MonoBehaviour anim = GetComponent<Animator>(); } - void Update() { gameOverText = transform.Find("GameOverText"); @@ -79,10 +78,12 @@ public class GameOverManager : MonoBehaviour public void RestartButton() { SceneManager.LoadScene(1); + WinManager.isWin = false; } public void MainMenuButton() { SceneManager.LoadScene(0); + WinManager.isWin = false; } } \ No newline at end of file diff --git a/Assets/Scripts/Managers/WinManager.cs b/Assets/Scripts/Managers/WinManager.cs index e42f648..25a23a1 100644 --- a/Assets/Scripts/Managers/WinManager.cs +++ b/Assets/Scripts/Managers/WinManager.cs @@ -5,18 +5,4 @@ using UnityEngine; public class WinManager : MonoBehaviour { public static bool isWin = false; - - // Text text; - - //void Awake() - //{ - // text = GetComponent<Text>(); - // score = 0; - //} - - - //void Update() - //{ - // text.text = "Score: " + score; - //} } diff --git a/Assets/Scripts/WeaponUpgrade/WeaponUpgrade.cs b/Assets/Scripts/WeaponUpgrade/WeaponUpgrade.cs index 3171e4c..7595355 100644 --- a/Assets/Scripts/WeaponUpgrade/WeaponUpgrade.cs +++ b/Assets/Scripts/WeaponUpgrade/WeaponUpgrade.cs @@ -9,7 +9,8 @@ public class WeaponUpgrade : MonoBehaviour private int levelDiagonalWeapon; // maks 9x upgrade private int levelFasterWeapon; - // TODO max level? + private const int maxLevelDiagonal = 1; + private const int maxLevelSpeed = 9; private void Awake() { @@ -35,6 +36,11 @@ public class WeaponUpgrade : MonoBehaviour Instantiate(gunBarrelEnd, gunBarrelEnd.position, right, player.transform); Instantiate(gunBarrelEnd, gunBarrelEnd.position, left, player.transform); + + if (levelDiagonalWeapon >= maxLevelDiagonal) + { + WeaponUpgradeManager.isMaxUpgradeDiagonal = true; + } } public void UpgradeFasterWeapon() @@ -42,14 +48,17 @@ public class WeaponUpgrade : MonoBehaviour levelFasterWeapon++; // TODO akses semua gunBarrelEnd + + if (levelDiagonalWeapon >= maxLevelDiagonal) + { + WeaponUpgradeManager.isMaxUpgradeDiagonal = true; + } } public void UpgradeRearWeapon() { var rotationY = player.transform.eulerAngles.y; - var backward = Quaternion.Euler(0, -1 * rotationY, 0); + var backward = Quaternion.Euler(0, rotationY + 180, 0); Instantiate(gunBarrelEnd, gunBarrelEnd.position, backward, player.transform); - - // TODO masih aneh } } diff --git a/Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs b/Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs new file mode 100644 index 0000000..b3387a4 --- /dev/null +++ b/Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs @@ -0,0 +1,9 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class WeaponUpgradeManager : MonoBehaviour +{ + public static bool isMaxUpgradeDiagonal = false; + public static bool isMaxUpgradeFaster = false; +} diff --git a/Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs.meta b/Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs.meta new file mode 100644 index 0000000..92834a9 --- /dev/null +++ b/Assets/Scripts/WeaponUpgrade/WeaponUpgradeManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: df1bf4d3e0030504bafb69a06e50d20c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/WeaponUpgrade/WeaponUpgradeUI.cs b/Assets/Scripts/WeaponUpgrade/WeaponUpgradeUI.cs index 8ef7f4e..922a13f 100644 --- a/Assets/Scripts/WeaponUpgrade/WeaponUpgradeUI.cs +++ b/Assets/Scripts/WeaponUpgrade/WeaponUpgradeUI.cs @@ -1,10 +1,12 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; public class WeaponUpgradeUI : MonoBehaviour { - private Transform weaponUpgradeTemplate; + private Button upgradeDiagonalButton; + private Button upgradeFasterButton; private Transform container; public static bool GameIsPaused = false; @@ -14,6 +16,11 @@ public class WeaponUpgradeUI : MonoBehaviour private void Awake() { container = transform.Find("WeaponUpgradeContainer"); + var canvas = container.Find("Canvas"); + var opt = canvas.Find("WeaponUpgradeOptions"); + + upgradeDiagonalButton = opt.Find("UpgradeDiagonalButton").GetComponent<Button>(); + upgradeFasterButton = opt.Find("UpgradeFasterButton").GetComponent<Button>(); } public void Pause() @@ -25,6 +32,16 @@ public class WeaponUpgradeUI : MonoBehaviour public void SkipOrContinue() { + if (WeaponUpgradeManager.isMaxUpgradeDiagonal) + { + upgradeDiagonalButton.interactable = false; + } + + if (WeaponUpgradeManager.isMaxUpgradeFaster) + { + upgradeFasterButton.interactable = false; + } + container.gameObject.SetActive(false); Time.timeScale = 1f; GameIsPaused = false; -- GitLab