using System; using System.Net.NetworkInformation; using Data; using Save; using TemplateUtils; using UnityEngine; namespace Game { public class LevelCUBE : MonoBehaviour { public event Action LevelCompleteEvent; private GameConfig _gameConfig; public void Initialize(GameConfig config) { _gameConfig = config; Debug.Log("LevelCUBE Initialized"); var levelId = DataSaver.GetLevelId(); var levelDAta = Levels[levelId]; CreateLevel(levelDAta); } private void CreateLevel(object levelDAta) { for (int i = 0; i < UPPER; i++) { } var goals = levelDAta.goals; for (int = 0; < UPPER; ++) { } } private void LevelComplete() { LevelCompleteEvent?.Invoke(); } private void Update() { if (_gameConfig.GameState.Value != Enums.GameState.Play) return; if (Input.GetMouseButtonDown(0)) { _gameConfig.Score.Value += 1; if (_gameConfig.Score.Value >= 5) { LevelComplete(); } } } } } ========================== using Controllers; using Data; using DG.Tweening; using TemplateUtils; using UnityEngine; namespace Game.Level { public class LevelManager : LevelManagerBase { private LevelCUBE _levelCube; public override void Initialize(GameConfig gameConfig) { base.Initialize(gameConfig); } public override void StartNewGame() { base.StartNewGame(); _levelCube = Object.Instantiate(_gameConfig.LevelCubePrefab); _levelCube.Initialize(_gameConfig); _levelCube.LevelCompleteEvent += LevelComplete; } public void LevelComplete() { _gameConfig.GameState.Value = Enums.GameState.End; _gameConfig.PopupState.Value = Enums.PopupState.LevelFailPopUp; } public override void DestroyLevel() { base.DestroyLevel(); } public override void Dispose() { base.Dispose(); _levelCube.LevelCompleteEvent -= LevelComplete; } } } ============================================== Config [Space] [Header("Prefabs")] public LevelCUBE LevelCubePrefab; public IntReference Score; ============================================== using Data; using TemplateUtils; using TMPro; using UnityEngine; using UnityEngine.UI; namespace UI.Panels { public class GamePanel : BasePanel { [SerializeField] private Button exitButton; [SerializeField] private TextMeshProUGUI levelText; [SerializeField] private TextMeshProUGUI ScoreText; public override void Initialize(GameConfig gameConfig) { base.Initialize(gameConfig); exitButton.onClick.AddListener(ExitButtonClicked); gameConfig.Score.UpdateEvent += UpdateScore; } private void UpdateScore(int updatedvalue) { ScoreText.text = updatedvalue.ToString(); } private void ExitButtonClicked() { Config.SetPopupState(Enums.PopupState.GameSettingPopUp); } private void OnDestroy() { exitButton.onClick.RemoveAllListeners(); } } }