From 2c4496e721556993fc95a287d3f34b4209775bb2 Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Thu, 26 Sep 2024 17:25:53 +0500 Subject: [PATCH] >Added level locking/Unlocking --- Assets/Scenes/Level_1.unity | 67 ++++++++++++++++++- Assets/Source/Scripts/GameProgress.cs | 1 + Assets/Source/Scripts/LevelSelectionScreen.cs | 41 ++++++++++++ .../Scripts/LevelSelectionScreen.cs.meta | 11 +++ 4 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 Assets/Source/Scripts/LevelSelectionScreen.cs create mode 100644 Assets/Source/Scripts/LevelSelectionScreen.cs.meta diff --git a/Assets/Scenes/Level_1.unity b/Assets/Scenes/Level_1.unity index 444187a9..6888959a 100644 --- a/Assets/Scenes/Level_1.unity +++ b/Assets/Scenes/Level_1.unity @@ -35657,9 +35657,70 @@ MonoBehaviour: m_GameObject: {fileID: 1780496680} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 20c583ef6dfb0014ba8e903e3c524d2f, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Script: {fileID: 11500000, guid: bbc01220aec21af42b658c8f7e1394b4, type: 3} + m_Name: + m_EditorClassIdentifier: + levelButtonStatesList: + - Locked: {fileID: 1929610440} + Unlocked: {fileID: 1332971986} + Completed: {fileID: 444569478} + - Locked: {fileID: 1788151842} + Unlocked: {fileID: 1535183447} + Completed: {fileID: 1476911097} + - Locked: {fileID: 1794735186} + Unlocked: {fileID: 1928894768} + Completed: {fileID: 191513299} + - Locked: {fileID: 1996921123} + Unlocked: {fileID: 265164210} + Completed: {fileID: 1204215995} + - Locked: {fileID: 1703976288} + Unlocked: {fileID: 653091084} + Completed: {fileID: 2048644369} + - Locked: {fileID: 1546442775} + Unlocked: {fileID: 358645670} + Completed: {fileID: 1388204550} + - Locked: {fileID: 759969899} + Unlocked: {fileID: 1813115399} + Completed: {fileID: 475154345} + - Locked: {fileID: 2065824762} + Unlocked: {fileID: 2017097871} + Completed: {fileID: 1260602678} + - Locked: {fileID: 1309489079} + Unlocked: {fileID: 1959940118} + Completed: {fileID: 340085412} + - Locked: {fileID: 426892049} + Unlocked: {fileID: 444941659} + Completed: {fileID: 821336363} + - Locked: {fileID: 806270146} + Unlocked: {fileID: 1486555263} + Completed: {fileID: 2001763897} + - Locked: {fileID: 1523267509} + Unlocked: {fileID: 1878934031} + Completed: {fileID: 1774304840} + - Locked: {fileID: 1925523366} + Unlocked: {fileID: 820727160} + Completed: {fileID: 1126456150} + - Locked: {fileID: 551843513} + Unlocked: {fileID: 2047664198} + Completed: {fileID: 139987263} + - Locked: {fileID: 2022041416} + Unlocked: {fileID: 335174088} + Completed: {fileID: 730183919} + - Locked: {fileID: 331774113} + Unlocked: {fileID: 68099417} + Completed: {fileID: 353052220} + - Locked: {fileID: 132478589} + Unlocked: {fileID: 1336815597} + Completed: {fileID: 490035123} + - Locked: {fileID: 1618354688} + Unlocked: {fileID: 869651978} + Completed: {fileID: 886029138} + - Locked: {fileID: 768304873} + Unlocked: {fileID: 701129813} + Completed: {fileID: 1142862741} + - Locked: {fileID: 159502466} + Unlocked: {fileID: 1418597769} + Completed: {fileID: 823371453} --- !u!23 &1787493491 stripped MeshRenderer: m_CorrespondingSourceObject: {fileID: 3250460047876692766, guid: 22094cc6dd603d942832401b762230e8, type: 3} diff --git a/Assets/Source/Scripts/GameProgress.cs b/Assets/Source/Scripts/GameProgress.cs index 5310de2c..c4de4c4e 100644 --- a/Assets/Source/Scripts/GameProgress.cs +++ b/Assets/Source/Scripts/GameProgress.cs @@ -15,6 +15,7 @@ public class GameProgress : GameStateMachineUser [SerializeField] private Vector2 levelUpTimeRange; [SerializeField] private Button[] levelButtons; // Array for buttons [SerializeField] private Text[] levelTexts; // Array for corresponding Text objects + [SerializeField] private LevelSelectionScreen levelSelectionScreen; int levelIndex; private float XPforLevelUp; private float totalXP; diff --git a/Assets/Source/Scripts/LevelSelectionScreen.cs b/Assets/Source/Scripts/LevelSelectionScreen.cs new file mode 100644 index 00000000..e0b54e7f --- /dev/null +++ b/Assets/Source/Scripts/LevelSelectionScreen.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class LevelButtonStates +{ + public GameObject Locked; + public GameObject Unlocked; + public GameObject Completed; +} + +public class LevelSelectionScreen : MonoBehaviour +{ + public List levelButtonStatesList; + + + + public void LockLevel(int levelIndex) + { + levelButtonStatesList[levelIndex].Completed.SetActive(false); + levelButtonStatesList[levelIndex].Unlocked.SetActive(false); + levelButtonStatesList[levelIndex].Locked.SetActive(true); + } + + public void UnlockLevel(int levelIndex) + { + levelButtonStatesList[levelIndex].Completed.SetActive(false); + levelButtonStatesList[levelIndex].Unlocked.SetActive(true); + levelButtonStatesList[levelIndex].Locked.SetActive(false); + } + + public void LevelCompleted(int levelIndex) + { + levelButtonStatesList[levelIndex].Completed.SetActive(true); + levelButtonStatesList[levelIndex].Unlocked.SetActive(false); + levelButtonStatesList[levelIndex].Locked.SetActive(false); + } + +} diff --git a/Assets/Source/Scripts/LevelSelectionScreen.cs.meta b/Assets/Source/Scripts/LevelSelectionScreen.cs.meta new file mode 100644 index 00000000..26e65e96 --- /dev/null +++ b/Assets/Source/Scripts/LevelSelectionScreen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bbc01220aec21af42b658c8f7e1394b4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: