using System.Collections.Generic;
using UnityEngine.SceneManagement;
///
/// Maintains information about each possible destination (scene) in the game
///
public struct Route
{
public string RouteDescription;
public bool CanTravel;
}
public static class NavigationManager
{
///
/// This dictioanry defines all destinations that exist in the game.
///
public static Dictionary RouteInformation = new Dictionary()
{
{ "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 } },
};
///
/// Searches the dictionary to find if the given destination is defined.
///
///
///
public static string GetRouteInfo(string destination)
{
return RouteInformation.ContainsKey(destination) ? RouteInformation[destination].RouteDescription : null;
}
///
/// Determines whether the given destination can be travelled to or not.
///
///
///
public static bool CanNavigate(string destination)
{
return RouteInformation.ContainsKey(destination) ? RouteInformation[destination].CanTravel : false;
}
///
/// This method performs the action of loading a new scene. The destination value needs
/// to match the name of a scene in the project.
///
///
public static void NavigateTo(string destination)
{
SceneManager.LoadScene(destination);
}
}