-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainMenuScene.cs
131 lines (120 loc) · 3.95 KB
/
MainMenuScene.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
using System;
using System.Collections.Generic;
using System.Linq;
using BlackCoat;
using BlackCoat.Entities;
using BlackCoat.Entities.Shapes;
using SFML.Graphics;
using SFML.System;
namespace LowHigh
{
class MainMenuScene : Scene
{
private Rectangle _StartCollider;
private Rectangle _ExitCollider;
private Rectangle _CredCollider;
private Graphic _Credits;
private Rectangle _Selection;
private bool _InputLock = false;
public MainMenuScene(Core core) : base(core, "MainMenue", "Assets") { }
protected override bool Load()
{
GameManager.View.Size = GameManager.FullHD;
GameManager.View.Center = GameManager.FullHD / 2;
Layer_Background.View = GameManager.View;
Layer_Game.View = GameManager.View;
Layer_Overlay.View = GameManager.View;
var tex = TextureLoader.Load("highestlowtitlesccreen");
Layer_Background.Add(new Graphic(_Core, tex));
Layer_Game.Add(_StartCollider = new Rectangle(_Core, new Vector2f(355, 80), Color.Green)
{
Alpha = .2f,
Position = new(781, 498),
Visible = false
});
Layer_Game.Add(_ExitCollider = new Rectangle(_Core, new Vector2f(190, 80), Color.Red)
{
Alpha = .2f,
Position = new(862, 682),
Visible = false
});
Layer_Game.Add(_CredCollider = new Rectangle(_Core, new Vector2f(245, 70), Color.Yellow)
{
Alpha = .2f,
Position = new(838, 870),
Visible = false
});
tex = TextureLoader.Load("credits");
Layer_Overlay.Add(_Credits = new Graphic(_Core, tex)
{
Position = GameManager.FullHD / 2 - tex.Size.ToVector2f() / 2,
Visible = false
});
Layer_Game.Add(_Selection = new Rectangle(_Core, new Vector2f(400, 10), Color.Cyan)
{
Alpha = .25f,
});
GameManager.Sfx.Play("Wind Atmo");
return true;
}
protected override void Update(float deltaT)
{
if (_StartCollider.CollidesWith(GameManager.MapToCoords(Input.MousePosition, GameManager.View)))
{
if (_Selection.Visible == false) GameManager.Sfx.Play("Extra");
_Selection.Visible = true;
_Selection.Position = new Vector2f(GameManager.FullHD.X/2-_Selection.Size.X/2,
_StartCollider.Position.Y+_StartCollider.Size.Y);
}
else if (_ExitCollider.CollidesWith(GameManager.MapToCoords(Input.MousePosition, GameManager.View)))
{
if (_Selection.Visible == false) GameManager.Sfx.Play("Extra");
_Selection.Visible = true;
_Selection.Position = new Vector2f(GameManager.FullHD.X / 2 - _Selection.Size.X/2,
_ExitCollider.Position.Y + _StartCollider.Size.Y);
}
else if (_CredCollider.CollidesWith(GameManager.MapToCoords(Input.MousePosition, GameManager.View)))
{
if (_Selection.Visible == false) GameManager.Sfx.Play("Extra");
_Selection.Visible = true;
_Selection.Position = new Vector2f(GameManager.FullHD.X / 2 - _Selection.Size.X/2,
_CredCollider.Position.Y + _StartCollider.Size.Y);
}
else _Selection.Visible = false;
if (Input.IsMButtonDown(SFML.Window.Mouse.Button.Left) && !_InputLock)
{
if (_Credits.Visible)
{
GameManager.PlayRandom("Bonus ", 3);
_Credits.Visible = false;
_InputLock = true;
_Core.AnimationManager.Wait(.65f, () => _InputLock = false);
}
else
{
if (_StartCollider.CollidesWith(GameManager.MapToCoords(Input.MousePosition, GameManager.View)))
{
GameManager.PlayRandom("Bonus ", 3);
GameManager.LoadNextLevel(true);
}
if (_ExitCollider.CollidesWith(GameManager.MapToCoords(Input.MousePosition, GameManager.View)))
{
GameManager.PlayRandom("Bonus ", 3);
_Core.Exit();
}
if (_CredCollider.CollidesWith(GameManager.MapToCoords(Input.MousePosition, GameManager.View)))
{
GameManager.PlayRandom("Bonus ", 3);
_Credits.Visible = true;
_InputLock = true;
_Core.AnimationManager.Wait(.65f, () => _InputLock = false);
}
}
}
if (GameManager.Input.IsJoystickButtonDown(0, 1)) GameManager.LoadNextLevel();
}
protected override void Destroy()
{
}
}
}