/
TitleScreen.cs
176 lines (161 loc) · 4.68 KB
/
TitleScreen.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
using System;
using System.Collections.Generic;
using Kawa.Json;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Kafe
{
class TitleBackground : DrawableGameComponent
{
private Texture2D sheet; //, backdrop;
//private int lineAnim, backdropAnim;
//private static int gridStart = 49;
public TitleBackground() : base(Kafe.Me)
{
sheet = Mix.GetTexture("menu.png");
//backdrop = Mix.GetTexture("menu_back.png");
Kafe.RetrowaveEffect.Parameters["iResolution"].SetValue(new Vector2(Kafe.ScreenWidth, Kafe.ScreenHeight));
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
Kafe.RetrowaveEffect.Parameters["iTime"].SetValue(gameTime.TotalGameTime.Ticks / 2000000f);
/* backdropAnim++;
if (backdropAnim >= backdrop.Width * 16)
backdropAnim = 0;
lineAnim++;
if (lineAnim == 64)
lineAnim = 0; */
}
public override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
var batch = Kafe.SpriteBatch;
batch.Begin(SpriteSortMode.Immediate, null, SamplerState.PointClamp, null, null, Kafe.RetrowaveEffect);
batch.Draw(sheet, new Rectangle(0, 0, Kafe.ScreenWidth, Kafe.ScreenHeight), null, Color.White, 0, Vector2.Zero, SpriteEffects.FlipVertically, 0);
/* var dst = new Rectangle(-(backdropAnim / 16), 0, backdrop.Width, Kafe.ScreenHeight);
batch.Draw(backdrop, dst, Color.White);
dst.Offset(backdrop.Width, 0);
batch.Draw(backdrop, dst, Color.White);
var src = new Rectangle(0, 0, 384, 49);
dst = new Rectangle(0, Kafe.ScreenHeight - gridStart, Kafe.ScreenWidth, gridStart);
batch.Draw(sheet, dst, src, Color.White);
src = new Rectangle(1, 50, 14, 14);
dst = new Rectangle(0, Kafe.ScreenHeight - gridStart + (lineAnim / 4), Kafe.ScreenWidth, 14);
for (var i = 0; i < 4; i++)
{
batch.Draw(sheet, dst, src, Color.White);
dst.Offset(0, 16);
}
*/
batch.End();
}
}
class TitleScreen : DrawableGameComponent
{
private Texture2D title, logo;
private int anim, selection;
private bool skipLogo;
private string[] captions = new[] { "SOLO GAME", "VERSUS GAME", "QUIT" };
public TitleScreen(bool skipLogo) : base(Kafe.Me)
{
title = Mix.GetTexture("title_logo.png");
logo = Mix.GetTexture("firrhna_logo.png");
selection = 0;
this.skipLogo = skipLogo;
if (skipLogo)
anim = 64;
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (gameTime.TotalGameTime.Seconds > 2 || skipLogo)
if (anim < 128)
anim++;
if (anim < 64)
return;
if (Input.Controls[0].TrgUp)
{
if (selection == 0)
selection = captions.Length;
selection--;
}
else if (Input.Controls[0].TrgDown)
{
selection++;
if (selection == captions.Length)
selection = 0;
}
else if (Input.WasJustReleased(Keys.Escape))
{
Input.Flush();
if (selection < 2)
selection = 2;
else
Kafe.AskToQuit();
}
else if (Input.WasJustReleased(Keys.Enter) || Input.Controls[0].TrgA)
{
Input.Flush();
switch (selection)
{
case 0: //Story Mode
Kafe.DoTransition(false, () =>
{
Kafe.Me.Components.Remove(this);
LoadingScreen.Start(() =>
{
var charSelect = new CharacterSelect(false) { Enabled = false };
Kafe.Me.Components.Add(charSelect);
Kafe.DoTransition(true, () => { charSelect.Enabled = true; });
});
});
break;
case 1: //Versus Mode
Kafe.DoTransition(false, () =>
{
Kafe.Me.Components.Remove(this);
LoadingScreen.Start(() =>
{
var charSelect = new CharacterSelect(true) { Enabled = false };
Kafe.Me.Components.Add(charSelect);
Kafe.DoTransition(true, () => { charSelect.Enabled = true; });
});
});
break;
case 2: //Quit
Kafe.AskToQuit();
break;
}
}
}
public override void Draw(GameTime gameTime)
{
var batch = Kafe.SpriteBatch;
if (gameTime.TotalGameTime.Seconds < 2)
{
batch.Begin();
batch.Draw(logo, Vector2.Zero, Color.White);
batch.End();
return;
}
base.Draw(gameTime);
batch.Begin();
var dst = new Vector2(Kafe.ScreenWidth / 2, Kafe.ScreenHeight / 2);
var center = new Vector2(title.Width / 2, title.Height / 2);
batch.Draw(title, dst, null, Color.White, 0.0f, center, (anim < 32) ? anim / 32f : 1f, SpriteEffects.None, 0);
if (anim >= 64)
{
const int left = Kafe.ScreenWidth / 2;
var top = 160;
for (var i = 0; i < captions.Length; i++)
{
Text.DrawEx(batch, 1, captions[i], left, top, Alignment.Center, 0, (i == selection) ? Color.White : Color.Gray);
top += 20;
}
}
batch.End();
}
}
}