private void Initialize() { PlayerUnits = GetComponentInChildren <PlayerUnits> (); EnemyUnits = GetComponentInChildren <EnemyUnits> (); EnemyUnits.Init(); _enemySpawners = GetComponentsInChildren <EnemySpawner>(); foreach (var enemySpawner in _enemySpawners) { enemySpawner.Init(EnemyUnits); } #if UNITY_EDITOR if (Global.Instance.CurrentGameData == null) { Global.Instance.CurrentGameData = new GameData() { Level = 1, PlayerDatas = new List <PlayerData>() { new PlayerData() { Controller = InputManager.ControllerType.KeyboardArrow, Id = PlayerData.PlayerId.Player1, Lives = 3, UnitType = PlayerUnit.UnitType.Balanced }, new PlayerData() { Controller = InputManager.ControllerType.KeyboardWasd, Id = PlayerData.PlayerId.Player2, Lives = 3, UnitType = PlayerUnit.UnitType.Heavy } } }; } #endif PlayerUnits.Init(Global.Instance.CurrentGameData.PlayerDatas.ToArray()); InputManager = gameObject.GetOrAddComponent <InputManager> (); InputManager.Init(this, InputManager.ControllerType.KeyboardWasd, InputManager.ControllerType.KeyboardArrow, InputManager.ControllerType.Gamepad1); // All conditions should be parented to LevelManager _conditions = GetComponentsInChildren <ConditionBase> (); foreach (var condition in _conditions) { condition.Init(this); } }
private void Initialize() { PlayerUnits = GetComponentInChildren <PlayerUnits> (); EnemyUnits = GetComponentInChildren <EnemyUnits> (); EnemyUnits.Init(); // TODO: Get player data from GameManager (new data or saved data) PlayerData playerData = new PlayerData() { Id = PlayerData.PlayerId.Player1, UnitType = PlayerUnit.UnitType.Heavy, Lives = 3 }; PlayerUnits.Init(playerData); }