I am using unity for game development for the last 1.5 years but my approach from the first game till the last game i did remain the same for handling level spawning and other game functionalities like making a manager and then in the list do everything. How can I perform all these functionalities in the better way and why? and what are the problems in this approach
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class EnemiesData
{
public Transform enemyPrefeb;
public Transform enemySpawnPoint;
}
[System.Serializable]
public class Enemies
{
public string levelName; // Name of the Level
public int levelObjective; // total objective in current level like if play has to kill 5
//enemies then 5 objective
public string objectiveText;
public List<EnemiesData> enemyDataList;
}
public class DogManager : MonoBehaviour
{
public static DogManager Instance;
[SerializeField] private GameObject playerPrefeb;
[SerializeField] private List<Enemies> enemiesList;
[SerializeField] private List<Transform> PlayerSpawnPoint;
public int currentLevel = 0;
private void Awake()
{
Instance = this;
currentLevel = 5; //lets suppose current level is 5
SpwanEnemies();
SpawnPlayer();
}
private void Start()
{
ShowObjective();
}
#region SpawnRegion
private void SpwanEnemies()
{
for (int i = 0; i < enemiesList[currentLevel].enemyDataList.Count; i++)
{
var tempEnemy = enemiesList[currentLevel].enemyDataList*;*
Instantiate(tempEnemy.enemyPrefeb, tempEnemy.enemySpawnPoint.position, tempEnemy.enemySpawnPoint.rotation);
}
}
private void SpawnPlayer()
{
//Spawn Player
}
#endregion
#region Objective
void ShowObjective()
{
// show objective
}
#endregion
#region player Healh
void CheckPlayerHealth()
{
}
void PlayerDied()
{
// Do player died functaionality
}
#endregion
#region Level Progress
void LevelComplete()
{
// Do level complete functaionality
}
void LevelFail()
{
// Do level fail functaionality
}
#endregion