-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScene.cs
78 lines (62 loc) · 1.81 KB
/
Scene.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
using System;
using System.Collections.Generic;
namespace Nitemare3D
{
//todo: fade in transition
public abstract class Scene
{
public const int LEVEL_START = 0;
public const int LEVEL_MAINMENU = 1;
public const int LEVEL_LEVELSELECT = 2;
public const int LEVEL_SOUNDEDITOR = 3;
public const int LEVEL_GAME = 4;
public Pcx pcx;
public int songid;
public abstract void Update();
public abstract void Load();
public abstract void UnLoad();
static int currentMenu = 0;
static List<Scene> menus = new List<Scene>();
static int nextMenu;
public bool fading = false;
public byte alpha = 255;
float fade = 255;
float fadeAmount = 0;
float loadTimer = 0;
float loadTime = .25f;
public static void Start()
{
menus[currentMenu].Load();
}
public void UpdateFading()
{
fade -= fadeAmount * Time.dt;
alpha = (fade > 0) ? (byte)fade : (byte)0;
if (fade < 1)
{
loadTimer += Time.dt;
if (loadTimer > loadTime)
{
menus[currentMenu].UnLoad();
menus[nextMenu].Load();
currentMenu = nextMenu;
}
}
}
public static Scene currentScene{
get{
return menus[currentMenu];
}
}
public static void AddScene(Scene scene)
{
menus.Add(scene);
}
public void FadeOut(int nextMenu, float fadeTime = 1f)
{
fading = true;
fadeAmount = 255f / fadeTime;
Scene.nextMenu = nextMenu;
}
}
}