Added Level Selection

Tahir-branch
Hazim Bin Ijaz 2 months ago
parent 435297ba04
commit 052d8c5520

@ -130,6 +130,7 @@ namespace D2D.Databases
PassedLevels.Value++; PassedLevels.Value++;
} }
public static void Clear() public static void Clear()
{ {
ES3.Save("ReloadsCount", 0); ES3.Save("ReloadsCount", 0);

@ -7,17 +7,20 @@ using UnityEngine;
public class MemberInitializer : Unit public class MemberInitializer : Unit
{ {
[SerializeField] private List<SquadMember> listOfCharacters; [SerializeField] private List<SquadMember> listOfCharacters;
[SerializeField] private List<NeutralMember> listOfNeutralCharacters;
[SerializeField] private SquadMember squadMember; [SerializeField] private SquadMember squadMember;
private SquadComponent squadComponent; private SquadComponent squadComponent;
[SerializeField] private NeutralsSpawn neutralsSpawn;
private void Awake() private void Awake()
{ {
squadComponent = Get<SquadComponent>(); squadComponent = Get<SquadComponent>();
squadMember = GetInitialSquadMember();
neutralsSpawn.neutralMember = GetInitialNeutralMember();
AddMember();
} }
private void Start() private void Start()
{ {
squadMember = GetInitialSquadMember();
AddMember();
} }
private SquadMember GetInitialSquadMember() private SquadMember GetInitialSquadMember()
@ -26,6 +29,12 @@ public class MemberInitializer : Unit
return listOfCharacters[selectedPlayerId]; return listOfCharacters[selectedPlayerId];
} }
private NeutralMember GetInitialNeutralMember()
{
int selectedPlayerId = GetIDFromPlayerPrefs();
return listOfNeutralCharacters[selectedPlayerId];
}
private int GetIDFromPlayerPrefs() private int GetIDFromPlayerPrefs()
{ {
return PlayerPrefs.GetInt(Constants.PlayerSelectionKey, 0); return PlayerPrefs.GetInt(Constants.PlayerSelectionKey, 0);

File diff suppressed because one or more lines are too long

@ -8,7 +8,7 @@ public class NeutralsSpawn : Unit
{ {
[SerializeField] private int maxNeutralsOnScreen = 8; [SerializeField] private int maxNeutralsOnScreen = 8;
[SerializeField] private float spawnCooldown = .8f; [SerializeField] private float spawnCooldown = .8f;
[SerializeField] private NeutralMember neutralMember; public NeutralMember neutralMember;
private Camera currentCamera; private Camera currentCamera;

@ -12,7 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 40a8313b47064e26bcdb60e81b588bc9, type: 3} m_Script: {fileID: 11500000, guid: 40a8313b47064e26bcdb60e81b588bc9, type: 3}
m_Name: GameplaySettings m_Name: GameplaySettings
m_EditorClassIdentifier: m_EditorClassIdentifier:
levels: [] levels:
- {fileID: 0}
groundMaterials: groundMaterials:
- {fileID: 2100000, guid: ebf7e8ea2b948a34ca46b0d32ce8d667, type: 2} - {fileID: 2100000, guid: ebf7e8ea2b948a34ca46b0d32ce8d667, type: 2}
pistolProjectile: {fileID: 11400000, guid: eee42d13775b33643be3ec5187ac0ef9, type: 2} pistolProjectile: {fileID: 11400000, guid: eee42d13775b33643be3ec5187ac0ef9, type: 2}

File diff suppressed because it is too large Load Diff

@ -498,7 +498,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 0, g: 0.77999973, b: 1, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
@ -676,8 +676,8 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} m_Sprite: {fileID: 21300000, guid: 80ca872f56e1d374a8d320061f652e8e, type: 3}
m_Type: 1 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
m_FillMethod: 4 m_FillMethod: 4

File diff suppressed because it is too large Load Diff

@ -1,5 +1,6 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using D2D.Databases;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
@ -10,7 +11,7 @@ public class CharacterSelectionUI : MonoBehaviour
[SerializeField] private Button leftButton; // Button to scroll left [SerializeField] private Button leftButton; // Button to scroll left
[SerializeField] private Button rightButton; // Button to scroll right [SerializeField] private Button rightButton; // Button to scroll right
[SerializeField] private Button nextButton; // Button to confirm and save the selection [SerializeField] private Button nextButton; // Button to confirm and save the selection
[SerializeField] private GameProgressionDatabase GameProgressionDatabase;
private int currentIndex = 0; // Tracks the currently active character index private int currentIndex = 0; // Tracks the currently active character index
void Start() void Start()
@ -50,6 +51,7 @@ public class CharacterSelectionUI : MonoBehaviour
PlayerPrefs.SetInt(Constants.PlayerSelectionKey, currentIndex); PlayerPrefs.SetInt(Constants.PlayerSelectionKey, currentIndex);
PlayerPrefs.Save(); PlayerPrefs.Save();
Debug.Log("Character " + currentIndex + " selected and saved."); Debug.Log("Character " + currentIndex + " selected and saved.");
// GameProgressionDatabase.ResetLevelsPerSession();
// SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); // SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
} }

@ -1,18 +1,18 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using D2D.Databases;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LevelSelectionUI : MonoBehaviour public class LevelSelectionUI : MonoBehaviour
{ {
// Start is called before the first frame update [SerializeField] private GameProgressionDatabase gameProgressionDatabase;
void Start() public void OnButtonClicked(int level)
{ {
gameProgressionDatabase.PassedLevels.Value = level == -1 ? 0 : level;
} SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
// Update is called once per frame
void Update()
{
} }
} }

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5071c26e606b8724ea4cf941fe967170
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1b2e5360cddaa1548807141331917a93
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -12,6 +12,6 @@ EditorBuildSettings:
path: Assets/Scenes/MainMenu.unity path: Assets/Scenes/MainMenu.unity
guid: 9888893f03b606b46a630459db2dd1b6 guid: 9888893f03b606b46a630459db2dd1b6
- enabled: 1 - enabled: 1
path: Assets/Scenes/Level_1.unity path: Assets/Scenes/Gameplay.unity
guid: c5ddf6fc4e21e4ec18c592064edf342f guid: c5ddf6fc4e21e4ec18c592064edf342f
m_configObjects: {} m_configObjects: {}

Loading…
Cancel
Save