-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEjemploAlumno.cs
More file actions
1586 lines (1412 loc) · 76.1 KB
/
Copy pathEjemploAlumno.cs
File metadata and controls
1586 lines (1412 loc) · 76.1 KB
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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Text;
using TgcViewer.Example;
using TgcViewer;
using Microsoft.DirectX.Direct3D;
using System.Drawing;
using Microsoft.DirectX;
using TgcViewer.Utils.TgcSceneLoader;
using TgcViewer.Utils.TgcGeometry;
using TgcViewer.Utils._2D;
using TgcViewer.Utils.TgcSkeletalAnimation;
using TgcViewer.Utils.Sound;
using System.Linq;
using System.Windows.Forms;
using TgcViewer.Utils;
using TgcViewer.Utils.Shaders;
using TgcViewer.Utils.Interpolation;
namespace AlumnoEjemplos.GODMODE
{
#region Descripcion Ejemplo
/// <summary>
/// Ejemplo del alumno
/// </summary>
public class EjemploAlumno : TgcExample
{ ///Configuraciones del Tgc-Viewer
///Configuraciones del Ejemplo
/// <summary>
/// Categoría a la que pertenece el ejemplo.
/// Influye en donde se va a haber en el árbol de la derecha de la pantalla.
/// </summary>
public override string getCategory()
{
return "AlumnoEjemplos";
}
/// <summary>
/// Completar nombre del grupo en formato Grupo NN
/// </summary>
public override string getName()
{
return "Grupo GODMODE";
}
/// <summary>
/// Completar con la descripción del TP
/// </summary>
public override string getDescription()
{
return "Survival Horror";
}
#endregion
#region Variables Globales
TgcScene tgcScene; // Crea la escena
List<TgcBoundingBox> objetosColisionables; //Lista de esferas colisionables
List<TgcBoundingBox> objetosColisionablesCambiantes; //Lista de objetos que se calcula cada vez
List<TgcBoundingBox> todosObjetosColisionables;
List<TgcMesh> todosLosMeshesIluminables;
List<TgcMesh> meshesParaNightVision;
Camara camara;
TgcBoundingSphere esferaCamara; //Esfera que rodea a la camara
TgcScene linterna, vela, farol;
List<TgcMesh> meshesExtra; //Otros meshes para iluminar
TgcMesh meshLinterna, meshVela, meshFarol;
Luz miLuz; //Instancia de clase luz para la iluminacion de la linterna
float temblorLuz;
int ObjetoIluminacion; //0 linterna 1 farol 2 vela
float tiempo;
float tiempoIluminacion;
Puerta puerta1, puerta2, puerta3, puerta4, puerta5, puerta6, puerta7;
List<Puerta> puertas;
public static Boolean esperandoPuerta; //si esta en true no se mueve
TgcSprite bateria, titulo, mancha, instrucciones,spriteLocker,spriteObjetivos;
TgcSkeletalMesh meshEnemigo;
Enemigo enemigo;
bool mostrarInstrucciones;
TgcRay rayo; //Rayo que conecta al enemigo con el jugador
int contadorDetecciones;
bool perdido;
Vector3 direccionRayo;
Vector3 lastKnownPos;
string animacionSeleccionada;
float tiempoBuscando;
bool enemigoActivo;
bool enWaypoints;
bool enLocker;
List<Tgc3dSound> sonidos;
Tgc3dSound sonidoEnemigo;
TgcStaticSound sonidoPilas, sonidoObjeto, sonidoPuertas, sonidoGrito, sonidoJadeo;
Recarga[] recargas;
Objetivo copa, espada, locket, llave;
int iteracion;
Boolean enMenu;
Boolean gameOver;
Boolean ganado;
TgcText2d textoEmpezarJuego;
TgcText2d textoDescripcion;
TgcText2d textoGameOver;
TgcText2d textoSpace;
TgcText2d textoGanador;
List<Locker> listaLockers;
Locker locker1, locker2, locker3, locker4, locker5;
bool enemigoEsperandoPuerta;
Effect effect,efectoMiedo;
/*NightVision*/
Surface g_pDepthStencil; // Depth-stencil buffer
Texture g_pRenderTarget, g_pGlowMap, g_pRenderTarget4, g_pRenderTarget4Aux;
VertexBuffer g_pVBV3D;
int cant_pasadas;
Boolean conNightVision;
/*Miedo*/
VertexBuffer screenQuadVB;
Texture renderTarget2D;
Surface pOldRT;
TgcTexture alarmTexture;
InterpoladorVaiven intVaivenAlarm;
bool cameraCorrection; //Propiedad que marca si necesita corregirse la camara
float tiempoRestanteCorrer = TIEMPO_LIMITE_CORRER;
#endregion
string alumnoMediaFolder;
const int VELOCIDAD_ENEMIGO = 95;
const int VELOCIDAD_PATRULLA = 75;
const float POSICION_INICIAL_ENEMIGO_X = 2135.981f;
const float POSICION_INICIAL_ENEMIGO_Z = -780.9791f;
const float TIEMPO_DE_BUSQUEDA = 15;
const int DELAY_FRAMES_DETECCION = 4;
const float VELOCIDAD_JUGADOR_CAMINAR = 100f;
const float VELOCIDAD_JUGADOR_CORRER = 150f;
const float VELOCIDAD_ROTACION_CAMARA = 2f;
const float TIEMPO_LIMITE_CORRER = 3f;
public override void init()
{
#region Inicializaciones
enMenu = true;
objetosColisionables = new List<TgcBoundingBox>(); //Lista de esferas colisionables
objetosColisionablesCambiantes = new List<TgcBoundingBox>(); //Lista de objetos que se calcula cada vez
todosObjetosColisionables = new List<TgcBoundingBox>();
todosLosMeshesIluminables = new List<TgcMesh>();
meshesParaNightVision = new List<TgcMesh>();
meshesExtra = new List<TgcMesh>();
miLuz = new Luz();
enemigo = new Enemigo();
mostrarInstrucciones = false;
rayo = new TgcRay();
GuiController.Instance.CustomRenderEnabled = true;
contadorDetecciones = 0;
perdido = true;
direccionRayo = new Vector3();
lastKnownPos = new Vector3();
enemigoActivo = true;
enWaypoints = true;
tiempoRestanteCorrer = TIEMPO_LIMITE_CORRER;
enLocker = false;
iteracion = 0;
enMenu = true;
gameOver = false;
ganado = false;
enemigoEsperandoPuerta = false;
cant_pasadas = 3;
conNightVision = false;
#endregion
#region Menu
Size screenSize = GuiController.Instance.Panel3d.Size;
GuiController.Instance.BackgroundColor = Color.Black;
textoEmpezarJuego = new TgcText2d();
textoEmpezarJuego.Text = "Presione Space para comenzar";
textoEmpezarJuego.Color = Color.Maroon;
textoEmpezarJuego.Align = TgcText2d.TextAlign.CENTER;
textoEmpezarJuego.changeFont(new System.Drawing.Font("TimesNewRoman", 25, FontStyle.Bold));
//textoEmpezarJuego.Size = new Size(500, 120);
textoEmpezarJuego.Size = new Size((int)FastMath.Ceiling(screenSize.Width * 0.52f), (int)FastMath.Ceiling(screenSize.Height * 0.24f));
textoEmpezarJuego.Position = new Point(FastMath.Max(screenSize.Width / 2 - textoEmpezarJuego.Size.Width / 2, 0), (int)FastMath.Max(screenSize.Height / 2 + textoEmpezarJuego.Size.Height / 0.8f, 0));
textoDescripcion = new TgcText2d();
textoDescripcion.Text = " El objetivo del juego es encontrar los tres objetos malditos distribuídos por los distintos sectores del mapa. Sólo así se podrá atravesar la puerta final, en busca del objeto más preciado. Pero cuidado, habrá varios obstáculos en tu camino que deberás superar. Presiona H para ver la ayuda.";
textoDescripcion.changeFont(new System.Drawing.Font("TimesNewRoman", 13, FontStyle.Bold));
textoDescripcion.Color = Color.Gray;
textoDescripcion.Align = TgcText2d.TextAlign.LEFT;
textoDescripcion.Size = new Size(screenSize.Width - (int)FastMath.Ceiling(screenSize.Width * 0.21f), screenSize.Height / 2);
textoDescripcion.Position = new Point(screenSize.Width / 8, screenSize.Height / 2);
textoGameOver = new TgcText2d();
textoGameOver.Text = "GAME OVER";
textoGameOver.Color = Color.Red;
textoGameOver.Align = TgcText2d.TextAlign.CENTER;
textoGameOver.changeFont(new System.Drawing.Font("TimesNewRoman", screenSize.Width*screenSize.Height* 0.000122f, FontStyle.Bold));
textoGameOver.Size = new Size((int)FastMath.Ceiling(screenSize.Width * 0.52f), (int)FastMath.Ceiling(screenSize.Height * 0.39f));
textoGameOver.Position = new Point(FastMath.Max(screenSize.Width / 2 - textoEmpezarJuego.Size.Width / 2, 0), (int)FastMath.Max(screenSize.Height / 2 - textoEmpezarJuego.Size.Height / 6f, 0));
textoGanador = new TgcText2d();
textoGanador.Text = "Felicitaciones, Ganaste";
textoGanador.Color = Color.Green;
textoGanador.Align = TgcText2d.TextAlign.CENTER;
textoGanador.changeFont(new System.Drawing.Font("TimesNewRoman", screenSize.Width * screenSize.Height * 0.000102f, FontStyle.Bold));
textoGanador.Size = new Size((int)FastMath.Ceiling(screenSize.Width * 0.52f), (int)FastMath.Ceiling(screenSize.Height * 0.39f));
textoGanador.Position = new Point(FastMath.Max(screenSize.Width / 2 - textoEmpezarJuego.Size.Width / 2, 0), FastMath.Max(screenSize.Height / 2 - textoEmpezarJuego.Size.Height / 2, 0));
textoSpace = new TgcText2d();
textoSpace.Text = "Presione Space para Volver al menu";
textoSpace.Color = Color.White;
textoSpace.Align = TgcText2d.TextAlign.LEFT;
textoSpace.Size = new Size(screenSize.Width - (int)FastMath.Ceiling(screenSize.Width * 0.21f), screenSize.Height / 2);
textoSpace.Position = new Point(screenSize.Width / 8, screenSize.Height / 2 + textoGameOver.Size.Height);
mancha = new TgcSprite();
mancha.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\mancha1.png");
screenSize = GuiController.Instance.Panel3d.Size;
Size textureSize = mancha.Texture.Size;
mancha.Scaling = new Vector2(screenSize.Width* 0.00062f, screenSize.Height * 0.0012f);
mancha.Position = new Vector2(FastMath.Max(screenSize.Width / 4 - textureSize.Width / 4, 0), FastMath.Max(screenSize.Height / 2 - textureSize.Height / 4f, 0));
titulo = new TgcSprite();
titulo.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\titulo.png");
screenSize = GuiController.Instance.Panel3d.Size;
textureSize = titulo.Texture.Size;
titulo.Scaling = new Vector2(screenSize.Width * 0.00073f, screenSize.Height * 0.0014f);
titulo.Position = new Vector2(FastMath.Max(screenSize.Width / 2 - textureSize.Width * 0.7f / 2, 0), FastMath.Max(screenSize.Height / 3 - textureSize.Height / 2.2f, 0));
instrucciones = new TgcSprite();
instrucciones.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\instrucciones.png");
screenSize = GuiController.Instance.Panel3d.Size;
textureSize = instrucciones.Texture.Size;
instrucciones.Scaling = new Vector2(screenSize.Width * 0.001f, screenSize.Height * 0.002f);
instrucciones.Position = new Vector2(FastMath.Max(screenSize.Width / 2 - (screenSize.Width * 0.001f*textureSize.Width) / 2, 0), FastMath.Max(screenSize.Height / 2 - (screenSize.Height * 0.002f*textureSize.Height) / 2, 0));
#endregion
tiempoBuscando = TIEMPO_DE_BUSQUEDA;
esperandoPuerta = false;
GuiController.Instance.FullScreenEnable = true; //Pantalla Completa
//GuiController.Instance: acceso principal a todas las herramientas del Framework
GuiController.Instance.UserVars.addVar("enLocker");
//Device de DirectX para crear primitivas
Device d3dDevice = GuiController.Instance.D3dDevice;
ObjetoIluminacion = 0;
//Carpeta de archivos Media del alumno
alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosDir;
#region Carga de la Escena
TgcSceneLoader loader = new TgcSceneLoader(); //TgcsceneLoader para cargar el escenario
tgcScene = loader.loadSceneFromFile( //Carga el escenario
alumnoMediaFolder + "GODMODE\\Media\\mapaCentrado-TgcScene.xml",
alumnoMediaFolder + "GODMODE\\Media\\");
#endregion
#region Inicializacion de Recargas
recargas = new Recarga[4];
recargas[0] = new Recarga(alumnoMediaFolder, new Vector3(-1508f, 20f, 107f));
recargas[1] = new Recarga(alumnoMediaFolder, new Vector3(-1430.953f, 20f, 966.6811f));
recargas[2] = new Recarga(alumnoMediaFolder, new Vector3(1100f, 20f, -850f));
recargas[3] = new Recarga(alumnoMediaFolder, new Vector3(800f, 20f, 539f));
tiempo = 0;
tiempoIluminacion = 80;
#endregion
#region Carga de Mesh para Enemigo
string pathMesh = alumnoMediaFolder + "GODMODE\\Media\\BasicHuman\\BasicHuman-TgcSkeletalMesh.xml";
string mediaPath = alumnoMediaFolder + "GODMODE\\Media\\BasicHuman\\";
TgcSkeletalLoader enemigos = new TgcSkeletalLoader();
string[] animaciones = { "Walk" };
animacionSeleccionada = animaciones[0];
for (int i = 0; i < animaciones.Length; i++)
{
animaciones[i] = mediaPath + "Animations\\" + animaciones[i] + "-TgcSkeletalAnim.xml";
}
meshEnemigo = enemigos.loadMeshAndAnimationsFromFile(pathMesh, mediaPath, animaciones);
meshEnemigo.playAnimation(animacionSeleccionada, true);
meshEnemigo.Position = new Vector3(POSICION_INICIAL_ENEMIGO_X, 0, POSICION_INICIAL_ENEMIGO_Z);
meshEnemigo.Scale = new Vector3(1.5f, 1.3f, 1.3f);
meshEnemigo.rotateY(FastMath.PI / 2);
enemigo.setMesh(meshEnemigo);
lastKnownPos = enemigo.getPosicion();
#endregion
#region Modifiers
//Modifiers de la luz
GuiController.Instance.Modifiers.addBoolean("lightEnable", "lightEnable", true);
GuiController.Instance.Modifiers.addVertex3f("posVista", new Vector3(-20f, 49f, -20f), new Vector3(20f, 51f, 20f), new Vector3(0, 50, 0));
//Modifiers para desplazamiento del personaje
GuiController.Instance.UserVars.addVar("posicion");
GuiController.Instance.UserVars.addVar("lookAt");
GuiController.Instance.UserVars.addVar("PosEnemigo", 0);
GuiController.Instance.UserVars.addVar("lastKnown", 0);
GuiController.Instance.UserVars.addVar("enWaypoints", 0);
GuiController.Instance.UserVars.addVar("perdido", perdido);
GuiController.Instance.UserVars.addVar("ancho_pantalla", screenSize.Width);
GuiController.Instance.UserVars.addVar("alto_pantalla", screenSize.Height);
GuiController.Instance.UserVars.addVar("poder", 0);
GuiController.Instance.Modifiers.addFloat("lightIntensity", 0, 10000, 4000);
GuiController.Instance.Modifiers.addFloat("lightAttenuation", 0, 500, 200);
GuiController.Instance.Modifiers.addVertex3f("posicionS", new Vector3(-300, 0, -50), new Vector3(300, 100, 500), new Vector3(-140, 50, 246.74f));
miLuz.posicionesDeLuces[0] = new Vector3(240, 60, 145.5f);
miLuz.posicionesDeLuces[1] = new Vector3(-260, 60, -133.2f);
miLuz.posicionesDeLuces[2] = new Vector3(997, 60, -645);
miLuz.posicionesDeLuces[3] = new Vector3(-1314, 60, 1077);
/* GuiController.Instance.Modifiers.addVertex3f("posPuerta", new Vector3(-151f, 1f, 549.04f), new Vector3(-11f, 1f, 749.04f), new Vector3(-51f, 1f, 649.04f));
GuiController.Instance.Modifiers.addVertex3f("escaladoPuerta", new Vector3(-5f, -52.15f, -51f), new Vector3(10f, 52.15f, 51f), new Vector3(4.1f, 2.15f, 1f));*/
#endregion
#region Configuracion de camara
//Camara
GuiController.Instance.FpsCamera.Enable = false;
GuiController.Instance.RotCamera.Enable = false;
camara = new Camara();
//camara.setCamera(new Vector3(1f, 50f, 1f), new Vector3(1.9996f, 50f, 0.9754f)); Posicion original
// camara.setCamera(new Vector3(1710f, 50f, -269f), new Vector3(1.9996f, 50f, 0.9754f)); //cerca del final
Camara.movimiento = new Vector3(0f, 0f, 0f);
Camara.moving = false;
camara.setCamera(new Vector3(0f, 50f, 0f), new Vector3(-1f, 49.95f, -1f));// Inicia camara en posicion de conflicto
camara.MovementSpeed = VELOCIDAD_JUGADOR_CAMINAR;
camara.RotationSpeed = VELOCIDAD_ROTACION_CAMARA;
camara.JumpSpeed = 30f;
camara.init();
#endregion
#region Lockers
spriteLocker = new TgcSprite();
spriteLocker.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\spriteLocker.png");
screenSize = GuiController.Instance.Panel3d.Size;
textureSize = spriteLocker.Texture.Size;
spriteLocker.Scaling = new Vector2(screenSize.Width*0.001f, screenSize.Height*0.002f);
spriteLocker.Position = new Vector2(-screenSize.Width / 1.9f, -screenSize.Height / 3f);
//spriteLocker.Position = new Vector2(FastMath.Max(screenSize.Width / 2 -textureSize.Width/5, 0), FastMath.Max(screenSize.Height /2 - textureSize.Width/4 , 0));
listaLockers = new List<Locker>();
locker1 = new Locker(alumnoMediaFolder, new Vector3(214f, 0, -240f), new Vector3(0.4f, 0.17f, 0.4f));
locker1.posVista = new Vector3(193.7315f, 50f, -189.9574f);
locker1.lookAt = new Vector3(193.675f, 50f, -189.4574f);
listaLockers.Add(locker1);
locker2 = new Locker(alumnoMediaFolder, new Vector3(805f, 0, -890f), new Vector3(0.4f, 0.17f, 0.4f));
locker2.posVista = new Vector3(823.6697f, 50f, -829.9934f);
locker2.lookAt = new Vector3(823.8191f, 49.97f, -829.4934f);
listaLockers.Add(locker2);
locker3 = new Locker(alumnoMediaFolder, new Vector3(-1170.824f, 0, 940f), new Vector3(0.4f, 0.17f, 0.4f));
locker3.posVista = new Vector3(-1161.415f, 50f, 980.6960f);
locker3.lookAt = new Vector3(-1161.45f, 50f, 981.1906f);
listaLockers.Add(locker3);
locker4 = new Locker(alumnoMediaFolder, new Vector3(-5f, 0, -929f), new Vector3(0.4f, 0.17f, 0.4f));
locker4.posVista = new Vector3(-7.00997f, 50f, -762.6996f);
locker4.lookAt = new Vector3(-7.00255f, 50f, -762.1996f);
listaLockers.Add(locker4);
locker5 = new Locker(alumnoMediaFolder, new Vector3(-249f, 0, 664f), new Vector3(0.4f, 0.17f, 0.4f));
locker5.posVista = new Vector3(-229.3327f,50, 724.005f);
locker5.lookAt = new Vector3(-229.2234f, 50f, 724.505f);
listaLockers.Add(locker5);
#endregion
#region Control de Colisiones
objetosColisionables.Clear();
foreach (TgcMesh mesh in tgcScene.Meshes) //Agrega una caja a cada mesh que haya en la escena
{
objetosColisionables.Add(mesh.BoundingBox);
}
foreach(Locker locker in listaLockers)
{
objetosColisionables.Add(locker.mesh.BoundingBox);
}
esferaCamara = new TgcBoundingSphere(camara.getPosition(), 20f); //Crea la esfera de la camara en la posicion de la camara
#endregion
/* ACLARACION: para usar ListenerTracking es necesario pasar un mesh por parametro. Como la esfera del jugador no tiene, el envio
* del sonido se hace de esfera a enemigo; es decir, el ListenerTracking se hace sobre el enemigo.*/
#region Sonido
sonidos = new List<Tgc3dSound>();
sonidoEnemigo = new Tgc3dSound(alumnoMediaFolder + "GODMODE\\Media\\Sound\\pies, arrastrar.wav", esferaCamara.Position);
sonidoEnemigo.MinDistance = 10f;
sonidos.Add(sonidoEnemigo);
GuiController.Instance.DirectSound.ListenerTracking = enemigo.getMesh();
sonidoPilas = new TgcStaticSound();
sonidoPilas.loadSound(alumnoMediaFolder + "GODMODE\\Media\\Sound\\torno 3.wav");
sonidoObjeto = new TgcStaticSound();
sonidoObjeto.loadSound(alumnoMediaFolder + "GODMODE\\Media\\Sound\\supersónico cueva.wav");
sonidoPuertas = new TgcStaticSound();
sonidoPuertas.loadSound(alumnoMediaFolder + "GODMODE\\Media\\Sound\\pisada crujiente izda.wav");
sonidoGrito = new TgcStaticSound();
sonidoGrito.loadSound(alumnoMediaFolder + "GODMODE\\Media\\Sound\\monstruo, grito.wav");
sonidoJadeo = new TgcStaticSound();
sonidoJadeo.loadSound(alumnoMediaFolder + "GODMODE\\Media\\Sound\\jadeo.wav");
#endregion
#region Meshes Objetos Iluminacion
linterna = loader.loadSceneFromFile(alumnoMediaFolder + "GODMODE\\Media\\linterna-TgcScene.xml",
alumnoMediaFolder + "GODMODE\\Media\\");
meshLinterna = linterna.Meshes[0];
vela = loader.loadSceneFromFile(alumnoMediaFolder + "GODMODE\\Media\\vela con fuego-TgcScene.xml",
alumnoMediaFolder + "GODMODE\\Media\\");
meshVela = vela.Meshes[0];
farol = loader.loadSceneFromFile(alumnoMediaFolder + "GODMODE\\Media\\farol-TgcScene.xml",
alumnoMediaFolder + "GODMODE\\Media\\");
meshFarol = farol.Meshes[0];
meshLinterna.Position = camara.getPosition() + new Vector3(10f,-70f,52.5f);
meshLinterna.Rotation = new Vector3(Geometry.DegreeToRadian(-5f), Geometry.DegreeToRadian(90f), Geometry.DegreeToRadian(-5f));
meshLinterna.Scale = new Vector3(0.1f, 0.1f, 0.1f);
meshVela.Position = camara.getPosition() + new Vector3(10f, -80f, 52.5f);
meshVela.Rotation = new Vector3(Geometry.DegreeToRadian(-5f), Geometry.DegreeToRadian(90f), Geometry.DegreeToRadian(-5f));
meshVela.Scale = new Vector3(0.08f, 0.08f, 0.08f);
meshFarol.Position = camara.getPosition() + new Vector3(15f, -80f, 52.5f);
meshFarol.Rotation = new Vector3(Geometry.DegreeToRadian(-5f), Geometry.DegreeToRadian(90f), Geometry.DegreeToRadian(-5f));
meshFarol.Scale = new Vector3(0.2f,0.2f,0.2f);
#endregion
#region Sprite Bateria
bateria = new TgcSprite();
bateria.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Bateria3.png");
screenSize = GuiController.Instance.Panel3d.Size;
textureSize = bateria.Texture.Size;
bateria.Scaling = new Vector2(screenSize.Height * 0.00078f, screenSize.Height * 0.00078f);
bateria.Position = new Vector2(FastMath.Max(screenSize.Width / 5 - textureSize.Width / 4, 0), FastMath.Max(screenSize.Height - textureSize.Height / 1.7f, 0));
#endregion
#region Sprite Objetivos
spriteObjetivos = new TgcSprite();
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\0.png");
screenSize = GuiController.Instance.Panel3d.Size;
textureSize = spriteObjetivos.Texture.Size;
spriteObjetivos.Scaling = new Vector2(screenSize.Height*0.0012f, screenSize.Height * 0.0012f);
spriteObjetivos.Position = new Vector2(FastMath.Max(screenSize.Width / 2.7f, 0), FastMath.Max(screenSize.Height / 1.2f, 0));
#endregion
#region Puertas
puerta1 = new Puerta(alumnoMediaFolder, new Vector3(-251f, 1f, -71f), new Vector3(5.85f, 2.15f, 1f), new Vector3(0f, -0.05f, 0f));//puerta que esta atras nuestro cuando empezamos
puerta2 = new Puerta(alumnoMediaFolder, new Vector3(50.4f, 1f, -252f), new Vector3(5.75f, 2.15f, 1f), new Vector3(0f, -1.6f, 0f)); // a nuestra derecha
puerta3 = new Puerta(alumnoMediaFolder, new Vector3(251.5f, 1f, 61f), new Vector3(5.85f, 2.15f, 1f), new Vector3(0f, -3.17f, 0f)); //puerta frente a la cual empezamos
puerta4 = new Puerta(alumnoMediaFolder, new Vector3(51f, 1f, 648.04f), new Vector3(5.75f, 2.15f, 1f), new Vector3(0f, -1.59f, 0f)); // a nuestra izquierda
puerta5 = new Puerta(alumnoMediaFolder, new Vector3(-1360f, 1f, 432f), new Vector3(5.75f, 2.15f, 1f), new Vector3(0f, 1.55f, 0f)); // siguiendo el camino indicado por la 3
puerta6 = new Puerta(alumnoMediaFolder, new Vector3(1200.8f, 1f, -749f), new Vector3(4.65f, 2.15f, 1f), new Vector3(0f, 3.1f, 0f)); // siguiendo el camino indicado por la 2
puerta7 = new Puerta(alumnoMediaFolder, new Vector3(1740f, 1f, -248f), new Vector3(4.05f, 2.15f, 1f), new Vector3(0f, 1.54f, 0f)); //ULTIMOA PUERTA
meshesExtra.Add(puerta1.mesh);
meshesExtra.Add(puerta2.mesh);
meshesExtra.Add(puerta3.mesh);
meshesExtra.Add(puerta4.mesh);
meshesExtra.Add(puerta5.mesh);
meshesExtra.Add(puerta6.mesh);
meshesExtra.Add(puerta7.mesh);
puertas = new List<Puerta>();
puertas.Add(puerta1); puertas.Add(puerta2); puertas.Add(puerta3); puertas.Add(puerta4);
puertas.Add(puerta5); puertas.Add(puerta6); puertas.Add(puerta7);
#endregion
#region Inicializacion del rayo
direccionRayo = camara.getPosition() - enemigo.getPosicion();
rayo.Origin = enemigo.getPosicion();
rayo.Direction = direccionRayo;
#endregion
#region Objetos a buscar
copa = new Objetivo(alumnoMediaFolder, "GODMODE\\Media\\copa-TgcScene.xml", new Vector3(1782.22f, 30f,-5.51f), new Vector3(0.1f, 0.1f, 0.1f));
espada = new Objetivo(alumnoMediaFolder, "GODMODE\\Media\\espada-TgcScene.xml", new Vector3(829f, 0f, 821f), new Vector3(0.1f, 0.1f, 0.1f));
locket = new Objetivo(alumnoMediaFolder, "GODMODE\\Media\\locket-TgcScene.xml", new Vector3(-1447f, 30f,1023f), new Vector3(0.02f,0.02f,0.02f));
llave = new Objetivo(alumnoMediaFolder, "GODMODE\\Media\\llave-TgcScene.xml", new Vector3(1274f, 40f, -458f), new Vector3(0.1f, 0.1f, 0.1f));
locket.mesh.rotateY(-0.7f);
espada.mesh.rotateZ(1f);
#endregion
#region Cargo shader nightvision
String compilationErrors;
effect = Effect.FromFile(GuiController.Instance.D3dDevice,
alumnoMediaFolder + "GODMODE\\Media\\Shaders\\GaussianBlur.fx",
null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
if (effect == null)
{
throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
}
//Configurar Technique dentro del shader
effect.Technique = "DefaultTechnique";
g_pDepthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth,
d3dDevice.PresentationParameters.BackBufferHeight,
DepthFormat.D24S8,
MultiSampleType.None,
0,
true);
// inicializo el render target
g_pRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth
, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
Format.X8R8G8B8, Pool.Default);
g_pGlowMap = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth
, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
Format.X8R8G8B8, Pool.Default);
g_pRenderTarget4 = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4
, d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget,
Format.X8R8G8B8, Pool.Default);
g_pRenderTarget4Aux = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4
, d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget,
Format.X8R8G8B8, Pool.Default);
effect.SetValue("g_RenderTarget", g_pRenderTarget);
// Resolucion de pantalla
effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);
CustomVertex.PositionTextured[] vertices = new CustomVertex.PositionTextured[]
{
new CustomVertex.PositionTextured( -1, 1, 1, 0,0),
new CustomVertex.PositionTextured(1, 1, 1, 1,0),
new CustomVertex.PositionTextured(-1, -1, 1, 0,1),
new CustomVertex.PositionTextured(1,-1, 1, 1,1)
};
//vertex buffer de los triangulos
g_pVBV3D = new VertexBuffer(typeof(CustomVertex.PositionTextured),
4, d3dDevice, Usage.Dynamic | Usage.WriteOnly,
CustomVertex.PositionTextured.Format, Pool.Default);
g_pVBV3D.SetData(vertices, 0, LockFlags.None);
#endregion
#region Carga shader Miedo
CustomVertex.PositionTextured[] screenQuadVertices = new CustomVertex.PositionTextured[]
{
new CustomVertex.PositionTextured( -1, 1, 1, 0,0),
new CustomVertex.PositionTextured(1, 1, 1, 1,0),
new CustomVertex.PositionTextured(-1, -1, 1, 0,1),
new CustomVertex.PositionTextured(1,-1, 1, 1,1)
};
//vertex buffer de los triangulos
screenQuadVB = new VertexBuffer(typeof(CustomVertex.PositionTextured),
4, d3dDevice, Usage.Dynamic | Usage.WriteOnly,
CustomVertex.PositionTextured.Format, Pool.Default);
screenQuadVB.SetData(screenQuadVertices, 0, LockFlags.None);
//Creamos un Render Targer sobre el cual se va a dibujar la pantalla
renderTarget2D = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth
, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
Format.X8R8G8B8, Pool.Default);
//Cargar shader con efectos de Post-Procesado
efectoMiedo = TgcShaders.loadEffect(alumnoMediaFolder + "GODMODE\\Media\\Shaders\\Miedo.fx");
//Configurar Technique dentro del shader
efectoMiedo.Technique = "OndasTechnique";
//Cargar textura que se va a dibujar arriba de la escena del Render Target
alarmTexture = TgcTexture.createTexture(d3dDevice, alumnoMediaFolder + "GODMODE\\Media\\efecto_alarma.png");
intVaivenAlarm = new InterpoladorVaiven();
intVaivenAlarm.Min = 0;
intVaivenAlarm.Max = 1;
intVaivenAlarm.Speed = 0.8f;
intVaivenAlarm.reset();
#endregion
}
// <param name="elapsedTime">Tiempo en segundos transcurridos desde el último frame</param>
public override void render(float elapsedTime)
{
if (cameraCorrection)
{
cameraCorrection = false;
camara.setCamera(new Vector3(0f, 50f, 0f), new Vector3(1f, 50f, 0f));
}
#region enMenu
if (enMenu) {
GuiController.Instance.Drawer2D.beginDrawSprite();
//Dibujar sprite (si hubiese mas, deberian ir todos aquí)
titulo.render();
mancha.render();
//Finalizar el dibujado de Sprites
GuiController.Instance.Drawer2D.endDrawSprite();
textoEmpezarJuego.render();
textoDescripcion.render();
if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Space))
{
enMenu = false;
//Al salir del menu, marca que el proximo frame llevará corrección de la camara
cameraCorrection = true;
}
}
#endregion
#region Gameover
if (gameOver)
{
GuiController.Instance.Drawer2D.beginDrawSprite();
//Dibujar sprite (si hubiese mas, deberian ir todos aquí)
titulo.render();
mancha.render();
//Finalizar el dibujado de Sprites
GuiController.Instance.Drawer2D.endDrawSprite();
textoGameOver.render();
textoSpace.render();
if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Space))
{
enMenu = true;
gameOver = false;
reiniciarJuego();
}
}
#endregion
#region ganado
if (ganado)
{
GuiController.Instance.Drawer2D.beginDrawSprite();
//Dibujar sprite (si hubiese mas, deberian ir todos aquí)
titulo.render();
//Finalizar el dibujado de Sprites
GuiController.Instance.Drawer2D.endDrawSprite();
textoGanador.render();
textoSpace.render();
if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Space))
{
enMenu = true;
gameOver = false;
ganado = false;
reiniciarJuego();
}
}
#endregion
else if (!enMenu && !gameOver && !ganado) {
iteracion++;
objetosColisionablesCambiantes.Clear();
todosObjetosColisionables.Clear();
GuiController.Instance.UserVars.setValue("perdido", perdido);
GuiController.Instance.UserVars.setValue("PosEnemigo", enemigo.getPosicion());
GuiController.Instance.UserVars.setValue("lastKnown", lastKnownPos);
GuiController.Instance.UserVars.setValue("enWaypoints", enWaypoints);
GuiController.Instance.UserVars.setValue("enLocker", enLocker);
GuiController.Instance.UserVars.setValue("lookAt", camara.getLookAt());
#region Manejo de Puertas
foreach (Puerta puerta in puertas)
{
if (puerta != puertas.Last())
manejarPuerta(puerta);
}
if ((llave.encontrado && locket.encontrado && espada.encontrado) || iteracion == 1)
{
manejarPuerta(puertas.Last());
}
if (!puertas.Last().abierta) //Manejo de la ultima puerta para colisiones
{
puertas.Last().mesh.updateBoundingBox();
puertas.Last().mesh.BoundingBox.transform(puertas.Last().mesh.Transform); //rota el bounding box
objetosColisionablesCambiantes.Add(puertas.Last().mesh.BoundingBox);
}
#endregion
//Device de DirectX para renderizar
Device d3dDevice = GuiController.Instance.D3dDevice;
//tgcScene.renderAll(); //Renderiza la escena del TGCSceneLoader
#region Camara y Colisiones
todosObjetosColisionables.AddRange(objetosColisionables);
todosObjetosColisionables.AddRange(objetosColisionablesCambiantes);
camara.objetosColisionables = todosObjetosColisionables;
camara.characterSphere = esferaCamara;
if (!esperandoPuerta && !enLocker)
{
camara.updateCamera();
}
#endregion
#region Deteccion del jugador
if (enemigoActivo)
{
bool colisionDetectada = false;
Vector3 origenRayo = enemigo.getPosicion();
origenRayo.Y = 20;
direccionRayo = camara.getPosition() - enemigo.getPosicion();
direccionRayo.Y = 0;
rayo.Origin = origenRayo;
rayo.Direction = direccionRayo;
Vector3 ptoIntersec;
foreach (TgcBoundingBox obstaculo in todosObjetosColisionables)
{
if (TgcCollisionUtils.intersectRayAABB(rayo, obstaculo, out ptoIntersec) && (direccionRayo.Length() > (rayo.Origin - ptoIntersec).Length()))
{
colisionDetectada = true;
break;
}
}
if (colisionDetectada && !perdido) //Indicar que se perdio al jugador al detectar colision, si no lo estaba
{
perdido = true;
contadorDetecciones = 0;
}
if (!colisionDetectada && iteracion != 1 && !enLocker) //En la primera iteracion no se carga bien el escenario y no funciona
{
contadorDetecciones++;
if (contadorDetecciones >= DELAY_FRAMES_DETECCION && !enemigoEsperandoPuerta)
{
lastKnownPos = esferaCamara.Position;
if (perdido && enWaypoints) sonidoGrito.play();
perdido = false; //Si se ve al jugador, indicar que se lo encontro
enWaypoints = false;
enemigoActivo = true; //RARO
tiempoBuscando = TIEMPO_DE_BUSQUEDA; //Reiniciar el tiempo que nos busca si no estamos
contadorDetecciones = 0;
}
}
}
#endregion
sonidoEnemigo.Position = esferaCamara.Position; //Actualizar posicion del origen del sonido.
#region manejo de lockers
manejarLocker(locker1);
manejarLocker(locker2);
manejarLocker(locker3);
manejarLocker(locker4);
manejarLocker(locker5);
#endregion
#region Calculos Tiempo Iluminacion
tiempoIluminacion -= elapsedTime;
if (tiempoIluminacion <= 15)
tiempoIluminacion = 15;
tiempo += elapsedTime;
//temblorLuz = temblorLuz + elapsedTime; //Calcula movimientos del mesh de luz, ya se suma en otro lado
var random = FastMath.Cos(6 * temblorLuz);
foreach (Recarga pila in recargas)
{
if (Math.Abs(Vector3.Length(camara.eye - pila.mesh.Position)) < 30f)
{
if (!pila.usada)
{
tiempoIluminacion = 80f;
sonidoPilas.play();
}
pila.usada = true;
tiempoIluminacion = 80f;
}
pila.flotar(random, elapsedTime,conNightVision);
GuiController.Instance.UserVars.setValue("posicion", camara.getPosition());
GuiController.Instance.UserVars.setValue("poder", tiempoIluminacion);
}
#endregion
#region Mover Enemigo
if (enemigoActivo)
{
sonidoEnemigo.play();
if (!enWaypoints)
{
if (perdido)
{
tiempoBuscando -= elapsedTime;
foreach (Puerta puerta in puertas)
{
Vector3 ptoIntersec = new Vector3();
if (TgcCollisionUtils.intersectRayAABB(rayo, puerta.mesh.BoundingBox, out ptoIntersec) && (direccionRayo.Length() > (rayo.Origin - ptoIntersec).Length()) && !puerta.abierta)
{
enWaypoints = true;
enemigo.irAWaypointMasCercano();
}
}
}
enemigo.perseguir(lastKnownPos, VELOCIDAD_ENEMIGO * elapsedTime);
}
else
{
enemigoEsperandoPuerta = false;
foreach (Puerta puerta in puertas)
{
Vector3 posicionPuerta = puerta.mesh.Position; posicionPuerta.Y = 0;
if (Math.Abs(Vector3.Length(enemigo.getPosicion() - posicionPuerta)) < 110f && !puerta.abierta)
{
if (!puerta.girando)
{
sonidoPuertas.play(false);
puerta.girando = true;
}
enemigoEsperandoPuerta = true;
break;
}
}
if (!enemigoEsperandoPuerta)
enemigo.seguirWaypoints(VELOCIDAD_PATRULLA * elapsedTime);
}
//Retomar waypoints por tiempo de busqueda
if (!enWaypoints && tiempoBuscando <= 0)
{
tiempoBuscando = TIEMPO_DE_BUSQUEDA;
perdido = true;
enWaypoints = true;
enemigo.irAWaypointMasCercano();
}
//GAME OVER
if ((Math.Abs(Vector3.Length(esferaCamara.Position - new Vector3(enemigo.getPosicion().X, 50, enemigo.getPosicion().Z))) < 30f) && !enLocker && enemigoActivo)
{
gameOver = true;
}
enemigo.actualizarAnim();
}
#endregion
#region Manejo de Objetos a Buscar
if (Math.Abs(Vector3.Length(camara.eye - copa.mesh.Position)) < 30f)
{
if (!copa.encontrado) sonidoObjeto.play(false);
copa.encontrado = true;
ganado = true;
}
if (Math.Abs(Vector3.Length(camara.eye - espada.mesh.Position)) < 50f)
{
if (!espada.encontrado) sonidoObjeto.play(false);
/* if ((!enemigoActivo) && (!espada.encontrado))
{
ponerEnemigo(new Vector3(489.047f, 0f, 843.8695f)); //PONER ENEMIGO
}*/
espada.encontrado = true;
}
if (Math.Abs(Vector3.Length(camara.eye - locket.mesh.Position)) < 40f)
{
if (!locket.encontrado) sonidoObjeto.play(false);
locket.encontrado = true;
}
if (Math.Abs(Vector3.Length(camara.eye - llave.mesh.Position)) < 40f)
{
if (!llave.encontrado) sonidoObjeto.play(false);
llave.encontrado = true;
}
llave.flotar(random, elapsedTime, 40f,conNightVision);
espada.flotar(random, elapsedTime, 10f, conNightVision);
copa.flotar(random, elapsedTime, 30f, conNightVision);
locket.flotar(random, elapsedTime, 30f, conNightVision);
#endregion
#region Renderizado
todosLosMeshesIluminables.Clear();
todosLosMeshesIluminables.AddRange(tgcScene.Meshes);
todosLosMeshesIluminables.AddRange(meshesExtra);
foreach(Locker locker in listaLockers)
{
todosLosMeshesIluminables.Add(locker.mesh);
}
bool lightEnable = (bool)GuiController.Instance.Modifiers["lightEnable"];
//Actualzar posición de la luz
Vector3 lightPos = camara.getPosition();
//Normalizar direccion de la luz
Vector3 lightDir = camara.target - camara.eye;
lightDir.Normalize();
if (!conNightVision && tiempoIluminacion!=15)
{
renderizarMeshes(todosLosMeshesIluminables, lightEnable, lightPos, lightDir);
//Renderizar mesh de luz
enemigo.render();
renderizarObjetoIluminacion(elapsedTime);
} else if(conNightVision)
{
renderizarNightVision(elapsedTime);
} else if(!conNightVision && tiempoIluminacion == 15){
renderizarMiedo(elapsedTime);
}
if (enLocker)
{
//Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno)
GuiController.Instance.Drawer2D.beginDrawSprite();
//Dibujar sprite (si hubiese mas, deberian ir todos aquí)
spriteLocker.render();
//Finalizar el dibujado de Sprites
GuiController.Instance.Drawer2D.endDrawSprite();
}
#endregion
#region Sprites
if (tiempoIluminacion <= 30)
{
bateria.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Bateria0.png");
}
else if (tiempoIluminacion >30 && tiempoIluminacion < 50)
{
bateria.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Bateria1.png");
}
else if (tiempoIluminacion >= 50 && tiempoIluminacion <= 70)
{
bateria.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Bateria2.png");
}
else
{
bateria.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Bateria3.png");
}
if(!llave.encontrado && !locket.encontrado && !espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\0.png");
} else if(!llave.encontrado && ! locket.encontrado && espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\1.png");
} else if(llave.encontrado && !locket.encontrado && espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\2.png");
} else if(!llave.encontrado && locket.encontrado && espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\3.png");
} else if (llave.encontrado && locket.encontrado && !espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\4.png");
} else if(llave.encontrado && !locket.encontrado && !espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\5.png");
} else if (!llave.encontrado && locket.encontrado && !espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\6.png");
} else if(llave.encontrado && locket.encontrado && espada.encontrado)
{
spriteObjetivos.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosDir + "GODMODE\\Media\\Objetivos\\7.png");
}
//Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno)
GuiController.Instance.Drawer2D.beginDrawSprite();
//Dibujar sprite (si hubiese mas, deberian ir todos aquí)
bateria.render();
spriteObjetivos.render();
//Finalizar el dibujado de Sprites
GuiController.Instance.Drawer2D.endDrawSprite();
#endregion
#region Ejemplo de input teclado
///////////////INPUT//////////////////
//Capturar Input teclado
if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.D1))
{
ObjetoIluminacion = 0;
}
if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.D2))
{
ObjetoIluminacion = 1;
}
if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.D3))
{
ObjetoIluminacion = 2;
}
if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.R))
{
conNightVision = !conNightVision;
}
//Correr
if (GuiController.Instance.D3dInput.keyDown(Microsoft.DirectX.DirectInput.Key.LeftShift))
{
if (tiempoRestanteCorrer > 0)
{
camara.MovementSpeed = VELOCIDAD_JUGADOR_CORRER;
camara.tiempoPaso = 0.3f;
tiempoRestanteCorrer -= elapsedTime;
if (tiempoRestanteCorrer <= 0)
{
sonidoJadeo.play();
tiempoRestanteCorrer = -2 * TIEMPO_LIMITE_CORRER;
camara.MovementSpeed = VELOCIDAD_JUGADOR_CAMINAR;
camara.tiempoPaso = 0.4f;
}
}
else
if (tiempoRestanteCorrer < TIEMPO_LIMITE_CORRER)