Implemented dungeon selector
This commit is contained in:
parent
514d985ddb
commit
aeeb15cb12
46 changed files with 26355 additions and 32 deletions
|
|
@ -0,0 +1,13 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace DungeonSelection
|
||||
{
|
||||
[CreateAssetMenu(fileName = "New Dungeon", menuName = "Dungeon")]
|
||||
public class DungeonData : ScriptableObject
|
||||
{
|
||||
public string DungeonName;
|
||||
public Sprite Thumbnail;
|
||||
public string SceneName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b94e2e73105498fac9021dca1250c4b
|
||||
timeCreated: 1740990047
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace DungeonSelection
|
||||
{
|
||||
public class DungeonLoader : MonoBehaviour
|
||||
{
|
||||
private void OnEnable()
|
||||
{
|
||||
GameEvents.LoadDungeon += LoadDungeon;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GameEvents.LoadDungeon -= LoadDungeon;
|
||||
}
|
||||
|
||||
public static void LoadDungeon(DungeonData dungeonData)
|
||||
{
|
||||
SceneManager.LoadScene(dungeonData.SceneName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f74d58a6b5f48d4a1f6ef179fb11a76
|
||||
timeCreated: 1740995037
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace DungeonSelection
|
||||
{
|
||||
public class DungeonSelector : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private DungeonData[] dungeons;
|
||||
private DungeonData _currentlySelectedDungeonData;
|
||||
private int _currentlySelectedDungeonIndex = 0;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
UIEvents.NextDungeonClicked += SelectNextDungeon;
|
||||
UIEvents.PreviousDungeonClicked += SelectPreviousDungeon;
|
||||
UIEvents.EnterDungeonClicked += LoadDungeon;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
UIEvents.NextDungeonClicked -= SelectNextDungeon;
|
||||
UIEvents.PreviousDungeonClicked -= SelectPreviousDungeon;
|
||||
UIEvents.EnterDungeonClicked -= LoadDungeon;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameEvents.DungeonSelectionStarted?.Invoke();
|
||||
|
||||
_currentlySelectedDungeonData = dungeons[_currentlySelectedDungeonIndex];
|
||||
GameEvents.ShowingDungeon?.Invoke(_currentlySelectedDungeonData);
|
||||
if (_currentlySelectedDungeonIndex == 0)
|
||||
{
|
||||
GameEvents.ShowingFirstDugeon?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadDungeon(DungeonData dungeon)
|
||||
{
|
||||
GameEvents.LoadDungeon?.Invoke(dungeon);
|
||||
}
|
||||
|
||||
private void SelectNextDungeon()
|
||||
{
|
||||
if (_currentlySelectedDungeonIndex + 1 >= dungeons.Length) return;
|
||||
_currentlySelectedDungeonIndex++;
|
||||
_currentlySelectedDungeonData = dungeons[_currentlySelectedDungeonIndex];
|
||||
GameEvents.ShowingDungeon?.Invoke(_currentlySelectedDungeonData);
|
||||
if (_currentlySelectedDungeonIndex == dungeons.Length - 1)
|
||||
{
|
||||
GameEvents.ShowingLastDungeon?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectPreviousDungeon()
|
||||
{
|
||||
if (_currentlySelectedDungeonIndex - 1 < 0) return;
|
||||
_currentlySelectedDungeonIndex--;
|
||||
_currentlySelectedDungeonData = dungeons[_currentlySelectedDungeonIndex];
|
||||
GameEvents.ShowingDungeon?.Invoke(_currentlySelectedDungeonData);
|
||||
if (_currentlySelectedDungeonIndex == 0)
|
||||
{
|
||||
GameEvents.ShowingFirstDugeon?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c4e78bf105514ac45bd51d639ef9da5c
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace DungeonSelection
|
||||
{
|
||||
// Announcing in game events
|
||||
public static class GameEvents
|
||||
{
|
||||
public static Action DungeonSelectionStarted;
|
||||
public static Action ShowingLastDungeon;
|
||||
public static Action ShowingFirstDugeon;
|
||||
public static Action<DungeonData> ShowingDungeon;
|
||||
public static Action<DungeonData> LoadDungeon;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d50ab8728586475daa8f20f953be31dd
|
||||
timeCreated: 1740991637
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace DungeonSelection
|
||||
{
|
||||
// Announcing actions taken in UI
|
||||
public static class UIEvents
|
||||
{
|
||||
public static Action NextDungeonClicked;
|
||||
public static Action PreviousDungeonClicked;
|
||||
public static Action<DungeonData> EnterDungeonClicked;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a3f1145923464a0ba0209796e00263d2
|
||||
timeCreated: 1740991548
|
||||
Loading…
Add table
Add a link
Reference in a new issue