You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.9 KiB
55 lines
1.9 KiB
using System.Collections.Generic; |
|
using UnityEngine.SceneManagement; |
|
|
|
/// <summary> |
|
/// Maintains information about each possible destination (scene) in the game |
|
/// </summary> |
|
public struct Route |
|
{ |
|
public string RouteDescription; |
|
public bool CanTravel; |
|
} |
|
|
|
public static class NavigationManager |
|
{ |
|
/// <summary> |
|
/// This dictioanry defines all destinations that exist in the game. |
|
/// </summary> |
|
public static Dictionary<string, Route> RouteInformation = new Dictionary<string, Route>() |
|
{ |
|
{ "Overworld", new Route { RouteDescription = "The big bad world", CanTravel = true } }, |
|
{ "Construction", new Route { RouteDescription = "The construction area", CanTravel = false } }, |
|
{ "Town", new Route { RouteDescription = "The main town", CanTravel = true } }, |
|
{ "Campsite", new Route { RouteDescription = "The campsite", CanTravel = true } }, |
|
}; |
|
|
|
/// <summary> |
|
/// Searches the dictionary to find if the given destination is defined. |
|
/// </summary> |
|
/// <param name="destination"></param> |
|
/// <returns></returns> |
|
public static string GetRouteInfo(string destination) |
|
{ |
|
return RouteInformation.ContainsKey(destination) ? RouteInformation[destination].RouteDescription : null; |
|
} |
|
|
|
/// <summary> |
|
/// Determines whether the given destination can be travelled to or not. |
|
/// </summary> |
|
/// <param name="destination"></param> |
|
/// <returns></returns> |
|
public static bool CanNavigate(string destination) |
|
{ |
|
return RouteInformation.ContainsKey(destination) ? RouteInformation[destination].CanTravel : false; |
|
} |
|
|
|
/// <summary> |
|
/// This method performs the action of loading a new scene. The destination value needs |
|
/// to match the name of a scene in the project. |
|
/// </summary> |
|
/// <param name="destination"></param> |
|
public static void NavigateTo(string destination) |
|
{ |
|
SceneManager.LoadScene(destination); |
|
} |
|
} |