Example #1
0
        /// <summary>
        ///     Crear un nuevo Sprite animado
        /// </summary>
        /// <param name="texturePath">path de la textura animada</param>
        /// <param name="frameSize">tamaño de un tile de la animacion</param>
        /// <param name="totalFrames">cantidad de frames que tiene la animacion</param>
        /// <param name="frameRate">velocidad en cuadros por segundo</param>
        public AnimatedSprite(string texturePath, Size frameSize, int totalFrames, float frameRate)
        {
            enabled          = true;
            currentFrame     = 0;
            this.frameSize   = frameSize;
            this.totalFrames = totalFrames;
            currentTime      = 0;
            playing          = true;

            //Sprite
            Bitmap = new CustomBitmap(texturePath, D3DDevice.Instance.Device);

            //Calcular valores de frames de la textura
            textureWidth    = Bitmap.Width;
            textureHeight   = Bitmap.Height;
            framesPerColumn = (int)textureWidth / frameSize.Width;
            framesPerRow    = (int)textureHeight / frameSize.Height;
            var realTotalFrames = framesPerRow * framesPerColumn;

            if (realTotalFrames > totalFrames)
            {
                throw new Exception(
                          "Error en AnimatedSprite. No coinciden la cantidad de frames y el tamaño de la textura: " +
                          totalFrames);
            }

            setFrameRate(frameRate);
        }
Example #2
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);
 }
Example #3
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?
        }
        public static TGCVector2 CalculateRelativeScaling(CustomBitmap bitmap, float scale)
        {//hace el calculo sobre width
            float screen_occupation = D3DDevice.Instance.Width * scale;
            //float screen_ratio = D3DDevice.Instance.Width / bitmap.Width;
            float escala_real = screen_occupation / bitmap.Width;

            return(new TGCVector2(escala_real, escala_real));
        }
Example #5
0
        private TGCVector2 CalculeRelativeScaling(CustomBitmap bitmap, float width, float height, float scale_x, float scale_y)
        {//hace el calculo sobre width
            float screen_occupation_x = width * scale_x;
            float screen_occupation_y = height * scale_y;
            //float screen_ratio = D3DDevice.Instance.Width / bitmap.Width;
            float escala_real_x = screen_occupation_x / bitmap.Width;
            float escala_real_y = screen_occupation_y / bitmap.Height;

            return(new TGCVector2(escala_real_x, escala_real_y));
        }
Example #6
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);
 }
Example #7
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);
 }
Example #8
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
Example #9
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;
        }
        public void Init()
        {
            correctFactorWidth  = Device.Viewport.Width / originalWidth;
            correctFactorHeigth = Device.Viewport.Height / originalHeigth;

            bitmapTomasFace          = new CustomBitmap(MediaDir + "Level1\\Textures\\" + "tomasFace.png", Device);
            spriteTomasFace.Bitmap   = bitmapTomasFace;
            spriteTomasFace.Scaling  = new TGCVector2(0.25f * correctFactorWidth, 0.2f * correctFactorHeigth);
            spriteTomasFace.Position = new TGCVector2(Device.Viewport.Width / 1.3f, Device.Viewport.Height / 30f);
            sprites.Add(spriteTomasFace);

            bitmapOxygenBar          = new CustomBitmap(MediaDir + "Level1\\Textures\\" + "oxygenBar.png", Device);
            spriteOxygenBar.Bitmap   = bitmapOxygenBar;
            spriteOxygenBar.Scaling  = new TGCVector2(0.4f * correctFactorWidth, 1f * correctFactorHeigth);
            spriteOxygenBar.Position = new TGCVector2(Device.Viewport.Width / 1.2f, Device.Viewport.Height / 30f);
            sprites.Add(spriteOxygenBar);

            bitmapHealthBar          = new CustomBitmap(MediaDir + "Level1\\Textures\\" + "healthBar.png", Device);
            spriteHealthBar.Bitmap   = bitmapHealthBar;
            spriteHealthBar.Scaling  = new TGCVector2(0.4f * correctFactorWidth, 1f * correctFactorHeigth);
            spriteHealthBar.Position = new TGCVector2(Device.Viewport.Width / 1.2f, Device.Viewport.Height / 12f);
            sprites.Add(spriteHealthBar);
        }
Example #11
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();
        }