-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenManager.cs
81 lines (68 loc) · 2.1 KB
/
ScreenManager.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ActionGame
{
public class ScreenManager
{
Game1 game;
bool isScreenChanging = false;
int animationType;
int step = 0;
float duration;
float delay = 0;
double time;
public ScreenManager(Game1 game)
{
this.game = game;
}
public void setScreen(Screen screen, int animation, float duration,float delay)
{
isScreenChanging = true;
screen.screenAlpha = 0F;
game.NextScreen = screen;
animationType = animation;
this.duration = duration;
this.delay = delay;
}
public void setScreenUpdate(double deltaTime)
{
}
public void update(double deltaTime)
{
if (!isScreenChanging) return;
if (delay != 0)
{
time += deltaTime/1000;
if (time < delay) return;
}
if (animationType == 1)
{
Console.WriteLine((float)deltaTime / 1000);
switch (step)
{
case 0:
if (game.MainScreen.screenAlpha < 0) step = 1;
game.MainScreen.screenAlpha -= ((float)deltaTime/1000)* (1 / duration);
break;
case 1:
game.MainScreen = game.NextScreen;
game.NextScreen = null;
step = 2;
break;
case 2:
if (game.MainScreen.screenAlpha >= 1) step = 3;
game.MainScreen.screenAlpha += ((float)deltaTime/1000) * (1 / duration);
break;
case 3:
isScreenChanging = false;
step = 0;
time = 0;
break;
}
}
}
}
}