-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainWindow.xaml.cs
460 lines (396 loc) · 21.9 KB
/
MainWindow.xaml.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MiniVerse
{
/// <summary>
/// Lógica de interacción para MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private int tematica = 1; //TEMATICA: 1=UNIVERSO, 2=DRAGONBALL, 3=PACMAN, 4=MARIOBROS
SoundPlayer musica = new SoundPlayer();
public MainWindow()
{
InitializeComponent();
musica.SoundLocation = Directory.GetCurrentDirectory() + "\\music\\Universo.wav";
musica.Play();
}
private void moverPersonaje(object sender, KeyEventArgs e)
{
int left = (int)imgPersonaje.Margin.Left;
int up = (int)imgPersonaje.Margin.Top;
int right = (int)imgPersonaje.Margin.Right;
int down = (int)imgPersonaje.Margin.Bottom;
int velocidad = 15;
switch (e.Key)
{
case Key.Left:
if (left - velocidad * 0.5 > 0)
imgPersonaje.Margin = new Thickness(left - velocidad, up, right + velocidad, down);
break;
case Key.Up:
if (up + velocidad * 1.5 > 0)
imgPersonaje.Margin = new Thickness(left, up - velocidad, right, down + velocidad);
break;
case Key.Right:
if (right - velocidad * 0.5 > 0)
imgPersonaje.Margin = new Thickness(left + velocidad, up, right - velocidad, down);
break;
case Key.Down:
if (down + velocidad * 1.5 > 0)
imgPersonaje.Margin = new Thickness(left, up + velocidad, right, down - velocidad);
break;
}
visitarPlanetas(left + 75, up + 75, right + 75, down + 75);
}
private void visitarPlanetas(int left, int up, int right, int down)
{
int pointsToWin = new Random().Next(3) + 2;
int pointsToWinSpecial = new Random().Next(6) + 5;
//PLANETA VENUS
if (left > 120 && right > 960 && up > 40 && down > 340)
{
MessageBoxResult resultado;
if (tematica == 1)
{
resultado = MessageBox.Show("¿Quieres jugar en Venus y conseguir " + pointsToWin.ToString() + " puntos por descubrir su inédita atmosfera?", "Bienvenido a Venus", MessageBoxButton.YesNo);
}
else if (tematica == 2)
{
resultado = MessageBox.Show("Hola, soy Goku ¿Me ayudas con este minijuego?\nSi lo haces, ganarás " + pointsToWin.ToString() + " puntos!", "Mensaje de Goku", MessageBoxButton.YesNo);
}
else if (tematica == 3)
{
resultado = MessageBox.Show("Escapa del fantasma azul y el señor PacMan te regalará " + pointsToWin.ToString() + " PacPoints.", "Fantasma azul", MessageBoxButton.YesNo);
}
else
{
resultado = MessageBox.Show("¿Quieres probar la seta gigante?\nMario te regalará " + pointsToWin.ToString() + " puntos si le ayudas a superar este reto.", "Champinión rojo", MessageBoxButton.YesNo);
}
switch (resultado)
{
case MessageBoxResult.Yes:
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine("cd .. && cd .. && cd games && cd game1 && python3 game1.py");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
check();
pbPuntos.Value = pbPuntos.Value + pointsToWin;
checkPB();
break;
case MessageBoxResult.No:
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
}
}
// PLANETA TIERRA
else if (left > 545 && right > 545 && up > 20 && down > 370)
{
MessageBoxResult resultado;
if (tematica == 1)
{
resultado = MessageBox.Show("¿Quieres jugar en la Tierra y conseguir " + pointsToWin.ToString() + " puntos por descubrir su naturaleza sorprendente?", "Bienvenido a La Tierra", MessageBoxButton.YesNo);
}
else if (tematica == 2)
{
resultado = MessageBox.Show("¿Quieres ayudar a BuBu?\nSi lo haces, ganarás " + pointsToWin.ToString() + " puntos!", "Saludos de BuBu", MessageBoxButton.YesNo);
}
else if (tematica == 3)
{
resultado = MessageBox.Show("Escapa del fantasma amarillo y el señor PacMan te regalará " + pointsToWin.ToString() + " PacPoints.", "Fantasma amarillo", MessageBoxButton.YesNo);
}
else
{
resultado = MessageBox.Show("Como te descuides el fantasma te comerá, ¡juega para escapar!", "Fantasma comilón", MessageBoxButton.YesNo);
}
switch (resultado)
{
case MessageBoxResult.Yes:
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine("cd .. && cd .. && cd games && cd game2 && python3 game2.py");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
check();
pbPuntos.Value = pbPuntos.Value + pointsToWin;
checkPB();
break;
case MessageBoxResult.No:
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
}
}
//PLANETA MARTE
else if (left > 70 && right > 1020 && up > 345 && down > 40)
{
MessageBoxResult resultado;
if (tematica == 1)
{
resultado = MessageBox.Show("¿Quieres jugar en Marte y conseguir " + pointsToWin.ToString() + " puntos por descubrir sus paisajes rojizos?", "Bienvenido a Marte", MessageBoxButton.YesNo);
}
else if (tematica == 2)
{
resultado = MessageBox.Show("¿Quieres ayudar a Krilin?\nSi lo haces, ganarás " + pointsToWin.ToString() + " puntos!", "Saludos de Krilin", MessageBoxButton.YesNo);
}
else if (tematica == 3)
{
resultado = MessageBox.Show("¿Quieres ganar puntos con las cerezas? \nMr. PacMan te regalará " + pointsToWin.ToString() + " PacPoints.", "Las cerezas de PacMan", MessageBoxButton.YesNo);
}
else
{
resultado = MessageBox.Show("¿Quieres ganar puntos con las monedas de Mario? \nMario te regalará " + pointsToWin.ToString() + " puntos si le ayudas a superar este reto.", "Mario Coins", MessageBoxButton.YesNo);
}
switch (resultado)
{
case MessageBoxResult.Yes:
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine("cd .. && cd .. && cd games && cd game3 && python3 game3.py");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
check();
pbPuntos.Value = pbPuntos.Value + pointsToWin;
checkPB();
break;
case MessageBoxResult.No:
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
}
}
//PLANETA *ESPECIAL* URANO
else if (left > 1000 && right > 80 && up > 40 && down > 350 && imgJuego4.Visibility == Visibility.Visible)
{
MessageBoxResult resultado;
if (tematica == 1)
{
resultado = MessageBox.Show("¿Quieres jugar en Urano y conseguir " + pointsToWinSpecial.ToString() + " puntos por descubrir sus anillos gigantes?", "Bienvenido a Urano", MessageBoxButton.YesNo);
}
else if (tematica == 2)
{
resultado = MessageBox.Show("¿Quieres ayudar a Goku Super Sayan?\nSi lo haces, ganarás " + pointsToWinSpecial.ToString() + " puntos!", "Saludos de Goku Super Sayan", MessageBoxButton.YesNo);
}
else if (tematica == 3)
{
resultado = MessageBox.Show("¿Quieres ganar puntos con la fresa? \nMr. PacMan te regalará " + pointsToWinSpecial.ToString() + " PacPoints.", "La fresa de PacMan", MessageBoxButton.YesNo);
}
else
{
resultado = MessageBox.Show("¿Quieres probar el superpoder misterioso\nMario te regalará " + pointsToWinSpecial.ToString() + " puntos si le ayudas a superar este reto.", "Super Power UP", MessageBoxButton.YesNo);
}
switch (resultado)
{
case MessageBoxResult.Yes:
//Se crea el proceso
Process cmd = new Process();
cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
switch (tematica)
{
//JUEGO ESPECIAL UNIVERSO
case 1:
cmd.StandardInput.WriteLine("cd .. && cd .. && cd games && cd game4 && cd game4Universo && python3 SpaceInvaders.py");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
//JUEGO ESPECIAL DRAGON BALL
case 2:
cmd.StandardInput.WriteLine("cd .. && cd .. && cd games && cd game4 && cd game4DB && python3 Goku.py");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
//JUEGO ESPECIAL PACMAN
case 3:
cmd.StandardInput.WriteLine("cd .. && cd .. && cd games && cd game4 && cd game4PM && python3 PacMan.py");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
//JUEGO ESPECIAL MARIO BROS
case 4:
cmd.StandardInput.WriteLine("cd .. && cd .. && cd games && cd game4 && cd game4MB && python3 main.py");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
}
pbPuntos.Value = pbPuntos.Value + pointsToWinSpecial;
checkPB();
break;
case MessageBoxResult.No:
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
}
}
//SALIDA
else if (left > 1050 && right > 10 && up > 350 && down > 10)
{
MessageBoxResult resultado = MessageBox.Show("¿Ya te quieres ir?", "Salida", MessageBoxButton.YesNo);
switch (resultado)
{
case MessageBoxResult.Yes:
App.Current.Shutdown();
break;
case MessageBoxResult.No:
imgPersonaje.Margin = new Thickness(568, 308, 555, 112);
break;
}
}
//LOBBY
else { }
}
//CHECKEAR JUEGO ESPECIAL
private void check()
{
if (imgJuego4.Visibility == Visibility.Hidden)
{
switch (tematica)
{
//JUEGO ESPECIAL UNIVERSO
case 1:
MessageBox.Show("¡¡ ENHORABUENA !!\nHas desbloqueado un planeta oculto.", "MiniVerse", MessageBoxButton.OK);
break;
//JUEGO ESPECIAL DRAGON BALL
case 2:
MessageBox.Show("¡¡ ENHORABUENA !!\nHas desbloqueado un personaje oculto.", "MiniVerse", MessageBoxButton.OK);
break;
//JUEGO ESPECIAL PACMAN
case 3:
MessageBox.Show("¡¡ ENHORABUENA !!\nHas desbloqueado un juego oculto.", "MiniVerse", MessageBoxButton.OK);
break;
//JUEGO ESPECIAL MARIO BROS
case 4:
MessageBox.Show("¡¡ ENHORABUENA !!\nHas desbloqueado un objeto oculto.", "MiniVerse", MessageBoxButton.OK);
break;
}
imgJuego4.Visibility = Visibility.Visible;
}
}
private void checkPB()
{
if (pbPuntos.Value >= 100)
{
MessageBox.Show("¡¡ ENHORABUENA !!\nHas conseguido la máxima puntuación.", "MiniVerse", MessageBoxButton.OK);
pbPuntos.Foreground = Brushes.LightSkyBlue;
//pbPuntos.Foreground = Brushes.Cyan;
txtPuntuacion.Text = "JUEGO COMPLETADO";
}
}
/*-------------------------------------- RECURSOS DE TEMATICAS -----------------------------------------*/
private void tematicaUniverso(object sender, RoutedEventArgs e)
{
tematica = 1;
string rutaImagen = "images/Universo/";
this.imgLogo.Source = new BitmapImage(new Uri(rutaImagen + "logoUniverso.png", UriKind.Relative));
this.imgFondo.Source = new BitmapImage(new Uri(rutaImagen + "fondoUniverso.png", UriKind.Relative));
this.imgPersonaje.Source = new BitmapImage(new Uri(rutaImagen + "naveUniverso.png", UriKind.Relative));
this.imgJuego1.Source = new BitmapImage(new Uri(rutaImagen + "venus.png", UriKind.Relative));
this.imgJuego2.Source = new BitmapImage(new Uri(rutaImagen + "marte.png", UriKind.Relative));
this.imgJuego3.Source = new BitmapImage(new Uri(rutaImagen + "tierra.png", UriKind.Relative));
this.imgJuego4.Source = new BitmapImage(new Uri(rutaImagen + "urano.png", UriKind.Relative));
this.imgBanner.Source = new BitmapImage(new Uri(rutaImagen + "bannerUniverso.jpg", UriKind.Relative));
this.imgSalir.Source = new BitmapImage(new Uri(rutaImagen + "salidaUniverso.png", UriKind.Relative));
this.imgJuego4.Visibility = Visibility.Hidden;
musica.SoundLocation = Directory.GetCurrentDirectory() + "\\music\\Universo.wav";
musica.Play();
}
private void tematicaDragonBall(object sender, RoutedEventArgs e)
{
tematica = 2;
string rutaImagen = "images/DragonBall/";
this.imgLogo.Source = new BitmapImage(new Uri(rutaImagen + "logoDragonBall.png", UriKind.Relative));
this.imgFondo.Source = new BitmapImage(new Uri(rutaImagen + "fondoDragonBall.png", UriKind.Relative));
this.imgPersonaje.Source = new BitmapImage(new Uri(rutaImagen + "naveDragonBall.png", UriKind.Relative));
this.imgJuego1.Source = new BitmapImage(new Uri(rutaImagen + "juego1DragonBall.png", UriKind.Relative));
this.imgJuego2.Source = new BitmapImage(new Uri(rutaImagen + "juego2DragonBall.png", UriKind.Relative));
this.imgJuego3.Source = new BitmapImage(new Uri(rutaImagen + "juego3DragonBall.png", UriKind.Relative));
this.imgJuego4.Source = new BitmapImage(new Uri(rutaImagen + "juego4DragonBall.png", UriKind.Relative));
this.imgBanner.Source = new BitmapImage(new Uri(rutaImagen + "bannerDragonBall.jpg", UriKind.Relative));
this.imgSalir.Source = new BitmapImage(new Uri(rutaImagen + "salidaDragonBall.png", UriKind.Relative));
this.imgJuego4.Visibility = Visibility.Hidden;
musica.SoundLocation = Directory.GetCurrentDirectory() + "\\music\\DragonBall.wav";
musica.Play();
}
private void tematicaPacMan(object sender, RoutedEventArgs e)
{
tematica = 3;
string rutaImagen = "images/PacMan/";
this.imgLogo.Source = new BitmapImage(new Uri(rutaImagen + "logoPacMan.png", UriKind.Relative));
this.imgFondo.Source = new BitmapImage(new Uri(rutaImagen + "fondoPacMan.png", UriKind.Relative));
this.imgPersonaje.Source = new BitmapImage(new Uri(rutaImagen + "navePacMan.png", UriKind.Relative));
this.imgJuego1.Source = new BitmapImage(new Uri(rutaImagen + "juego1PacMan.png", UriKind.Relative));
this.imgJuego2.Source = new BitmapImage(new Uri(rutaImagen + "juego2PacMan.png", UriKind.Relative));
this.imgJuego3.Source = new BitmapImage(new Uri(rutaImagen + "juego3PacMan.png", UriKind.Relative));
this.imgJuego4.Source = new BitmapImage(new Uri(rutaImagen + "juego4PacMan.png", UriKind.Relative));
this.imgBanner.Source = new BitmapImage(new Uri(rutaImagen + "bannerPacMan.png", UriKind.Relative));
this.imgSalir.Source = new BitmapImage(new Uri(rutaImagen + "salidaPacMan.png", UriKind.Relative));
this.imgJuego4.Visibility = Visibility.Hidden;
musica.SoundLocation = Directory.GetCurrentDirectory() + "\\music\\PacMan.wav";
musica.Play();
}
private void tematicaMarioBros(object sender, RoutedEventArgs e)
{
tematica = 4;
string rutaImagen = "images/MarioBros/";
this.imgLogo.Source = new BitmapImage(new Uri(rutaImagen + "logoMarioBros.png", UriKind.Relative));
this.imgFondo.Source = new BitmapImage(new Uri(rutaImagen + "fondoMarioBros.png", UriKind.Relative));
this.imgPersonaje.Source = new BitmapImage(new Uri(rutaImagen + "naveMarioBros.png", UriKind.Relative));
this.imgJuego1.Source = new BitmapImage(new Uri(rutaImagen + "juego1MarioBros.png", UriKind.Relative));
this.imgJuego2.Source = new BitmapImage(new Uri(rutaImagen + "juego2MarioBros.png", UriKind.Relative));
this.imgJuego3.Source = new BitmapImage(new Uri(rutaImagen + "juego3MarioBros.png", UriKind.Relative));
this.imgJuego4.Source = new BitmapImage(new Uri(rutaImagen + "juego4MarioBros.png", UriKind.Relative));
this.imgBanner.Source = new BitmapImage(new Uri(rutaImagen + "bannerMarioBros.jpg", UriKind.Relative));
this.imgSalir.Source = new BitmapImage(new Uri(rutaImagen + "salidaMarioBros.png", UriKind.Relative));
this.imgJuego4.Visibility = Visibility.Hidden;
musica.SoundLocation = Directory.GetCurrentDirectory() + "\\music\\MarioBros.wav";
musica.Play();
}
}
}