-
Notifications
You must be signed in to change notification settings - Fork 1
/
ResourceUtils.cs
185 lines (166 loc) · 8.67 KB
/
ResourceUtils.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
using Godot;
using System;
using System.Collections.Generic;
public static class ResourceUtils
{
public static PackedScene world;
public static PackedScene intro;
public static PackedScene pause;
public static PackedScene player;
public static PackedScene camera;
public static List<PackedScene> levels;
public static List<PackedScene> enemies;
public static List<PackedScene> bullets;
public static List<PackedScene> weapons;
public static List<TileSet> tilesets;
public static List<PackedScene> particles;
public static List<PackedScene> gfx;
public static PackedScene background;
public static List<Texture> bgTextures;
public static List<AudioStreamMP3>ingameMusic;
public static PackedScene touch;
public static PackedScene buttons;
public static void Init()
{
levels=new List<PackedScene>();
enemies=new List<PackedScene>();
tilesets=new List<TileSet>();
bgTextures=new List<Texture>();
particles=new List<PackedScene>();
bullets=new List<PackedScene>();
gfx=new List<PackedScene>();
weapons=new List<PackedScene>();
ingameMusic=new List<AudioStreamMP3>();
bool pck=ProjectSettings.LoadResourcePack("res://nodungeon.pck");
if(pck)
{
Console.WriteLine("Found external main dlc, using it.");
}
else
{
Console.WriteLine("No external main dlc found.");
}
Console.WriteLine("Check for addons...");
Directory dir=new Directory();
List<string>files=new List<string>();
if(dir.DirExists("res://dlcs"))
{
dir.Open("res://dlcs");
dir.ListDirBegin();
string file=dir.GetNext();
while(file!="")
{
if(file.EndsWith(".pck"))
{
files.Add("res://dlcs/"+file);
}
file=dir.GetNext();
}
dir.ListDirEnd();
}
else
{
dir.MakeDir("res://dlcs");
}
if(files.Count>0)
{
files.ForEach(file=>
{
if(ProjectSettings.LoadResourcePack(file,false))
{
Console.WriteLine("Loaded "+file);
}
else
{
Console.WriteLine("Failed to load "+file);
}
});
}
else
{
Console.WriteLine("No addons found.");
}
if(GameSettings.isMobile)
{
Console.WriteLine("Found Mobile, loading touch input");
touch=ResourceLoader.Load<PackedScene>("res://io/Touch.tscn");
buttons=ResourceLoader.Load<PackedScene>("res://io/Buttons.tscn");
}
Console.WriteLine("Loading Resources...");
world=ResourceLoader.Load<PackedScene>("res://World.tscn");
intro=ResourceLoader.Load<PackedScene>("res://intro/Intro.tscn");
pause=ResourceLoader.Load<PackedScene>("res://ui/PauseUI.tscn");
player=ResourceLoader.Load<PackedScene>("res://Player.tscn");
background=ResourceLoader.Load<PackedScene>("res://level/Background.tscn");
camera=ResourceLoader.Load<PackedScene>("res://PlayerCamera.tscn");
Console.WriteLine("Loading levels...");
levels.Add(ResourceLoader.Load<PackedScene>("res://level/Level.tscn"));
levels.Add(ResourceLoader.Load<PackedScene>("res://level/Level1.tscn"));
levels.Add(ResourceLoader.Load<PackedScene>("res://level/Level2.tscn"));
levels.Add(ResourceLoader.Load<PackedScene>("res://level/Level3.tscn"));
levels.Add(ResourceLoader.Load<PackedScene>("res://level/Level4.tscn"));
levels.Add(ResourceLoader.Load<PackedScene>("res://level/Level5.tscn"));
levels.Add(ResourceLoader.Load<PackedScene>("res://level/Level6.tscn"));
Console.WriteLine("Loading tilesets...");
tilesets.Add(ResourceLoader.Load<TileSet>("res://level/tileset1.tres"));
tilesets.Add(ResourceLoader.Load<TileSet>("res://level/tileset2.tres"));
tilesets.Add(ResourceLoader.Load<TileSet>("res://level/tileset3.tres"));
tilesets.Add(ResourceLoader.Load<TileSet>("res://level/tileset4.tres"));
Console.WriteLine("Loading background textures...");
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_A/PNG/bg1.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_A/PNG/bg2.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_A/PNG/bg3.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_B/PNG/bg1.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_B/PNG/bg2.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_B/PNG/bg3.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_C/PNG/bg1.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_C/PNG/bg2.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_C/PNG/bg3.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_D/PNG/bg1.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_D/PNG/bg2.png"));
bgTextures.Add(ResourceLoader.Load<Texture>("res://image/super_pixel_cave/style_D/PNG/bg3.png"));
Console.WriteLine("Loading particles...");
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/BlockParticles.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/CoinTakenParticles.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/EnemieDieParticles.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/DaggerMissParticles.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/MadRockParticles.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/WeaponChangeParticles.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/JumpParticles.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/DaggerShoot.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/PlayerDieEffect.tscn"));
particles.Add(ResourceLoader.Load<PackedScene>("res://particles/ExplodeParticles.tscn"));
Console.WriteLine("Loading bullets...");
bullets.Add((PackedScene)ResourceLoader.Load("res://bullets/SkullBullet.tscn"));
bullets.Add((PackedScene)ResourceLoader.Load("res://bullets/DaggerBullet.tscn"));
Console.WriteLine("Loading visual effects...");
gfx.Add(ResourceLoader.Load<PackedScene>("res://gfx/ExplodeGfx1.tscn"));
gfx.Add(ResourceLoader.Load<PackedScene>("res://gfx/ExplodeGfx2.tscn"));
gfx.Add(ResourceLoader.Load<PackedScene>("res://gfx/ExplodeGfx3.tscn"));
gfx.Add(ResourceLoader.Load<PackedScene>("res://gfx/ExplodeGfx4.tscn"));
gfx.Add(ResourceLoader.Load<PackedScene>("res://gfx/ExplodeGfx5.tscn"));
Console.WriteLine("Loading weapons...");
weapons.Add(ResourceLoader.Load<PackedScene>("res://weapons/Sword.tscn"));
weapons.Add(ResourceLoader.Load<PackedScene>("res://weapons/Broadsword.tscn"));
weapons.Add(ResourceLoader.Load<PackedScene>("res://weapons/Dagger.tscn"));
Console.WriteLine("Loading ingame musics...");
ingameMusic.Add(ResourceLoader.Load<AudioStreamMP3>("res://sounds/ingame/music/Dark Age 01 Stronghold Of The Barbarians.mp3"));
ingameMusic.Add(ResourceLoader.Load<AudioStreamMP3>("res://sounds/ingame/music/Dark Age 02 The Lightning - Riven Crag Of Lord Doom.mp3"));
ingameMusic.Add(ResourceLoader.Load<AudioStreamMP3>("res://sounds/ingame/music/Dark Age 03 Orcs And Goblins Emerge From The Bogswamps.mp3"));
ingameMusic.Add(ResourceLoader.Load<AudioStreamMP3>("res://sounds/ingame/music/Dark Age 05 Battle Theme I.mp3"));
ingameMusic.Add(ResourceLoader.Load<AudioStreamMP3>("res://sounds/ingame/music/Dark Age 09 The Rift Of Ever - Burning Fire.mp3"));
ingameMusic.Add(ResourceLoader.Load<AudioStreamMP3>("res://sounds/ingame/music/Dark Age 10 Battle Theme II - 1.mp3"));
Console.WriteLine("Done!");
}
public static InputController getInputController(Node scene)
{
if(GameSettings.isMobile)
{
return new MobileInput(scene);
}
else
{
return new DesktopInput();
}
}
}