Newer
Older
Marco Zimmer
committed
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public static class StageStatic
{
public static Dictionary<string, Stage> StageOfficial;
public static Dictionary<string, Stage> StageLocal;
public static string current_name;
public static bool local_stage;
public static bool devel = false;
public static Mode mode;
public static Stage stage {
get {
return (local_stage ? StageLocal : StageOfficial)[current_name];
}
set {
current_name = value.name;
local_stage = !value.use_install_folder;
(local_stage ? StageLocal : StageOfficial).Remove(current_name);
(local_stage ? StageLocal : StageOfficial).Add(current_name, value);
}
}
public enum Mode
{
Play,
Create,
}
public static void SetMode(Mode mode, GameObject gameObject = null)
{
gameObject ??= new GameObject();
// handle StageStatic.mode
switch (StageStatic.mode = mode)
{
case Mode.Play:
gameObject.UpdateTagActive("CreatorMode", false);
break;
case Mode.Create:
gameObject.UpdateTagActive("CreatorMode", true);
break;
}
// handle stage mode
switch (mode)
{
case Mode.Play:
case Mode.Create:
stage.SetMode(mode == Mode.Create);
break;
}
}
public static void WakeUp()
{
}
public static bool LoadNewStage(int id, string name, string description, string scene)
{
if (name.Length == 0
|| ContainsKey(name, true)
|| ContainsNumber(id, true))
return false;
stage = new Stage(id, name, description, scene, true);
stage.creatorMode = true;
stage.store();
devel = true;
Loader.LoadScene(scene);
return true;
}
public static int NextNumber(bool local)
{
var numbers = (local ? StageLocal : StageOfficial).Values.Select(s => s.number).ToList();
if (0 == numbers.Count)
return 1;
numbers.Sort();
int last = numbers[0];
foreach (int i in numbers)
{
if (i > last && i != last + 1)
return last + 1;
last = i;
}
return last + 1;
}
public static bool ContainsNumber(int i, bool local)
{
return (local ? StageLocal : StageOfficial).Values.Select(s => s.number).Contains(i);
}
public static void ShallowLoadStages()
{
StageOfficial = Stage.Grup(null, true);
StageLocal = Stage.Grup(null, false);
}
public static void SetStage(string name, bool local = false)
{
local_stage = local;
current_name = name;
}
public static bool LoadInitStage(string name, bool local = false, bool restore_session = true, GameObject gameObject = null)
{
if (!ContainsKey(name, local))
return false;
bool old_l = local_stage;
string old_n = current_name;
SetStage(name, local);
if (!LoadInitStage(restore_session, gameObject))
{
local_stage = old_l;
current_name = old_n;
return false;
}
return true;
}
public static bool LoadInitStage(bool restore_session = true, GameObject gameObject = null)
{
if (current_name == null || current_name.Length == 0 || !stage.DeepLoad())
return false;
gameObject ??= new GameObject();
if (restore_session)
{
stage.factState.invoke = true;
stage.factState.Draw();
}
else
stage.factState = new FactOrganizer(true);
gameObject.UpdateTagActive("DevelopingMode", devel);
SetMode(stage.creatorMode ? Mode.Create : Mode.Play);
return true;
}
public static bool ContainsKey(string key)
{
return ContainsKey(key, local_stage);
}
public static bool ContainsKey(string key, bool local = false)
{
return (local ? StageLocal : StageOfficial).ContainsKey(key);
}
}