116 lines
3.8 KiB
C#
116 lines
3.8 KiB
C#
using System.Collections.Generic;
|
|
using BriarQueen.Data.Identifiers;
|
|
using BriarQueen.Framework.Coordinators.Events;
|
|
using BriarQueen.Framework.Events.UI;
|
|
using BriarQueen.Framework.Managers.Hints.Data;
|
|
using BriarQueen.Framework.Managers.Interaction;
|
|
using BriarQueen.Framework.Managers.IO;
|
|
using BriarQueen.Framework.Managers.Player;
|
|
using BriarQueen.Framework.Managers.Player.Data.Codex;
|
|
using BriarQueen.Framework.Services.Destruction;
|
|
using BriarQueen.Framework.Services.Settings;
|
|
using BriarQueen.Framework.Services.Tutorials;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using VContainer;
|
|
|
|
namespace BriarQueen.Framework.Managers.Levels.Data
|
|
{
|
|
public class BaseLevel : MonoBehaviour
|
|
{
|
|
[Header("General")]
|
|
[SerializeField]
|
|
private LevelKey _levelKey;
|
|
[SerializeField]
|
|
private string _levelName;
|
|
[Header("Items")]
|
|
[SerializeField]
|
|
public List<BaseItem> Pickups;
|
|
|
|
public List<CodexTrigger> CodexTriggers;
|
|
|
|
[Header("Setup")]
|
|
[SerializeField]
|
|
protected GraphicRaycaster _raycaster;
|
|
|
|
protected DestructionService DestructionService;
|
|
|
|
protected EventCoordinator EventCoordinator;
|
|
protected InteractManager InteractManager;
|
|
protected PlayerManager PlayerManager;
|
|
protected SaveManager SaveManager;
|
|
protected SettingsService SettingsService;
|
|
protected TutorialService TutorialService;
|
|
public virtual string SceneID => AssetKeyIdentifiers.Get(SceneKey.GameScene);
|
|
public string LevelID => AssetKeyIdentifiers.Get(_levelKey);
|
|
|
|
public virtual string LevelName => _levelName;
|
|
|
|
public virtual bool IsPuzzleLevel { get; }
|
|
|
|
public virtual int CurrentLevelHintStage { get; set; }
|
|
|
|
public virtual Dictionary<int, BaseHint> Hints { get; }
|
|
|
|
[Inject]
|
|
public void Construct(EventCoordinator eventCoordinator, InteractManager interactManager, SaveManager saveManager,
|
|
DestructionService destructionService, SettingsService settingsService, PlayerManager playerManager,
|
|
TutorialService tutorialService)
|
|
{
|
|
EventCoordinator = eventCoordinator;
|
|
InteractManager = interactManager;
|
|
SaveManager = saveManager;
|
|
DestructionService = destructionService;
|
|
SettingsService = settingsService;
|
|
PlayerManager = playerManager;
|
|
TutorialService = tutorialService;
|
|
}
|
|
|
|
public async UniTask PostLoad()
|
|
{
|
|
InteractManager.AddUIRaycaster(_raycaster);
|
|
EventCoordinator.Publish(new UIToggleHudEvent(true));
|
|
|
|
await PostLoadInternal();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called after Level Load, but before activating. Override for Implementations
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected virtual UniTask PostLoadInternal()
|
|
{
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
public async UniTask PostActivate()
|
|
{
|
|
await PostActivateInternal();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called after a level is activated. Override for implementations.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected virtual UniTask PostActivateInternal()
|
|
{
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
public async UniTask PreUnload()
|
|
{
|
|
InteractManager.RemoveUIRaycaster(_raycaster);
|
|
await PreUnloadInternal();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called before the level is destroyed. Override for cleanup, etc.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected virtual UniTask PreUnloadInternal()
|
|
{
|
|
return UniTask.CompletedTask;
|
|
}
|
|
}
|
|
} |