public HUD(GameModel env) { this.env = env; drawer2D = new Drawer2D(); Size textureSize; //Creo el Background del HUD backgroundHUD = new CustomSprite(); backgroundHUD.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\background.png", D3DDevice.Instance.Device); textureSize = backgroundHUD.Bitmap.Size; backgroundHUD.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 6), 0); backgroundHUD.Scaling = new Vector2(6, D3DDevice.Instance.Height / 10); //Crear Personaje 192 x 242 personaje = new CustomSprite(); personaje.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\face1.png", D3DDevice.Instance.Device); textureSize = personaje.Bitmap.Size; personaje.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 0.3f) - 10, D3DDevice.Instance.Height - (textureSize.Height * 0.3f) - 10); personaje.Scaling = new Vector2(0.3f, 0.3f); // Hacha hacha = new CustomSprite(); hacha.Bitmap = new CustomBitmap(env.MediaDir + "\\hacha\\hacha.png", D3DDevice.Instance.Device); textureSize = hacha.Bitmap.Size; hacha.Position = new Vector2( D3DDevice.Instance.Width / 2, D3DDevice.Instance.Height - textureSize.Height + 80); //hacha.Scaling = new Vector2(0.3f, 0.3f); //Crear Vaso de Agua 512 x 512 vaso = new CustomSprite(); vaso.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\agua.png", D3DDevice.Instance.Device); textureSize = vaso.Bitmap.Size; vaso.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 0.15f) - 10, D3DDevice.Instance.Height - (textureSize.Height * 0.15f) - 250); vaso.Scaling = new Vector2(0.15f, 0.15f); //Crear Comida 512 x 512 comida = new CustomSprite(); comida.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\food.png", D3DDevice.Instance.Device); textureSize = comida.Bitmap.Size; comida.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 0.15f) - 10, D3DDevice.Instance.Height - (textureSize.Height * 0.15f) - 150); comida.Scaling = new Vector2(0.15f, 0.15f); //Crear Inventario0 512 x 512 inventario0 = new CustomSprite(); inventario0.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\food.png", D3DDevice.Instance.Device); textureSize = inventario0.Bitmap.Size; inventario0.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 0.15f) - 10, D3DDevice.Instance.Height - (textureSize.Height * 0.15f) - (D3DDevice.Instance.Height * 0.9f)); inventario0.Scaling = new Vector2(0.15f, 0.15f); //Crear Inventario1 512 x 512 inventario1 = new CustomSprite(); inventario1.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\agua.png", D3DDevice.Instance.Device); textureSize = inventario1.Bitmap.Size; inventario1.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 0.15f) - 10, D3DDevice.Instance.Height - (textureSize.Height * 0.15f) - (D3DDevice.Instance.Height * 0.8f)); inventario1.Scaling = new Vector2(0.15f, 0.15f); //Crear Inventario2 512 x 512 inventario2 = new CustomSprite(); inventario2.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\wood.png", D3DDevice.Instance.Device); textureSize = inventario2.Bitmap.Size; inventario2.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 0.15f) - 10, D3DDevice.Instance.Height - (textureSize.Height * 0.15f) - (D3DDevice.Instance.Height * 0.7f)); inventario2.Scaling = new Vector2(0.15f, 0.15f); //Crear Inventario3 512 x 512 inventario3 = new CustomSprite(); inventario3.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\stone.png", D3DDevice.Instance.Device); textureSize = inventario3.Bitmap.Size; inventario3.Position = new Vector2( D3DDevice.Instance.Width - (textureSize.Width * 0.15f) - 10, D3DDevice.Instance.Height - (textureSize.Height * 0.15f) - (D3DDevice.Instance.Height * 0.6f)); inventario3.Scaling = new Vector2(0.15f, 0.15f); // Inicializo los puntos de vida txtHambre = new TgcText2D(); txtSed = new TgcText2D(); txtCansancio = new TgcText2D(); inventario0text = new TgcText2D(); inventario1text = new TgcText2D(); inventario2text = new TgcText2D(); inventario3text = new TgcText2D(); //Crear GameOver 549 x 245 gameover = new CustomSprite(); gameover.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\game_over.png", D3DDevice.Instance.Device); textureSize = gameover.Bitmap.Size; gameover.Position = new Vector2( D3DDevice.Instance.Width / 2 - (textureSize.Width / 2), D3DDevice.Instance.Height / 2 - (textureSize.Height / 2)); gameover.Scaling = new Vector2(1f, 1f); youwin = new CustomSprite(); youwin.Bitmap = new CustomBitmap(env.MediaDir + "\\HUD\\winner.png", D3DDevice.Instance.Device); textureSize = youwin.Bitmap.Size; youwin.Position = new Vector2( D3DDevice.Instance.Width / 2 - (textureSize.Width / 2), D3DDevice.Instance.Height / 2 - (textureSize.Height / 2)); youwin.Scaling = new Vector2(1f, 1f); }
/// <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); }