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> /// Draws a sprite on the screen. /// </summary> /// <param name="sprite">The sprite.</param> public void DrawSprite(CustomSprite sprite) { DxSprite.Transform = sprite.TransformationMatrix; DxSprite.Draw(sprite.Bitmap.D3dTexture, sprite.SrcRect, Vector3.Empty, Vector3.Empty, sprite.Color); }
/// <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; }
private void RenderJugadoresMapa(List<Jugador> jugadores, CustomSprite punto) { foreach (Jugador jugador in jugadores) { Vector2 mapPosition = this.GetMapPosition(jugador.Position, this.mapa.Bitmap.Size, this.partido.Cancha.Size); //El 5 es porque en el x la imagen del a foto incluye mucho pasto fuera de las lineas float pX = this.mapa.Position.X - 5 + (this.mapa.Bitmap.Size.Width / 2) + mapPosition.X; float pZ = this.mapa.Position.Y + (this.mapa.Bitmap.Size.Height / 2) - mapPosition.Y; punto.Position = new Vector2(pX, pZ); drawer2D.DrawSprite(punto); } }