-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavigationManager.cs
59 lines (47 loc) · 1.55 KB
/
NavigationManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class NavigationManager : MonoBehaviour {
public struct Route
{
public string RouteDescription;
public bool CanTravel;
}
public static Dictionary<string, Route> RouteInformation = new Dictionary<string, Route>() {
{ "Town", new Route {CanTravel = true}},
{ "Shop", new Route {CanTravel = true}},
{ "Arena", new Route {CanTravel = true}},
};
private static string PreviousLocation;
public static string GetRouteInfo(string destination)
{
return RouteInformation.ContainsKey(destination) ? RouteInformation[destination].RouteDescription : null;
}
public static bool CanNavigate(string destination)
{
return RouteInformation.ContainsKey(destination) ? RouteInformation[destination].CanTravel : false;
}
public static void NavigateTo(string destination)
{
PreviousLocation = SceneManager.GetActiveScene().name;
//PreviousLocation = Application.loadedLevelName;
//Debug.Log (destination);
if (PreviousLocation == "Arena" && destination == "Town") {
GameState.PlayerReturningHome = true;
} else {
GameState.PlayerReturningHome = false;
}
ChangeScene (destination);
}
public static void GoBack()
{
var backlocation = PreviousLocation;
PreviousLocation = SceneManager.GetActiveScene().name;
//PreviousLocation = Application.loadedLevelName;
SceneManager.LoadScene (backlocation);
//FadeInOutManager.FadeToLevel (backlocation);
}
public static void ChangeScene(string destination){
SceneManager.LoadScene (destination);
}
}