diff --git a/Assets/Scenes/PetShopIntegrate.unity b/Assets/Scenes/PetShopIntegrate.unity index 456b216d77e56a59012055bfaf148ddd439d0c28..58b2c74835b060a87f0e7282690d359a9e03335f 100644 --- a/Assets/Scenes/PetShopIntegrate.unity +++ b/Assets/Scenes/PetShopIntegrate.unity @@ -2633,7 +2633,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 22 + m_RootOrder: 21 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &594892853 MonoBehaviour: @@ -8292,297 +8292,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 749821178} m_CullTransparentMesh: 1 ---- !u!1001 &756187584 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_RootOrder - value: 21 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalScale.x - value: 0.3 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalScale.y - value: 0.3 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalScale.z - value: 0.3 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalPosition.x - value: 6.39 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_Name - value: Dog - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - propertyPath: m_TagString - value: Pet - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} ---- !u!1 &756187585 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: e5aae2a65dffdcc46a3413ba4f12c67e, type: 3} - m_PrefabInstance: {fileID: 756187584} - m_PrefabAsset: {fileID: 0} ---- !u!82 &756187586 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 8300000, guid: 302a231041c8d354e80d82940e98466a, type: 3} - m_PlayOnAwake: 0 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 ---- !u!195 &756187587 -NavMeshAgent: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - m_Enabled: 1 - m_AgentTypeID: 0 - m_Radius: 3.5 - m_Speed: 8 - m_Acceleration: 8 - avoidancePriority: 50 - m_AngularSpeed: 120 - m_StoppingDistance: 6 - m_AutoTraverseOffMeshLink: 1 - m_AutoBraking: 1 - m_AutoRepath: 1 - m_Height: 5 - m_BaseOffset: 0 - m_WalkableMask: 4294967295 - m_ObstacleAvoidanceType: 4 ---- !u!95 &756187588 -Animator: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: 8762638e69d430b41801692035bb3508, type: 2} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_StabilizeFeet: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorControllerStateOnDisable: 0 ---- !u!136 &756187589 -CapsuleCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - m_Radius: 4 - m_Height: 3 - m_Direction: 2 - m_Center: {x: 0, y: 2, z: 0} ---- !u!54 &756187590 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - serializedVersion: 2 - m_Mass: 1 - m_Drag: Infinity - m_AngularDrag: Infinity - m_UseGravity: 1 - m_IsKinematic: 0 - m_Interpolate: 0 - m_Constraints: 84 - m_CollisionDetection: 0 ---- !u!114 &756187591 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ab7a4c084b262f0448c8491897ca3116, type: 3} - m_Name: - m_EditorClassIdentifier: - petType: 0 - timeBetweenBirdAudio: 15 ---- !u!114 &756187596 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0bbb7111da660634eb210887ce649855, type: 3} - m_Name: - m_EditorClassIdentifier: - timeBetweenHeals: 10 - healAmount: 10 - healClip: {fileID: 0} ---- !u!114 &756187597 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 756187585} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 772bbe56305330545b0647344704f3ad, type: 3} - m_Name: - m_EditorClassIdentifier: - startingHealth: 100 - sinkSpeed: 2.5 - deathClip: {fileID: 8300000, guid: 86e7e5b266acb464fbc1bd81a4b04e68, type: 3} - petType: 0 --- !u!1 &802023443 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Enemy/EnemyHealth.cs b/Assets/Scripts/Enemy/EnemyHealth.cs index e927b6162a08c4a6afeac00351293d9dc14aca94..f9ba8eaa92c649c890242126a0e4f49721b38565 100644 --- a/Assets/Scripts/Enemy/EnemyHealth.cs +++ b/Assets/Scripts/Enemy/EnemyHealth.cs @@ -9,9 +9,6 @@ public class EnemyHealth : MonoBehaviour public AudioClip deathClip; public EnemyType enemyType; - - GameObject pet; - PetHealth petHealth; PetType petType; Animator anim; AudioSource enemyAudio; @@ -31,10 +28,6 @@ public class EnemyHealth : MonoBehaviour currentHealth = startingHealth; questTemple = FindObjectOfType<Temple>(); - pet = GameObject.FindGameObjectWithTag ("Pet"); - petHealth = pet.GetComponent <PetHealth> (); - petType = petHealth.GetPetType(); - print(petType); } @@ -98,7 +91,8 @@ public class EnemyHealth : MonoBehaviour GetComponent<UnityEngine.AI.NavMeshAgent>().enabled = false; GetComponent<Rigidbody>().isKinematic = true; isSinking = true; - GameControl.control.currency += 5; + if (!GameControl.control.motherLoadOn) + GameControl.control.currency += 5; ScoreManager.score += scoreValue; Destroy(gameObject, 2f); } diff --git a/Assets/Scripts/Enums.meta b/Assets/Scripts/Enums.meta new file mode 100644 index 0000000000000000000000000000000000000000..56b005840663e407837ca4cfbfd43876a173ec5a --- /dev/null +++ b/Assets/Scripts/Enums.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bfb967f42a794604f93ccedb11cce92e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Enums/CheatType.cs b/Assets/Scripts/Enums/CheatType.cs new file mode 100644 index 0000000000000000000000000000000000000000..c84e028c401f496ce1a2e10e6b9773c38ca308f2 --- /dev/null +++ b/Assets/Scripts/Enums/CheatType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +public enum CheatType +{ + NODAMAGE, + ONEHITKILL, + MOTHERLODE, + TWOTIMESPEED, + FULLHPPET, +} \ No newline at end of file diff --git a/Assets/Scripts/Enums/CheatType.cs.meta b/Assets/Scripts/Enums/CheatType.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..163e767875d09545e4ae28c7a3053415c5aa0a65 --- /dev/null +++ b/Assets/Scripts/Enums/CheatType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c1f0c710468347340a6d172e23863a79 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Managers/CheatManager.cs b/Assets/Scripts/Managers/CheatManager.cs index 8098cd266e7ee80e4afb497b6cf632efdd9aa716..e6c134e051b3fbc7875c76913984750aa370a82b 100644 --- a/Assets/Scripts/Managers/CheatManager.cs +++ b/Assets/Scripts/Managers/CheatManager.cs @@ -14,7 +14,9 @@ public class CheatManager : MonoBehaviour ItemShopUI weaponShopUI; private string input; private int prevCurrency; - private bool motherlodeOn = false; + + // Activated Cheats + bool[] cheats = new bool[5]; private void Awake() { @@ -48,60 +50,143 @@ public class CheatManager : MonoBehaviour { if (input == "NODAMAGE") { - playerHealth.SetCheatNoDamage(true); - Hud.OpenMessagePanel("Cheat No Damage Activated!"); + CheatNoDamage(); return; } if (input == "ONEHITKILL") { - GameControl.control.cheatOneHitKill = true; - Hud.OpenMessagePanel("Cheat One Hit Kill Activated!"); + CheatOneHitKill(); return; } if (input == "MOTHERLODE") { - Hud.OpenMessagePanel("Cheat Motherlode Activated!"); - this.prevCurrency = GameControl.control.currency; - this.motherlodeOn = true; - // TODO: Handle overflow currency - GameControl.control.currency = 9999999; - petShopUI.SetCheatCurrency(true); - weaponShopUI.SetCheatCurrency(true); + CheatMotherLode(); return; } if (input == "TWOTIMESPEED") { - Hud.OpenMessagePanel("Cheat 2x Speed Activated!"); - playerMovement.SetCheatTwoTimesSpeed(); + CheatTwoTimeSpeed(); return; } if (input == "FULLHPPET") { - Hud.OpenMessagePanel("Cheat Full HP Pet Activated!"); - GameControl.control.fullHPPet = true; + CheatFullHPPet(); return; } if (input == "KILLPET") { - Hud.OpenMessagePanel("Cheat Kill Pet Activated!"); - GameControl.control.killPet = true; + CheatKillPet(); return; } if (input == "RESET") { - playerHealth.SetCheatNoDamage(false); - playerMovement.ResetSpeed(); - GameControl.control.cheatOneHitKill = false; - if (motherlodeOn) - { - GameControl.control.currency = this.prevCurrency; - petShopUI.SetCheatCurrency(false); - weaponShopUI.SetCheatCurrency(false); - } - GameControl.control.fullHPPet = false; - Hud.OpenMessagePanel("Cheat Reseted!"); + CheatReset(); return; } Hud.OpenMessagePanel("Invalid Cheat!"); } + + private void CheatNoDamage() + { + playerHealth.SetCheatNoDamage(true); + Hud.OpenMessagePanel("Cheat No Damage Activated!"); + cheats[(int)CheatType.NODAMAGE] = true; + } + + private void CheatOneHitKill() + { + GameControl.control.cheatOneHitKill = true; + Hud.OpenMessagePanel("Cheat One Hit Kill Activated!"); + cheats[(int)CheatType.ONEHITKILL] = true; + } + + private void CheatMotherLode() + { + this.prevCurrency = GameControl.control.currency; + GameControl.control.currency = 999999; + petShopUI.SetCheatCurrency(true); + weaponShopUI.SetCheatCurrency(true); + cheats[(int)CheatType.MOTHERLODE] = true; + GameControl.control.motherLoadOn = true; + Hud.OpenMessagePanel("Cheat Mother Lode Activated!"); + } + + private void CheatTwoTimeSpeed() + { + playerMovement.SetCheatTwoTimesSpeed(); + Hud.OpenMessagePanel("Cheat Two Time Speed Activated!"); + cheats[(int)CheatType.TWOTIMESPEED] = true; + } + + private void CheatFullHPPet() + { + Hud.OpenMessagePanel("Cheat Full HP Pet Activated!"); + GameControl.control.fullHPPet = true; + cheats[(int)CheatType.FULLHPPET] = true; + } + + private void CheatKillPet() + { + Hud.OpenMessagePanel("Cheat Kill Pet Activated!"); + GameControl.control.killPet = true; + } + + private void CheatReset() + { + playerHealth.SetCheatNoDamage(false); + playerMovement.ResetSpeed(); + GameControl.control.cheatOneHitKill = false; + if (cheats[(int)CheatType.MOTHERLODE]) + { + GameControl.control.currency = this.prevCurrency; + petShopUI.SetCheatCurrency(false); + weaponShopUI.SetCheatCurrency(false); + GameControl.control.motherLoadOn = false; + } + GameControl.control.fullHPPet = false; + Hud.OpenMessagePanel("Cheat Reseted!"); + } + + public void loadCheat(bool[] gatheredCheats) + { + if (gatheredCheats[(int)CheatType.NODAMAGE]) + { + CheatNoDamage(); + } + if (gatheredCheats[(int)CheatType.ONEHITKILL]) + { + CheatOneHitKill(); + } + if (gatheredCheats[(int)CheatType.MOTHERLODE]) + { + CheatMotherLode(); + } + if (gatheredCheats[(int)CheatType.TWOTIMESPEED]) + { + CheatTwoTimeSpeed(); + } + if (gatheredCheats[(int)CheatType.FULLHPPET]) + { + CheatFullHPPet(); + } + } + + public bool[] SaveCheat() + { + return cheats; + } + + public void ResetCheat() + { + cheats = new bool[5]; + foreach (CheatType cheat in System.Enum.GetValues(typeof(CheatType))) + { + cheats[(int)cheat] = false; + } + } + + public int GetPrevCurrency() + { + return this.prevCurrency; + } } diff --git a/Assets/Scripts/Managers/GameControl.cs b/Assets/Scripts/Managers/GameControl.cs index b6a0764253c0e6dadd827b72629f38c63dc4f2d2..620745af08e70e883b2487de85121e00b01754dc 100644 --- a/Assets/Scripts/Managers/GameControl.cs +++ b/Assets/Scripts/Managers/GameControl.cs @@ -49,11 +49,14 @@ public class GameControl : MonoBehaviour public float petIdx = -1; public int currency = 0; + // BOSS ABILITY + public bool cantShoot = false; + // CHEATS public bool cheatOneHitKill = false; - public bool cantShoot = false; public bool fullHPPet = false; public bool killPet = false; + public bool motherLoadOn = false; // Currencies public void addCurrency(int amt) diff --git a/Assets/Scripts/Managers/GlobalManager.cs b/Assets/Scripts/Managers/GlobalManager.cs index 618b4e9745e0462d15dfad31697c3d3deb903293..f5ce1f195845dc0a9813849bc0b6ce0f41efeda6 100644 --- a/Assets/Scripts/Managers/GlobalManager.cs +++ b/Assets/Scripts/Managers/GlobalManager.cs @@ -98,6 +98,7 @@ public class GlobalManager : MonoBehaviour { globalStateManager = GlobalStateManager.Instance; SceneManager.sceneLoaded += OnSceneLoaded; + this.metaStateSave = new MetaStateSave("DEFAULT-NAME"); } private void OnSceneLoaded(Scene arg0, LoadSceneMode arg1) diff --git a/Assets/Scripts/Managers/PetManager.cs b/Assets/Scripts/Managers/PetManager.cs index 934c1b9a91909b09622908bf312e03ca68680e58..6004fe1350afbf342fb9c0afa0016943edbe7992 100644 --- a/Assets/Scripts/Managers/PetManager.cs +++ b/Assets/Scripts/Managers/PetManager.cs @@ -4,26 +4,33 @@ using UnityEngine; public class PetManager : MonoBehaviour { - public PlayerHealth playerHealth; + private PlayerHealth _playerHealth; + public PlayerHealth playerHealth + { + get + { + if (_playerHealth == null ) + { + _playerHealth = GameObject.Find("Player").GetComponent<PlayerHealth>(); + } + + return _playerHealth; + } + } public float spawnTime = 5f; [SerializeField] MonoBehaviour factory; IFactory Factory { get { return factory as IFactory; } } - void Start() - { - playerHealth = GameObject.Find("Player").GetComponent<PlayerHealth>(); - } - - public void Spawn(int tag) + public GameObject Spawn(int tag) { - if (playerHealth.currentHealth <= 0f) + if (playerHealth.currentHealth <= 0f || tag == -1) { - return; + return null; } int spawnPet = tag; - Factory.FactoryMethod(spawnPet); + return Factory.FactoryMethod(spawnPet); } } diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 2390c1928e8361d8baca49290534ec0df3073cc8..a4e9cea76ce7a96f2a45f827fe003aa6e266c1df 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -9,6 +9,8 @@ public class PlayerMovement : MonoBehaviour Rigidbody playerRigidBody; int floorMask; float camRayLength = 100f; + float prevSpeed; + private void Awake() { @@ -18,6 +20,7 @@ public class PlayerMovement : MonoBehaviour anim = GetComponent<Animator>(); playerRigidBody = GetComponent<Rigidbody>(); + prevSpeed = speed; } private void FixedUpdate() @@ -79,6 +82,8 @@ public class PlayerMovement : MonoBehaviour public void SetCheatTwoTimesSpeed() { + if (this.speed * 2 > prevSpeed * 2) + return; this.speed *= 2; } diff --git a/Assets/Scripts/Quest/Temple/QuestConfig.cs b/Assets/Scripts/Quest/Temple/QuestConfig.cs index 78a14aba35ff4be9e381ff1de4aab639c073d701..5b55573b12546384cfae5ca4975a29715f93f7ed 100644 --- a/Assets/Scripts/Quest/Temple/QuestConfig.cs +++ b/Assets/Scripts/Quest/Temple/QuestConfig.cs @@ -11,19 +11,19 @@ public class QuestConfig { return type switch { - QuestType.FirstQuest => new QuestNumberEnemy() + QuestType.FirstQuest => new QuestNumberEnemy(100) .Add(EnemyType.Zombunny, 1) .Add(EnemyType.ZomBear, 1) .Add(EnemyType.Hellephant, 1), - QuestType.SecondQuest => new QuestNumberEnemy() + QuestType.SecondQuest => new QuestNumberEnemy(200) .Add(EnemyType.Zombunny, 10) .Add(EnemyType.ZomBear, 5) .Add(EnemyType.Hellephant, 3), - QuestType.ThirdQuest => new QuestNumberEnemy() + QuestType.ThirdQuest => new QuestNumberEnemy(300) .Add(EnemyType.Zombunny, 10) .Add(EnemyType.ZomBear, 10) .Add(EnemyType.Hellephant, 5), - QuestType.FinalQuest => new QuestNumberEnemy() + QuestType.FinalQuest => new QuestNumberEnemy(400) .Add(EnemyType.Zombunny, 10) .Add(EnemyType.ZomBear, 10) .Add(EnemyType.Hellephant, 5) diff --git a/Assets/Scripts/Quest/Temple/QuestNumberEnemy.cs b/Assets/Scripts/Quest/Temple/QuestNumberEnemy.cs index 637d50f4ccd8a23317369b782258e5edc3f8d0a3..86e1274cbb3f8438511b6e803fa4ae4730085c4d 100644 --- a/Assets/Scripts/Quest/Temple/QuestNumberEnemy.cs +++ b/Assets/Scripts/Quest/Temple/QuestNumberEnemy.cs @@ -9,9 +9,11 @@ using UnityEngine; public class QuestNumberEnemy { private readonly Dictionary<EnemyType, int> numEnemies; + public int Reward { get; private set; } - public QuestNumberEnemy() + public QuestNumberEnemy(int reward) { + Reward = reward; numEnemies = new Dictionary<EnemyType, int>(); var types = Enum.GetValues(typeof(EnemyType)).Cast<EnemyType>(); foreach (var type in types) @@ -56,7 +58,7 @@ public class QuestNumberEnemy public QuestNumberEnemy Clone() { - QuestNumberEnemy clone = new QuestNumberEnemy(); + QuestNumberEnemy clone = new QuestNumberEnemy(this.Reward); foreach (var enemyType in numEnemies.Keys) { clone.numEnemies[enemyType] = numEnemies[enemyType]; diff --git a/Assets/Scripts/Quest/Temple/Temple.cs b/Assets/Scripts/Quest/Temple/Temple.cs index afbc03c89341b336100ccca093a02b4268ae58e7..e0e3bfa5dd7e3dad3858eebd30542eb6263e395f 100644 --- a/Assets/Scripts/Quest/Temple/Temple.cs +++ b/Assets/Scripts/Quest/Temple/Temple.cs @@ -41,6 +41,20 @@ public class Temple : MonoBehaviour public bool OnQuest { get => onQuest; } + private SaveDialogHandler _saveDialog; + public SaveDialogHandler saveDialog + { + get + { + if (_saveDialog == null) + { + _saveDialog = GameObject.Find("HUDCanvas").GetComponentInChildren<SaveDialogHandler>(); + } + + return _saveDialog; + } + } + // Start is called before the first frame update void Start() { @@ -70,6 +84,8 @@ public class Temple : MonoBehaviour private void ExitingQuest() { + var reward = questNumberEnemy.Reward; + GameControl.control.addCurrency(reward); timer.StopTimer(); onQuest = false; questNumberEnemy = null; @@ -83,7 +99,7 @@ public class Temple : MonoBehaviour } idxCurrentQuest++; - ToastManager.Instance.ShowToastQueue("Quest " + idxCurrentQuest + " is Completed!", 1); + ToastManager.Instance.ShowToastQueue("Quest " + idxCurrentQuest + " is Completed! You got additional coins: " + reward, 1); // retrieve the time // add it to the global time @@ -94,6 +110,8 @@ public class Temple : MonoBehaviour + " + " + System.TimeSpan.FromSeconds(questTime).ToString("mm':'ss"), 1); GlobalManager.Instance.TotalTime += questTime; ToastManager.Instance.ShowToastQueue(System.TimeSpan.FromSeconds(GlobalManager.Instance.TotalTime).ToString("mm':'ss"), 1); + + this.saveDialog.Show(); } private void OnTriggerEnter(Collider other) diff --git a/Assets/Scripts/SaveLoad/SaveDialogHandler.cs b/Assets/Scripts/SaveLoad/SaveDialogHandler.cs index dd892a8ccbbf796e209ecd5d19aad3c315ac0482..7f860da44ef847df9b40da4df99cf88ec5d1fa4c 100644 --- a/Assets/Scripts/SaveLoad/SaveDialogHandler.cs +++ b/Assets/Scripts/SaveLoad/SaveDialogHandler.cs @@ -99,7 +99,16 @@ public class SaveDialogHandler : MonoBehaviour // Update is called once per frame void Update() { - + var onquest = GlobalStateManager.Instance.OnQuest; + if (onquest) + { + Close(); + } + + if (Input.GetKeyDown(KeyCode.Escape)) + { + Close(); + } } public void Show() diff --git a/Assets/Scripts/SaveLoad/SavePlace.cs b/Assets/Scripts/SaveLoad/SavePlace.cs index 20f06d03370629d7c49a511c281486ef961dc7fb..05e35ec24d56825249d36dc7a89e62649a4a1b5e 100644 --- a/Assets/Scripts/SaveLoad/SavePlace.cs +++ b/Assets/Scripts/SaveLoad/SavePlace.cs @@ -33,7 +33,8 @@ public class SavePlace : MonoBehaviour private void OnTriggerEnter(Collider other) { - if (other.CompareTag("Player")) + var onquest = GlobalStateManager.Instance.OnQuest; + if (other.CompareTag("Player") && !onquest) { ToastManager.Instance.ShowToast("Press B to save", 1); onArea = true; diff --git a/Assets/Scripts/States/GlobalStateManager.cs b/Assets/Scripts/States/GlobalStateManager.cs index ac3446882c29492fc5e3a15fc3f8f738321ff8b4..dbe4210efa0deb919a0190a3e90162c4be89366c 100644 --- a/Assets/Scripts/States/GlobalStateManager.cs +++ b/Assets/Scripts/States/GlobalStateManager.cs @@ -9,8 +9,21 @@ public class GlobalStateManager : MonoBehaviour public static GlobalStateManager Instance { get; private set; } private PlayerWeapons playerWeapons; private PlayerHealth playerHealth; - private Temple temple; + private Temple _temple; + private Temple temple + { + get + { + if (_temple == null) + { + _temple = FindObjectOfType<Temple>(); + } + + return _temple; + } + } private PetHealth petHealth; + private CheatManager cheatManager; private void Awake() { @@ -29,14 +42,17 @@ public class GlobalStateManager : MonoBehaviour { playerWeapons = FindObjectOfType<PlayerWeapons>(); playerHealth = FindObjectOfType<PlayerHealth>(); - temple = FindObjectOfType<Temple>(); + _temple = FindObjectOfType<Temple>(); petHealth = FindObjectOfType<PetHealth>(); + cheatManager = FindObjectOfType<CheatManager>(); } public int Money { get { + bool[] temp = cheatManager.SaveCheat(); + if (temp[(int)CheatType.MOTHERLODE]) return cheatManager.GetPrevCurrency(); return GameControl.control.currency; } } @@ -73,6 +89,28 @@ public class GlobalStateManager : MonoBehaviour } } + private PetManager _petManager; + public PetManager petManager + { + get + { + if (_petManager == null) + { + _petManager = GameObject.Find("PetManager").GetComponent<PetManager>(); + } + + return _petManager; + } + } + + + public bool OnQuest + { + get + { + return temple.OnQuest; + } + } public string Stats() { @@ -85,7 +123,7 @@ public class GlobalStateManager : MonoBehaviour var type = Enum.GetName(typeof(WeaponType), weapon.Type); var level = weapon.Level; var isUnlocked = weapon.IsUnlocked; - str += string.Format("Weapon {0} is {1}locked on level {2}\n", type, isUnlocked ? "un" : "",level); + str += string.Format("Weapon {0} is {1}locked on level {2}\n", type, isUnlocked ? "un" : "", level); } // TODO: PET @@ -96,7 +134,7 @@ public class GlobalStateManager : MonoBehaviour { get { - return temple.IdxCurrentQuest; + return temple.IdxCurrentQuest; } } @@ -117,6 +155,15 @@ public class GlobalStateManager : MonoBehaviour } } + public bool[] Cheats + { + get + { + /*return CheatManager.Ims*/ + return cheatManager.SaveCheat(); + } + } + private void Update() { if (Input.GetKeyDown(KeyCode.P)) @@ -141,24 +188,9 @@ public class GlobalStateManager : MonoBehaviour // TODO: get states var metaStateSave = new MetaStateSave("name"); - var arg1 = PlayerName; - var arg2 = Money; - var arg3 = Health; - var arg4 = IdxQuest; - var arg5 = playerWeapons; - - Debug.Log("PlayerName: " + PlayerName); - Debug.Log("Money: " + Money); - Debug.Log("Health: " + Health); - Debug.Log("IdxQuest: " + IdxQuest); - foreach (var w in playerWeapons) - { - Debug.Log("playerWeapon[{{i}}]: " + w); - } - var playerStateSave = new PlayerStateSave(PlayerName, Money, Health, IdxQuest, playerWeapons); - var petStateSave = new PetStateSave(PetHealth, -1); - var globalStateSave = new GlobalStateSave(TimePlayed); + var petStateSave = new PetStateSave(PetHealth, (int)GameControl.control.petIdx); + var globalStateSave = new GlobalStateSave(TimePlayed, Cheats); var state = new StateSave(metaStateSave, playerStateSave, petStateSave, globalStateSave); return state; @@ -178,20 +210,9 @@ public class GlobalStateManager : MonoBehaviour playerHealth.currentHealth = state.playerStateSave.health; GameControl.control.currency = state.playerStateSave.money; temple.IdxCurrentQuest = state.playerStateSave.idxQuest; - /* foreach (var weapon in state.playerStateSave.playerWeapons) - { - var type = weapon.weaponType; - var isUnlocked = weapon.isUnlocked; - var level = weapon.level; - - if (isUnlocked) - { - playerWeapons.UnlockWeapon(type); - playerWeapons.SetLevel(type, level); - } - }*/ + var len = state.playerStateSave.playerWeapons.Length; - for ( var i = 0; i<len; i++ ) + for (var i = 0; i < len; i++) { var weapon = state.playerStateSave.playerWeapons[i]; var type = weapon.weaponType; @@ -206,9 +227,15 @@ public class GlobalStateManager : MonoBehaviour } // TODO: set pet state save - + GameControl.control.petIdx = state.petStateSave.idxCurrentPet; + var pet = petManager.Spawn(state.petStateSave.idxCurrentPet); + if (pet != null) + { + pet.GetComponent<PetHealth>().currentHealth = state.petStateSave.health; + } // TODO: global state save GlobalManager.Instance.TimePlayed = state.globalStateSave.timePlayed; + cheatManager.loadCheat(state.globalStateSave.cheats); } } diff --git a/Assets/Scripts/States/StateSave.cs b/Assets/Scripts/States/StateSave.cs index 232870d665b17898cc7ed674cc5492e22d18386e..f925f4cce9ef4726eb1f2bcb4574b8e50ba33ed5 100644 --- a/Assets/Scripts/States/StateSave.cs +++ b/Assets/Scripts/States/StateSave.cs @@ -97,10 +97,12 @@ public class PetStateSave public class GlobalStateSave { public double timePlayed; + public bool[] cheats; - public GlobalStateSave(double timePlayed) + public GlobalStateSave(double timePlayed, bool[] cheats) { this.timePlayed = timePlayed; + this.cheats = cheats; } public override string ToString() diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9ec30492885d2057e378d6112afb4ba553f00566 --- /dev/null +++ b/README.md @@ -0,0 +1,140 @@ +# Tubes 2 IF3210 Pengembangan Aplikasi pada Platform +> Extended Survival Shooter written in the concept of Unity platform-based programming. + + +## Table of Contents +* [Introduction](#introduction) +* [General Information](#general-information) +* [Libraries Used](#libraries-used) +* [Screenshots](#screenshots) +* [Setup](#setup) +* [Project Status](#project-status) +* [Room for Improvement](#room-for-improvement) +* [Acknowledgements](#acknowledgements) +* [Job Description](#job-description) +* [Contact](#contact) + + +## Introduction +Hello, everyone! Welcome to our GitHub Repository! + +This project was created by: +| No. | Name | Student ID | +| :---: | :---: | :---: | +| 1. | Reinaldo Antolis | 13519015 | +| 2. | Angelica Winasta Sinisuka | 13520097 | +| 3. | Averrous Saloom | 13520100 | +| 4. | Malik Akbar Hashemi Rafsanjani | 13520105 | +| 5. | Nelsen Putra | 13520130 | + + +## General Information +### Background +After BNMO succeeded in creating an Android-based food purchase application, Doni now has high expectations for BNMO. After seeing BNMO's capabilities, Doni now wants to test BNMO's ability to make games. ~~Actually, Doni needed help for the tubes.~~ + +Doni had succeeded in making a Survival Shooter, but was not satisfied with the results, so Doni asked BNMO to try modifying the Survival Shooter to make it cooler. + +### Objective +1. Understand the basic principles of programming in Unity +2. Able to work in groups on Unity application development +3. Able to present the software that has been built + +### Description +Extended Survival Shooter is a modification of the Survival Shooter game that has additional functionality, including the following: +1. Story Mode +2. Save & Load Game +3. Game Over +4. Local Scoreboard +5. Main Menu +6. Shopkeeper +7. Weapon +8. Pet +9. Cheat +10. Weapon Upgrade (**BONUS**) + + +## Libraries Used +- Unity +- UnityEngine +- System +- TMPro + + +## Screenshots +### Cutscene + + +### Quest + + +### Save + + +### Game Over + + +### Local Scoreboard + + +### Main Menu + + +### Shopkeeper + + +### Weapon + + +### Pet + + +### Cheat + + +### Weapon Upgrade + + + +## Setup +1. Clone this repository in your own local directory + + `git clone https://gitlab.informatika.org/malikrafsan/if3210-2023-unity-jtd.git` + +2. + +3. + +4. + + +## Project Status +Project is: _complete_ + +All the specifications were implemented. + + +## Room for Improvement +- A faster or more efficient algorithm to make the program run quicker +- A better UI/UX to satisfy the users of this application + + +## Acknowledgements +- This project was based on [Spesifikasi Tugas Besar 2 IF3210](https://docs.google.com/document/d/1j_DLkW6HzVJ7TIHYZd2Adg6v6Mr_-KrcdfX7JM2fFEQ/edit) +- Thanks to God +- Thanks to Mr. Yudistira Dwi Wardhana Asnar, Mr. Muhammad Iqbal Arsyad, and Mr. Agung Dewandaru as our lecturers +- Thanks to academic assistants +- This project was created to fulfill our Big Project for IF3210 Platform-based Application Development + + +## Job Description +| No. | Name | Job Desc | Hours Spent +| :---: | :---: | :---: | +| 1. | Reinaldo Antolis | XXX | 000 +| 2. | Angelica Winasta Sinisuka | XXX | 000 +| 3. | Averrous Saloom | XXX | 000 +| 4. | Malik Akbar Hashemi Rafsanjani | XXX | 000 +| 5. | Nelsen Putra | XXX | 000 + + +## Contact +Created by JokiTubesDoni. 2023 All Rights Reserved.