예제 #1
0
 public StoryMenu(Microsoft.DirectX.DirectInput.Key skipKey)
 {
     drawer2D            = new Drawer2D();
     texto1              = new CustomSprite();
     texto2              = new CustomSprite();
     texto3              = new CustomSprite();
     texto_skip          = new CustomSprite();
     this.skipKey        = skipKey;
     b1                  = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\Start\\1.png", D3DDevice.Instance.Device);
     b2                  = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\Start\\2.png", D3DDevice.Instance.Device);
     b3                  = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\Start\\3.png", D3DDevice.Instance.Device);
     skip                = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\Start\\skip.png", D3DDevice.Instance.Device);
     texto1.Position     = new TGCVector2(D3DDevice.Instance.Width * .1f, D3DDevice.Instance.Height * .1f);
     texto2.Position     = new TGCVector2(D3DDevice.Instance.Width * .5f, D3DDevice.Instance.Height * .3f);
     texto3.Position     = new TGCVector2(D3DDevice.Instance.Width * .2f, D3DDevice.Instance.Height * .6f);
     texto_skip.Position = new TGCVector2(D3DDevice.Instance.Width * .9f, D3DDevice.Instance.Height * .8f);
     texto1.Scaling      = CommonHelper.CalculateRelativeScaling(b1, .3f);
     texto2.Scaling      = CommonHelper.CalculateRelativeScaling(b2, .3f);
     texto3.Scaling      = CommonHelper.CalculateRelativeScaling(b3, .3f);
     texto_skip.Scaling  = CommonHelper.CalculateRelativeScaling(skip, .05f);
     texto1.Bitmap       = b1;
     texto2.Bitmap       = b2;
     texto3.Bitmap       = b3;
     texto_skip.Bitmap   = skip;
     VariablesGlobales.managerSonido.PauseAll();
     VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.FORCE_THEME);
 }
예제 #2
0
 /// <summary>
 ///     método que muestra el sprite de game over
 /// </summary>
 internal void gameOver()
 {
     gameOverSprite          = new CustomSprite();
     gameOverSprite.Bitmap   = new CustomBitmap(gameOverSpriteLocation, Device.Device);
     gameOverSprite.Position = new Vector2(FastMath.Max((Device.Width - gameOverSprite.Bitmap.Width) / 2, 0), FastMath.Max((Device.Height - gameOverSprite.Bitmap.Height) / 2, 0));
     GameOver = true;
 }
예제 #3
0
        private void CalcularFullScreenScalingAndPosition(CustomSprite main)
        {//para 1280x720 lo transforma en 2048x1024 (no tiene mucha precision)
            var tamanio_textura = main.Bitmap.Size;

            main.ScalingCenter = new TGCVector2(0, 0);
            if (D3DDevice.Instance.AspectRatio < 2.1f)//16:9 o parecido
            {
                main.Position = new TGCVector2(0, 0);

                float width  = (float)D3DDevice.Instance.Width / (float)tamanio_textura.Width;
                float height = (float)D3DDevice.Instance.Height / (float)tamanio_textura.Height;
                main.Scaling = new TGCVector2(width, height);
            }
            else //21:9 o parecido
            {
                main.Position = new TGCVector2(((float)D3DDevice.Instance.Width - ((float)D3DDevice.Instance.Width * 16f / 21.6f)) / 2, 0);
                float width  = ((float)D3DDevice.Instance.Width * 16f / 21.6f) / (float)tamanio_textura.Width;
                float height = (float)D3DDevice.Instance.Height / (float)tamanio_textura.Height;
                main.Scaling = new TGCVector2(width, height);
            }
            var tr_x = main.Position.X + tamanio_textura.Width * main.Scaling.X;
            var tr_y = main.Position.Y;

            main_rect.top_right = new TGCVector2(tr_x, tr_y);
            var bl_x = main.Position.X;
            var bl_y = main.Position.Y + tamanio_textura.Height * main.Scaling.Y;

            main_rect.bottom_left = new TGCVector2(bl_x, bl_y);

            var br_x = tr_x;
            var br_y = bl_y;

            main_rect.bottom_right = new TGCVector2(br_x, br_y);
            //@asignar main_rect not so easy to do
        }
        public override void Init()
        {
            int W   = D3DDevice.Instance.Width;
            int H   = D3DDevice.Instance.Height;
            int x0  = W / 2;
            int y0  = H / 2;
            int dy  = 80;
            int dy2 = dy;
            int dx  = 200;

            drawer2D = new Drawer2D();

            backgroundSprite          = new CustomSprite();
            backgroundSprite.Bitmap   = new CustomBitmap(MediaDir + "\\Bitmaps\\youWin.png", D3DDevice.Instance.Device);
            backgroundSprite.Position = new TGCVector2(W * 0.1f, H * 0.2f);
            backgroundSprite.Scaling  = new TGCVector2(1, 1);

            gui.Create(MediaDir);
            gui.InitDialog(false, false);

            //gui.InsertMenuItem(ID_CLOSE, "Cerrar", "close.png", x0, y0, MediaDir, dx, dy);
            //gui.InsertButton(ID_CLOSE, "Salir", x0 - 150, y0 + 250, dx, dy, Color.DarkRed);

            winSound.loadSound(MediaDir + "\\Sounds\\win.wav", DirectSound.DsDevice);
        }
예제 #5
0
        public void instanciarMenu()
        {
            drawer2D = new Drawer2D();
            sprite   = new CustomSprite();


            sprite.Bitmap = new CustomBitmap(MediaDir + "pressSpacebarToContinue.jpg", D3DDevice.Instance.Device);

            var textureSize = sprite.Bitmap.Size;

            sprite.Position = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(D3DDevice.Instance.Height / 2 - textureSize.Height / 2, 0));

            float aspectRatio  = D3DDevice.Instance.Width / D3DDevice.Instance.Height;
            float aspectRatio2 = Screen.PrimaryScreen.Bounds.Width / Screen.PrimaryScreen.Bounds.Height;

            Console.WriteLine("Sprite.Width --> " + D3DDevice.Instance.Width);
            Console.WriteLine("Sprite.Height --> " + D3DDevice.Instance.Height);
            Console.WriteLine("Pantalla.Width --> " + Screen.PrimaryScreen.Bounds.Width);
            Console.WriteLine("Pantalla.Height --> " + Screen.PrimaryScreen.Bounds.Height);
            float FactorDeEscalaW = (float)Screen.PrimaryScreen.Bounds.Width / textureSize.Width;
            float FactorDeEscalaH = (float)Screen.PrimaryScreen.Bounds.Height / textureSize.Height;

            Console.WriteLine("FactorDeEscala.Width --> " + FactorDeEscalaW);
            Console.WriteLine("FactorDeEscala.Height --> " + FactorDeEscalaH);


            sprite.Scaling = new TGCVector2(FactorDeEscalaW, FactorDeEscalaH);
        }
예제 #6
0
        public EscenaControles(TgcCamera Camera, string MediaDir, string ShadersDir, TgcText2D DrawText, float TimeBetweenUpdates, TgcD3dInput Input) : base(Camera, MediaDir, ShadersDir, DrawText, TimeBetweenUpdates, Input)
        {
            TgcScene escena = new TgcSceneLoader().loadSceneFromFile(MediaDir + "Cancha-TgcScene.xml");

            pasto   = new Pasto(escena.Meshes[0], TGCShaders.Instance.LoadEffect(ShadersDir + "CustomShaders.fx"), 32, .5f);
            paredes = escena.getMeshByName("Box_5");
            Camera.SetCamera(new TGCVector3(20, 10, -20), new TGCVector3(0, 5, -7));

            skyBox        = new TgcSkyBox();
            skyBox.Center = new TGCVector3(0, 500, 0);
            skyBox.Size   = new TGCVector3(10000, 10000, 10000);
            var texturesPath = MediaDir + "Textures\\SkyBox LostAtSeaDay\\";

            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Up, texturesPath + "lostatseaday_up.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Down, texturesPath + "lostatseaday_dn.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Left, texturesPath + "lostatseaday_lf.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Right, texturesPath + "lostatseaday_rt.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Front, texturesPath + "lostatseaday_bk.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Back, texturesPath + "lostatseaday_ft.jpg");
            skyBox.Init();

            unSprite        = new CustomSprite();
            unSprite.Bitmap = new CustomBitmap(MediaDir + "Textures\\Controles2.png", D3DDevice.Instance.Device);

            //unSprite.Scaling = new TGCVector2(unSprite.Bitmap.Width, unSprite.Bitmap.Height);
            unSprite.Position = new TGCVector2((float)D3DDevice.Instance.Width / 2 - unSprite.Bitmap.Width / 2, (float)D3DDevice.Instance.Height / 2 - unSprite.Bitmap.Height / 2);
        }
예제 #7
0
        private void CalcularChildScalingAndPosition(CustomSprite child, CustomBitmap bitmap_base, float relX, float relY, float relScaleX, float relScaleY, Rect main)
        {
            float posX = main.bottom_right.X - main.bottom_left.X;
            float posY = main.bottom_right.Y - main.top_right.Y;

            child.Position = new TGCVector2(posX * relX, posY * relY);
            child.Scaling  = CalculeRelativeScaling(bitmap_base, posX, posY, relScaleX, relScaleY);//@capaz usar un scale para cada eje?
        }
예제 #8
0
        private void inicializarPantallaNegra()
        {
            pantallaNegra        = new CustomSprite();
            pantallaNegra.Bitmap = new CustomBitmap(MediaDir + "\\pantallaNegra.png", D3DDevice.Instance.Device);
            var textureSize = pantallaNegra.Bitmap.Size;

            pantallaNegra.Position = new Vector2(0, 0);
            pantallaNegra.Scaling  = new Vector2((float)D3DDevice.Instance.Width / textureSize.Width, (float)D3DDevice.Instance.Height / textureSize.Height);
        }
예제 #9
0
        private void incializarMenu()
        {
            menu        = new CustomSprite();
            menu.Bitmap = new CustomBitmap(MediaDir + "\\menuInicio.png", D3DDevice.Instance.Device);
            var textureSize = menu.Bitmap.Size;

            menu.Position = new Vector2(0, 0);
            menu.Scaling  = new Vector2((float)D3DDevice.Instance.Width / textureSize.Width, (float)D3DDevice.Instance.Height / textureSize.Height + 0.01f);
        }
        public static CustomSprite CreateImage(string path, TGCVector2 scalation, float rotation, TGCVector2 translation)
        {
            CustomSprite sprite = new CustomSprite();

            sprite.Bitmap   = new CustomBitmap(GlobalConcepts.GetInstance().GetMediaDir() + "GUI\\HUB\\Velocimetro\\VelocimetroSinFlecha.png", GlobalConcepts.GetInstance().GetScreen());
            sprite.position = translation;
            sprite.rotation = rotation;
            sprite.scaling  = new TGCVector2(0, 0);
            return(sprite);
        }
예제 #11
0
 /// <summary>
 /// Crea un elemento que se ajusta al tamaño de la pantalla, la duracion es del render, NO del sonido
 /// </summary>
 /// <param name="dir"></param>
 /// <param name="sonido"></param>
 /// <param name="duracion"></param>
 public FullScreenElement(string dir, SoundManager.SONIDOS sonido, float duracion)
 {
     this.duracion = duracion;
     drawer2D      = new Drawer2D();
     fondo         = new CustomSprite();
     bitmap        = new CustomBitmap(VariablesGlobales.mediaDir + dir, D3DDevice.Instance.Device);
     fondo.Bitmap  = bitmap;
     CalcularFullScreenScalingAndPosition(fondo);
     VariablesGlobales.managerSonido.ReproducirSonido(sonido);
 }
예제 #12
0
        public MiniMap(Drawer2D drawer)
        {
            this.drawer2D     = drawer;
            this.texturaPixel = VariablesGlobales.mediaDir + "Minimap\\pixel3.png";
            this.texturaFondo = VariablesGlobales.mediaDir + "Minimap\\mapaBomba.png";

            this.objetos = new List <Proyeccion>();

            this.spriteFondo = crearMapa(this.origTamanioX, this.origTamanioZ, this.escala);
        }
예제 #13
0
 public StartMenu(Key mappedKey)  //recibe un key.algo para la key que abre y cierra el menu
 {
     this.mappedKey = mappedKey;
     drawer2D       = new Drawer2D();
     fondo          = new CustomSprite();
     bitmap         = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\startmenu.jpg", D3DDevice.Instance.Device);
     fondo.Bitmap   = bitmap;
     CalcularFullScreenScalingAndPosition(fondo);
     VariablesGlobales.managerSonido.PauseAll();
     VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.MAIN_MENU);
 }
예제 #14
0
        public EscenaGameOver(TgcCamera Camera, string MediaDir, string ShadersDir, TgcText2D DrawText, float TimeBetweenUpdates, TgcD3dInput Input) : base(Camera, MediaDir, ShadersDir, DrawText, TimeBetweenUpdates, Input)
        {
            gameOver        = new CustomSprite();
            gameOver.Bitmap = new CustomBitmap(MediaDir + "Textures\\GameOver.png", D3DDevice.Instance.Device);

            gameOver.Scaling     = new TGCVector2((float)D3DDevice.Instance.Width / gameOver.Bitmap.Width, (float)D3DDevice.Instance.Height / gameOver.Bitmap.Height);
            gameOver.Position    = new TGCVector2(0, 0);
            mp3Gameover          = new TgcMp3Player();
            mp3Gameover.FileName = MediaDir + "Music\\GameOver.mp3";
            mp3Gameover.play(true);
        }
예제 #15
0
 public void asociarObjeto(Recolectable item, float factorAncho, float factorAlto)
 {
     itemGuardado = item;
     spriteItem   = new CustomSprite
     {
         Bitmap   = new CustomBitmap(item.getRutaImagen(), D3DDevice.Instance.Device),
         Position = spriteEspacioInventario.Position,
         Scaling  = new TGCVector2(factorAncho, factorAlto),
     };
     libre = false;
 }
        public void instanciarLinternita()
        {
            drawer2D      = new Drawer2D();
            sprite        = new CustomSprite();
            sprite.Bitmap = new CustomBitmap(MediaDir + "Linternita.png", D3DDevice.Instance.Device);

            var textureSize = sprite.Bitmap.Size;

            sprite.Position = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width / 1.135f - textureSize.Width / 1.135f, 0),
                                             FastMath.Max(D3DDevice.Instance.Height / 0.99f - textureSize.Height / 0.99f, 0));

            sprite.Scaling = new TGCVector2(614.7f / D3DDevice.Instance.Width, 317.25f / D3DDevice.Instance.Height);
        }
예제 #17
0
 private void inicializarBarra()
 {
     //Crear Sprite
     barra         = new CustomSprite();
     energia       = new CustomSprite();
     barra.Bitmap  = new CustomBitmap(MediaDir + "\\barra.png", D3DDevice.Instance.Device);
     barra.Scaling = new Vector2(0.5f, 0.5f);
     // barraDuracion.Color = Color.Empty;
     //var textureSize = barra.Bitmap.Size;
     barra.Position   = new Vector2(0, 0);
     energia.Bitmap   = new CustomBitmap(MediaDir + "\\energia.png", D3DDevice.Instance.Device);
     energia.Scaling  = new Vector2(escalaActual, 0.4f);
     energia.Position = new Vector2(22 + barra.Position.X, 16 + barra.Position.Y);
 }
예제 #18
0
 public PauseMenu(Microsoft.DirectX.DirectInput.Key mappedKey)
 {//recibe un key.algo para la key que abre y cierra el menu
     this.mappedKey = mappedKey;
     drawer2D       = new Drawer2D();
     fondo          = new CustomSprite();
     bitmap_fondo   = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\pause_menu.png", D3DDevice.Instance.Device);
     fondo.Bitmap   = bitmap_fondo;
     CalcularFullScreenScalingAndPosition(fondo);
     sound            = new CustomSprite();
     bitmap_sound     = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\sound_icon.png", D3DDevice.Instance.Device);
     bitmap_sound_off = new CustomBitmap(VariablesGlobales.mediaDir + "Bitmaps\\sound_off_icon.png", D3DDevice.Instance.Device);
     CalcularChildScalingAndPosition(sound, bitmap_sound                  /*lo uso como base, total el de sound on y off son iguales*/
                                     , .90f, .90f, .05f, .1f, main_rect); //90% de x 90% de y , .5% del tamaño de la pantalla
 }//@ ver si hay alguna forma de no tener q pasar los dos scale, usar aspect_ratio del rect capaz
        public void instanciarLinternas(int porcentajeVela)
        {
            drawer2D = new Drawer2D();
            sprite   = new CustomSprite();

            sprite.Bitmap = new CustomBitmap(MediaDir + "vidaUtilLinterna\\vidaUtilLinterna" + porcentajeVela + ".png", D3DDevice.Instance.Device);

            var textureSize = sprite.Bitmap.Size;

            sprite.Position = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width / 1.001f - textureSize.Width / 1.001f, 0),
                                             FastMath.Max(D3DDevice.Instance.Height / 0.847f - textureSize.Height / 0.847f, 0));

            sprite.Scaling = new TGCVector2(751.3f / D3DDevice.Instance.Width, 387.75f / D3DDevice.Instance.Height);
        }
        public void instanciarNotas(int numeroDeNota)
        {
            drawer2D = new Drawer2D();
            sprite   = new CustomSprite();

            sprite.Bitmap = new CustomBitmap(MediaDir + "Notas\\Notas" + numeroDeNota + ".png", D3DDevice.Instance.Device);

            var textureSize = sprite.Bitmap.Size;

            sprite.Position = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width / 1 - textureSize.Width / 1, 0),
                                             FastMath.Max(D3DDevice.Instance.Height / 0.8f - textureSize.Height / 0.8f, 0));

            sprite.Scaling = new TGCVector2(546.4f / D3DDevice.Instance.Width, 282f / D3DDevice.Instance.Height);
        }
예제 #21
0
        public Cue(ICueLauncher cueLauncher, string bitmap_path, float relative_scale, TGCVector2 relative_pos, float duracion)
        {//despues agrego mas condiciones para que una cue inicie, ademas de delay
            this.cueLauncher = cueLauncher;
            drawer2D         = new Drawer2D();
            cue    = new CustomSprite();
            bitmap = new CustomBitmap(VariablesGlobales.mediaDir + bitmap_path, D3DDevice.Instance.Device);
            //@no se xq tiene ese borde azul cuando lo renderiza???
            cue.Bitmap = bitmap;

            //cue.ScalingCenter = new TGCVector2((float)cue.Bitmap.Size.Width / 2f, (float)cue.Bitmap.Size.Height / 2f);
            cue.ScalingCenter = new TGCVector2(0, 0);
            cue.Scaling       = CommonHelper.CalculateRelativeScaling(bitmap, relative_scale);
            cue.Position      = new TGCVector2(D3DDevice.Instance.Width * relative_pos.X, D3DDevice.Instance.Height * relative_pos.Y);
            this.duracion     = duracion;
        }
예제 #22
0
        private CustomSprite crearCuadrado(float posicionX, float posicionZ, float ancho, float alto, string textura, Color color)
        {
            CustomSprite sprite = new CustomSprite();

            sprite.Bitmap   = new CustomBitmap(textura, D3DDevice.Instance.Device);
            sprite.Position = new TGCVector2(posicionX, posicionZ);
            //No va directo el Alto y Ancho porque depende del tamanio que tiene la textura
            sprite.Scaling = new TGCVector2(ancho / sprite.Bitmap.Width, alto / sprite.Bitmap.Height);
            //sprite.Scaling = new TGCVector2(ancho, alto);
            if (color != Color.Transparent)
            {
                sprite.Color = color;
            }
            return(sprite);
        }
        public override void Init()
        {
            drawer2D = new Drawer2D();

            //Crear Sprite
            backgroundSprite        = new CustomSprite();
            backgroundSprite.Bitmap = new CustomBitmap(MediaDir + "\\Bitmaps\\main3.jpg", D3DDevice.Instance.Device);

            text          = new TgcText2D();
            text.Text     = "CARIBBEAN´S DEATH";
            text.Color    = Color.Red;
            text.Align    = TgcText2D.TextAlign.RIGHT;
            text.Position = new Point(D3DDevice.Instance.Width - 500, 100);
            text.Size     = new Size(300, 100);
            text.changeFont(new Font("TimesNewRoman", 25, FontStyle.Bold | FontStyle.Italic));

            //Ubicarlo centrado en la pantalla
            var textureSize = backgroundSprite.Bitmap.Size;

            backgroundSprite.Position = new TGCVector2(0, 0);
            backgroundSprite.Scaling  = new TGCVector2(0.75f, 0.35f);

            gui.Create(MediaDir);

            // menu principal
            gui.InitDialog(false, false);
            int W   = D3DDevice.Instance.Width;
            int H   = D3DDevice.Instance.Height;
            int x0  = W - 200;
            int y0  = H - 300;
            int dy  = 80;
            int dy2 = dy;
            int dx  = 200;

            gui.InsertMenuItem(ID_NUEVA_PARTIDA, "  Jugar", "play.png", x0, y0, MediaDir, dx, dy);
            gui.InsertMenuItem(ID_CONTROLES, "  Controles", "navegar.png", x0, y0 += dy2, MediaDir, dx, dy);
            gui.InsertMenuItem(ID_APP_EXIT, "  Salir", "salir.png", x0, y0        += dy2, MediaDir, dx, dy);

            music          = new TgcMp3Player();
            music.FileName = MediaDir + "\\Sounds\\mainMenuMusic.mp3";
            music.play(true);
        }
예제 #24
0
        //--------------------------------------------------------------------------------------------------//

        private void InitializeHUDSprites()
        {
            var  imgDir = Game.Default.MediaDirectory + Game.Default.ImagesDirectory;
            int  imgW, imgH;
            Size maxSize = new Size(1920, 1017);

            // Inicializamos la interface para dibujar sprites 2D
            drawer2D = new Drawer2D();

            // Sprite del HUD principal
            hudSprites = new CustomSprite
            {
                Bitmap   = new CustomBitmap(imgDir + "HUD.png", D3DDevice.Instance.Device),
                Position = TGCVector2.Zero
            };
            imgW = hudSprites.Bitmap.ImageInformation.Width;
            imgH = hudSprites.Bitmap.ImageInformation.Height;
            hudSprites.Scaling = new TGCVector2((screenWidth / (float)hudSprites.Bitmap.Width), (screenHeight / (float)hudSprites.Bitmap.Height));

            // Sprite que representa la vida
            healthBar = new CustomSprite
            {
                Bitmap   = new CustomBitmap(imgDir + "healthBar.png", D3DDevice.Instance.Device),
                Position = new TGCVector2(screenWidth * 0.8802f, screenHeight * 0.7762f)
            };
            imgW = healthBar.Bitmap.ImageInformation.Width;
            imgH = healthBar.Bitmap.ImageInformation.Height;
            healthBar.Scaling = new TGCVector2(((imgW / (float)healthBar.Bitmap.Width)) * (screenWidth / (float)maxSize.Width), ((imgH / (float)healthBar.Bitmap.Height)) * (screenHeight / (float)maxSize.Height));
            hpScale           = healthBar.Scaling;

            // Sprite de la barra de especiales
            specialBar = new CustomSprite
            {
                Bitmap   = new CustomBitmap(imgDir + "specialBar.png", D3DDevice.Instance.Device),
                Position = new TGCVector2(screenWidth * 0.8805f, screenHeight * 0.8585f)
            };
            imgW = specialBar.Bitmap.ImageInformation.Width;
            imgH = specialBar.Bitmap.ImageInformation.Height;
            specialBar.Scaling = new TGCVector2(((imgW / (float)specialBar.Bitmap.Width)) * (screenWidth / (float)maxSize.Width), ((imgH / (float)specialBar.Bitmap.Height)) * (screenHeight / (float)maxSize.Height));
            specialScale       = specialBar.Scaling;
        }
예제 #25
0
        public void CalcularFullScreenScalingAndPosition(CustomSprite fondo)
        {//para 1280x720 lo transforma en 2048x1024 (no tiene mucha precision)
            var tamanio_textura = fondo.Bitmap.Size;

            fondo.ScalingCenter = new TGCVector2(0, 0);
            if (D3DDevice.Instance.AspectRatio < 2.1f)//16:9 o parecido
            {
                fondo.Position = new TGCVector2(0, 0);

                float width  = (float)D3DDevice.Instance.Width / (float)tamanio_textura.Width;
                float height = (float)D3DDevice.Instance.Height / (float)tamanio_textura.Height;
                fondo.Scaling = new TGCVector2(width, height);
            }
            else //21:9 o parecido
            {
                fondo.Position = new TGCVector2(((float)D3DDevice.Instance.Width - ((float)D3DDevice.Instance.Width * 16f / 21.6f)) / 2, 0);
                float width  = ((float)D3DDevice.Instance.Width * 16f / 21.6f) / (float)tamanio_textura.Width;
                float height = (float)D3DDevice.Instance.Height / (float)tamanio_textura.Height;
                fondo.Scaling = new TGCVector2(width, height);
            }
        }
예제 #26
0
        public HUD()
        {
            drawer2D = new Drawer2D();

            VariablesGlobales.miniMap = new MiniMap(this.drawer2D);
            this.miniMap = VariablesGlobales.miniMap;

            misiles = new List <CustomBitmap>
            {
                new CustomBitmap(VariablesGlobales.mediaDir + misiles0, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + misiles1, D3DDevice.Instance.Device)
            };

            vidas = new List <CustomBitmap>
            {
                new CustomBitmap(VariablesGlobales.mediaDir + vidas0, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas1, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas2, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas3, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas4, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas5, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas6, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas7, D3DDevice.Instance.Device),
                new CustomBitmap(VariablesGlobales.mediaDir + vidas8, D3DDevice.Instance.Device)
            };

            HUD_misiles = new CustomSprite();

            HUD_vidas = new CustomSprite();

            HUD_misiles.Scaling = CommonHelper.CalculateRelativeScaling(misiles[0], .1f);
            HUD_vidas.Scaling   = CommonHelper.CalculateRelativeScaling(vidas[0], .1f);

            HUD_misiles.Position =
                new TGCVector2(D3DDevice.Instance.Width * .1f, D3DDevice.Instance.Height * .8f);

            HUD_vidas.Position =
                new TGCVector2(HUD_misiles.Position.X, HUD_misiles.Position.Y + HUD_misiles.Scaling.Y * misiles[0].Height); //+ D3DDevice.Instance.Height *.05f);
        }
        public override void Init()
        {
            int W   = D3DDevice.Instance.Width;
            int H   = D3DDevice.Instance.Height;
            int x0  = W / 2;
            int y0  = H / 2;
            int dy  = 80;
            int dy2 = dy;
            int dx  = 200;

            drawer2D = new Drawer2D();

            backgroundSprite          = new CustomSprite();
            backgroundSprite.Bitmap   = new CustomBitmap(MediaDir + "\\Bitmaps\\noteView.PNG", D3DDevice.Instance.Device);
            backgroundSprite.Position = new TGCVector2(W * 0.2f, H * 0.2f);
            backgroundSprite.Scaling  = new TGCVector2(0.75f, 0.35f);

            gui.Create(MediaDir);
            gui.InitDialog(false, false);

            //gui.InsertMenuItem(ID_CLOSE, "Cerrar", "close.png", x0, y0, MediaDir, dx, dy);
            gui.InsertButton(ID_CLOSE, "Cerrar", x0 - 150, y0 + 150, dx, dy, Color.DarkRed);
        }
예제 #28
0
        public Boton(CustomBitmap sprite, CustomBitmap spriteSelec, string texto, int indice, Drawer2D drawer)
        {
            CustomSprite menuSprite = new CustomSprite();

            menuSprite.Bitmap = sprite;
            CustomSprite menuSpriteSelec = new CustomSprite();

            menuSpriteSelec.Bitmap = spriteSelec;

            menuItem      = new HUDSprite(HUD.AnclajeHorizontal.LEFT, HUD.AnclajeVertical.TOP, new TGCVector2(0.05f, 0.5f + (float)indice / 17), new TGCVector2(1, 1), drawer, menuSprite);
            menuItemSelec = new HUDSprite(HUD.AnclajeHorizontal.LEFT, HUD.AnclajeVertical.TOP, new TGCVector2(0.05f, 0.5f + (float)indice / 17), new TGCVector2(1, 1), drawer, menuSpriteSelec);
            menuItem.Init();
            menuItemSelec.Init();

            TgcText2D texto2D = new TgcText2D();

            texto2D.Align = TgcText2D.TextAlign.CENTER;
            texto2D.Size  = new Size((int)(menuItem.Sprite.Scaling.X * 350), 20);
            texto2D.changeFont(new System.Drawing.Font("Calibri", D3DDevice.Instance.Width / 96f, FontStyle.Italic | FontStyle.Bold));
            texto2D.Text = texto;

            this.texto = new HUDTexto(HUD.AnclajeHorizontal.LEFT, HUD.AnclajeVertical.TOP, new TGCVector2(0.1f, 0.5175f + (float)indice / 17), drawer, texto2D);
            this.texto.Init();
        }
예제 #29
0
 /// <summary>
 ///     Draws a sprite on the screen.
 /// </summary>
 /// <param name="sprite">The sprite.</param>
 public void DrawSprite(CustomSprite sprite)
 {
     DxSprite.Transform = sprite.TransformationMatrix.ToMatrix();
     DxSprite.Draw(sprite.Bitmap.D3dTexture, sprite.SrcRect, TGCVector3.Empty, TGCVector3.Empty, sprite.Color);
 }
예제 #30
0
        public override void Init()
        {
            // Defino que se muestre la presentacion
            presentacion          = true;
            opcionMenuSelecionado = 0;
            tiempoFogataEncendida = 0;
            partidoGanado         = false;

            // Defino el Menu presentacion
            drawer2D = new Drawer2D();

            menuPresentacion        = new CustomSprite();
            menuPresentacion.Bitmap = new CustomBitmap(this.MediaDir + "\\HUD\\presentacion.png", D3DDevice.Instance.Device);
            Size textureSize = menuPresentacion.Bitmap.Size;

            menuPresentacion.Position = new Vector2(0, 0);

            escaladoProporcionalX = (float)(D3DDevice.Instance.Width * 1f / menuPresentacion.Bitmap.Size.Width * 1f);
            escaladoProporcionalY = (float)(D3DDevice.Instance.Height * 1f / menuPresentacion.Bitmap.Size.Height * 1f);

            if (escaladoProporcionalX > escaladoProporcionalY)
            {
                menuPresentacion.Scaling = new Vector2(escaladoProporcionalX, escaladoProporcionalX);
            }
            else
            {
                menuPresentacion.Scaling = new Vector2(escaladoProporcionalY, escaladoProporcionalY);
            }

            buttonUnselected         = new CustomSprite();
            buttonUnselected.Bitmap  = new CustomBitmap(MediaDir + "\\HUD\\btn-off.png", D3DDevice.Instance.Device);
            buttonUnselected.Scaling = new Vector2(0.2f, 0.2f);

            buttonSelected         = new CustomSprite();
            buttonSelected.Bitmap  = new CustomBitmap(MediaDir + "\\HUD\\btn-on.png", D3DDevice.Instance.Device);
            buttonSelected.Scaling = new Vector2(0.2f, 0.2f);

            logoWilson          = new CustomSprite();
            logoWilson.Bitmap   = new CustomBitmap(MediaDir + "\\HUD\\wilson.png", D3DDevice.Instance.Device);
            logoWilson.Scaling  = new Vector2(0.5f, 0.5f);
            logoWilson.Position = new Vector2(0, 0);

            // Para determinar que momento del día es
            usoHorario       = 0;
            tiempoAcumLluvia = 0;
            tiempoAcumHacha  = 0;

            horaDelDia = 0; //0: dia, 1:tarde, 2:noche;

            terreno = new EscenarioGame.Escenario(this);
            terreno.Init();

            personaje = new Personaje(this);
            personaje.Init();

            hud = new HUD(this);
            hud.Init();

            musica = new Musica(this.MediaDir);
            musica.selectionSound("Sonido\\ambiente1.mp3");
            musica.startSound();

            musica2 = new Musica(this.MediaDir);
            musica2.selectionSound("Sonido\\talar.mp3");


            // Inicializacion de PostProcess con Render Target

            CustomVertex.PositionTextured[] screenQuadVertices =
            {
                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.Instance.Device, 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.Instance.Device,
                                         D3DDevice.Instance.Device.PresentationParameters.BackBufferWidth
                                         , D3DDevice.Instance.Device.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
                                         Format.X8R8G8B8, Pool.Default);

            //Creamos un DepthStencil que debe ser compatible con nuestra definicion de renderTarget2D.
            depthStencil =
                D3DDevice.Instance.Device.CreateDepthStencilSurface(
                    D3DDevice.Instance.Device.PresentationParameters.BackBufferWidth,
                    D3DDevice.Instance.Device.PresentationParameters.BackBufferHeight,
                    DepthFormat.D24S8, MultiSampleType.None, 0, true);

            //Cargar shader con efectos de Post-Procesado
            effect = TgcShaders.loadEffect(ShadersDir + "PostProcess.fx");

            //Configurar Technique dentro del shader
            effect.Technique = "RainTechnique";

            //Cargar textura que se va a dibujar arriba de la escena del Render Target
            lluviaTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, this.MediaDir + "Isla\\efecto_rain.png");
            // Inicializo la camara
            InitCamera();


            // SkyBox: Se cambia el valor por defecto del farplane para evitar cliping de farplane.
            D3DDevice.Instance.Device.Transform.Projection =
                Matrix.PerspectiveFovLH(D3DDevice.Instance.FieldOfView,
                                        D3DDevice.Instance.AspectRatio,
                                        D3DDevice.Instance.ZNearPlaneDistance,
                                        D3DDevice.Instance.ZFarPlaneDistance * 2560f);


            //cajaMenu = new TgcBox();
            //cajaMenu.Position = new Vector3(0, 0, 0);
            //cajaMenu.Size = new Vector3(1000, 1000, 1000);
            //cajaMenu.AutoTransformEnable = true;


            //menuCaja = TgcTexture.createTexture(D3DDevice.Instance.Device, this.MediaDir + "\\HUD\\presentacion.jpg");
            //cajaMenu.setTexture(menuCaja);
            //cajaMenu.updateValues();
        }