/// <summary> /// Crea un partido con todos sus componentes Cancha, Arcos, Jugadores y Pelota /// </summary> /// <param name="alumnoEjemplosMediaDir"> Carpeta donde estan los recursos </param> /// <returns> Un partido listo para comenzar a jugar :)</returns> public Partido CrearPartido(string pathRecursos, TgcD3dInput input, Dictionary<string, TgcStaticSound> sonidos, TgcThirdPersonCamera camara) { string nombreEquipoLocal = "SKTS"; string nombreEquipoVisitante = "TGCV"; Partido partido = Partido.Instance; partido.Sonidos = sonidos; partido.Marcador = this.CrearMarcador(nombreEquipoLocal, nombreEquipoVisitante); partido.Cancha = this.CrearCancha(pathRecursos); partido.ArcoLocal = this.CrearArco(pathRecursos, partido.Cancha, -1); partido.ArcoVisitante = this.CrearArco(pathRecursos, partido.Cancha, 1); partido.Pelota = this.CrearPelota(pathRecursos, partido.Cancha); partido.EquipoLocal = EquipoFactory.Instance.CrearEquipoHumanoIA(nombreEquipoLocal, pathRecursos, input, partido); partido.EquipoVisitante = EquipoFactory.Instance.CrearEquipoIA(nombreEquipoVisitante, pathRecursos, partido); //Creo la pelota con todos sus obstaculos List<IColisionablePelota> obstaculosPelota = new List<IColisionablePelota>(); obstaculosPelota.AddRange(partido.ArcoLocal.GetColisionables()); obstaculosPelota.AddRange(partido.ArcoVisitante.GetColisionables()); obstaculosPelota.Add(partido.Cancha); obstaculosPelota.AddRange(partido.Cancha.LimitesCancha); obstaculosPelota.AddRange(partido.EquipoLocal.JugadoresColisionables()); obstaculosPelota.AddRange(partido.EquipoVisitante.JugadoresColisionables()); partido.Pelota.CollisionManager = new PelotaCollisionManager(obstaculosPelota); //partido.Pelota.CollisionManager = new SphereCollisionManager(obstaculosPelota); //Cargo las colisiones de los jugadores EquipoFactory.Instance.CargarColisionesEquipos(partido.EquipoLocal, partido.EquipoVisitante, partido); partido.Camara = camara; return partido; }
public ConfiguracionPartido(string pathRecursos, int width, TgcThirdPersonCamera camara, EjemploAlumno main) { //Titulo this.titulo = new TgcText2D(); this.titulo.Text = "Configuración del partido"; this.titulo.Color = Color.White; this.titulo.Align = TgcText2D.TextAlign.CENTER; this.titulo.Size = new Size(400, 100); this.titulo.changeFont(new System.Drawing.Font("Arial", 24)); this.titulo.Position = new Point((width - this.titulo.Size.Width) / 2, 20); //Menu this.menus = new List<MenuItem>(); this.menus.Add(new MenuItem("listo", new Vector3(-7, 4, 0), new Vector3(14, 2, 0), pathRecursos + "Menu\\listo.png", pathRecursos + "Menu\\listo-seleccionado.png")); this.menus.Add(new MenuItem("uniformeLocal", new Vector3(-7, 1, 0), new Vector3(14, 4, 0), pathRecursos + "Menu\\local.png", pathRecursos + "Menu\\local-seleccionado.png")); this.menus.Add(new MenuItem("uniformeVisitante", new Vector3(-7, -3, 0), new Vector3(14, 4, 0), pathRecursos + "Menu\\visitante.png", pathRecursos + "Menu\\visitante-seleccionado.png")); this.menus.Add(new MenuItem("pelota", new Vector3(7, 3.2f, 0), new Vector3(14, 4, 0), pathRecursos + "Menu\\pelota.png", pathRecursos + "Menu\\pelota-seleccionado.png")); this.menus.Add(new MenuItem("camara", new Vector3(7, 0.2f, 0), new Vector3(14, 2, 0), pathRecursos + "Menu\\camara.png", pathRecursos + "Menu\\camara-seleccionado.png")); this.menus.Add(new MenuItem("volver", new Vector3(7, -2.2f, 0), new Vector3(14, 2, 0), pathRecursos + "Menu\\volver.png", pathRecursos + "Menu\\volver-seleccionado.png")); //Pelotas this.pelotas = new List<TgcSphere>(); //TODO cambiar por matrices this.pelotas.Add(this.CrearPelota(pathRecursos, new Vector3(10, 3.2f, 0), TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall))); this.pelotas.Add(this.CrearPelota(pathRecursos, new Vector3(10, 3.2f, 0), TgcTexture.createTexture(pathRecursos + "Texturas\\pelota2.jpg"))); this.pelotas.Add(this.CrearPelota(pathRecursos, new Vector3(10, 3.2f, 0), TgcTexture.createTexture(pathRecursos + "Texturas\\pelota3.jpg"))); //Jugadores this.jugadores = new List<TgcSkeletalMesh>(); this.jugadores.Add(this.CrearJugador(pathRecursos, TgcTexture.createTexture(pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.textureTeam1))); this.jugadores.Add(this.CrearJugador(pathRecursos, TgcTexture.createTexture(pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.textureTeam2))); this.jugadores.Add(this.CrearJugador(pathRecursos, TgcTexture.createTexture(pathRecursos + Settings.Default.meshFolderPlayer + "Textures\\uvw.jpg"))); this.jugadores.Add(this.CrearJugador(pathRecursos, TgcTexture.createTexture(pathRecursos + Settings.Default.meshFolderPlayer + "Textures\\uvwBlack.png"))); this.jugadores.Add(this.CrearJugador(pathRecursos, TgcTexture.createTexture(pathRecursos + Settings.Default.meshFolderPlayer + "Textures\\uvwOrange.png"))); this.jugadores.Add(this.CrearJugador(pathRecursos, TgcTexture.createTexture(pathRecursos + Settings.Default.meshFolderPlayer + "Textures\\uvwViolet.png"))); //Camaras this.camaras = new List<TgcText2D>(); this.camaras.Add(this.CrearCamara("Pelota", width)); //this.camaras.Add(this.CrearCamara("Jugador", screenSize)); this.camaras.Add(this.CrearCamara("Aérea", width)); this.menus[0].Select(); this.pelota = 0; this.jugadorLocal = 0; this.jugadorVisitante = 1; this.camaraSeleccionada = 0; this.positionJugadorLocal = new Vector3(-4, -0.1f, 0); this.positionJugadorVisitante = new Vector3(-4, -4, 0); this.camara = camara; this.main = main; }
public MenuInicial(string pathRecursos, TgcThirdPersonCamera camara, EjemploAlumno main) { this.main = main; this.camara = camara; this.drawer2D = new Drawer2D(); //Titulo this.titulo = new TgcText2D(); this.titulo.Text = "Socketes"; this.titulo.Color = Color.White; this.titulo.Align = TgcText2D.TextAlign.CENTER; this.titulo.Position = new Point(280, 0); this.titulo.Size = new Size(400, 100); this.titulo.changeFont(new System.Drawing.Font("Arial", 35)); //Brazuca this.pelota = new TgcSphere(); //TODO cambiar por matrices this.pelota.AutoTransformEnable = true; this.pelota.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall)); this.pelota.Radius = 2.5f; this.pelota.LevelOfDetail = 4; this.pelota.Position = new Vector3(3, 0, -4); this.pelota.updateValues(); //Cancha donde esta la pelota this.cancha = TgcBox.fromSize(new Vector3(20, 0, 20), TgcTexture.createTexture(pathRecursos + Settings.Default.textureMenuField)); //TODO cambiar por matrices this.cancha.AutoTransformEnable = true; this.cancha.Position = new Vector3(0, -2.5f, 0); //Menu this.menus = new List<MenuItem>(); this.menus.Add(new MenuItem("picadito", new Vector3(-5, 2, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.texturePicadito1, pathRecursos + Settings.Default.texturePicadito2)); this.menus.Add(new MenuItem("configuracion", new Vector3(-5, 0.8f, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.textureControles1, pathRecursos + Settings.Default.textureControles2)); this.menus.Add(new MenuItem("salir", new Vector3(-5, -0.4f, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.textureSalir1, pathRecursos + Settings.Default.textureSalir2)); this.menus[0].Select(); //Menu de configuracion //Crear Sprite this.panelConfiguracion = new CustomSprite(); this.panelConfiguracion.Bitmap = new CustomBitmap(pathRecursos + Settings.Default.texturePanelcontroles, D3DDevice.Instance.Device); this.panelConfiguracion.Scaling = new Vector2(0.75f, 0.75f); Size textureSize = this.panelConfiguracion.Bitmap.Size; this.panelConfiguracion.Position = new Vector2(FastMath.Max(D3DDevice.Instance.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(D3DDevice.Instance.Height / 2 - textureSize.Height / 2, 0)); }
/// <summary> /// Método que se llama una sola vez, al principio cuando se ejecuta el ejemplo. /// Escribir aquí todo el código de inicialización: cargar modelos, texturas, modifiers, uservars, etc. /// Borrar todo lo que no haga falta /// </summary> public override void Init() { //Musica //GuiController.Instance.Modifiers.addBoolean("Musica", "Música", true); //BoundingBox //GuiController.Instance.Modifiers.addBoolean("BoundingBox", "BoundingBox", false); //Inteligencia Artificial //GuiController.Instance.Modifiers.addBoolean("IA", "IA", true); //Un boton para reiniciar las posiciones //GuiController.Instance.Modifiers.addButton("ReiniciarPosiciones", "Reiniciar Posiciones", new EventHandler(this.ReiniciarPosiciones_Click)); //Luz //GuiController.Instance.Modifiers.addFloat("lightIntensity", 0, 100, 50); //GuiController.Instance.Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.20f); //Empiezo con un tema Random :) int numbreTrack = new Random().Next(Settings.Default.music.Count); //GuiController.Instance.Mp3Player.FileName = pathRecursos + Settings.Default.music[numbreTrack]; //TODO Arreglar para despues :) Dictionary<string, TgcStaticSound> sonidos = new Dictionary<string, TgcStaticSound>(); TgcStaticSound sonido = new TgcStaticSound(); sonido.loadSound(MediaDir + "Audio\\pelota-tiro.wav", DirectSound.DsDevice); sonidos.Add("pelota-tiro", sonido); //Configurar camara en Tercer Persona camaraInterna = new TgcThirdPersonCamera(); Camara = camaraInterna; this.pantallaActual = 0; //Creo el menu this.menu = new MenuInicial(MediaDir, camaraInterna, this); //Creo la configuracion del partido this.configuracionPartido = new ConfiguracionPartido(MediaDir, D3DDevice.Instance.Width, camaraInterna, this); //Creo el partido this.partido = PartidoFactory.Instance.CrearPartido(MediaDir, Input, sonidos, camaraInterna); drawer2D = new Drawer2D(); //Mapa this.mapa = new CustomSprite(); this.mapa.Bitmap = new CustomBitmap(MediaDir + "Texturas\\mapa.png", D3DDevice.Instance.Device); //this.mapa.Scaling = new Vector2(0.75f, 0.75f); Size textureSize = this.mapa.Bitmap.Size; this.mapa.Position = new Vector2((D3DDevice.Instance.Width - textureSize.Width) / 2, (D3DDevice.Instance.Height - textureSize.Height)); this.puntoAzul = new CustomSprite(); this.puntoAzul.Bitmap = new CustomBitmap(MediaDir + "Texturas\\radarAzul.png", D3DDevice.Instance.Device); this.puntoAzul.Scaling = new Vector2(0.03f, 0.03f); this.puntoNaranja = new CustomSprite(); this.puntoNaranja.Bitmap = new CustomBitmap(MediaDir + "Texturas\\radarNaranja.png", D3DDevice.Instance.Device); this.puntoNaranja.Scaling = new Vector2(0.03f, 0.03f); //Color de fondo (BackgroundColor) D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); //FIX que nos mando Mariano para poder bajar el Alpha en el PixelShader D3DDevice.Instance.Device.RenderState.ReferenceAlpha = 10; }