示例#1
0
 /// <summary>
 /// Gestiona las entradas por teclado del usuario.
 /// </summary>
 /// <param name="key">Tecla pulsada por el usuario.</param>
 /// <returns>Devuelve un objeto tipo Screen en función de las acciones del usuario.</returns>
 public Screen KeyboardAction(Keys key)
 {
     if (key == Keys.Tab)
     {
         if (BtnFocused != null)
         {
             changeFocus();
         }
         else
         {
             BtnFocused  = btns[0];
             btns[0].Img = BtnSelected;
         }
     }
     else if (key == Keys.Enter)
     {
         if (BtnFocused != null)
         {
             if (BtnFocused == BtnCreate)
             {
                 return(new CreateScreen(Game));
             }
             else if (BtnFocused == BtnJoin)
             {
                 return(new JoinScreen(Game));
             }
         }
     }
     return(this);
 }
示例#2
0
 /// <summary>
 /// Carga el contenido necesario en memoria.
 /// </summary>
 public void LoadContent()
 {
     BtnBack     = new Boton(0, 0, Game.Content.Load <Texture2D>("Sprites/btnBack"), ScreenWidth / 12);
     BtnSelected = Game.Content.Load <Texture2D>("Sprites/btnSelected");
     BtnDefault  = Game.Content.Load <Texture2D>("Sprites/btnDefault");
     Font        = Game.Content.Load <SpriteFont>("Fuentes/FuenteValor");
     BtnInput    = new TextBox(
         ScreenWidth / 2 - ScreenWidth * 3 / 8,
         ScreenHeight / 2,
         Game.Content.Load <Texture2D>("Sprites/textBoxSelected"),
         Game.Content.Load <Texture2D>("Sprites/textBoxSelected"),
         ScreenWidth * 3 / 4,
         Font,
         true
         );
     ErrorFont = Game.Content.Load <SpriteFont>("Fuentes/Error");
     BtnStart  = new Boton(
         ScreenWidth / 2 - ScreenWidth / 3 / 2,
         ScreenHeight * 3 / 4,
         BtnDefault,
         ScreenWidth / 3,
         ErrorFont,
         "Create room"
         );
 }
示例#3
0
 /// <summary>
 /// Carga el contenido necesario en memoria.
 /// </summary>
 public void LoadContent()
 {
     Font        = Game.Content.Load <SpriteFont>("Fuentes/FuenteValor");
     ErrorFont   = Game.Content.Load <SpriteFont>("Fuentes/Error");
     BtnSelected = Game.Content.Load <Texture2D>("Sprites/btnSelected");
     BtnDefault  = Game.Content.Load <Texture2D>("Sprites/btnDefault");
     BtnJoin     = new Boton(
         ScreenWidth / 2 - ScreenWidth / 6,
         ScreenHeight / 2,
         Game.Content.Load <Texture2D>("Sprites/btnDefault"),
         ScreenWidth / 3,
         ErrorFont,
         "Join room"
         );
     BtnCreate = new Boton(
         ScreenWidth / 2 - ScreenWidth / 6,
         ScreenHeight * 3 / 4,
         Game.Content.Load <Texture2D>("Sprites/btnDefault"),
         ScreenWidth / 3,
         ErrorFont,
         "Create room"
         );
     btns.Add(BtnCreate);
     btns.Add(BtnJoin);
 }
示例#4
0
 /// <summary>
 /// Borra el focus de todos los botones de la pantalla.
 /// </summary>
 public void clearButtons()
 {
     foreach (Boton btn in btns)
     {
         btn.Img = BtnDefault;
     }
     BtnFocused = null;
 }
示例#5
0
 /// <summary>
 /// Se encarga del refresco de pantalla. Se realiza 60 veces por segundo.
 /// </summary>
 /// <param name="gameTime">Valor temporal interno.</param>
 /// <returns></returns>
 public Screen Update(GameTime gameTime)
 {
     foreach (Boton btn in btns)
     {
         if (btn.isHover(Mouse.GetState().X, Mouse.GetState().Y))
         {
             clearButtons();
             btn.Img    = BtnSelected;
             BtnFocused = btn;
         }
     }
     return(this);
 }
示例#6
0
 /// <summary>
 /// Actualiza el focus de los botones.
 /// </summary>
 public void changeFocus()
 {
     foreach (Boton btn in btns)
     {
         if (btn == BtnFocused)
         {
             clearButtons();
             btn.Img    = BtnDefault;
             BtnFocused = btns.IndexOf(btn) >= btns.Count - 1 ? btns[0] : btns[btns.IndexOf(btn) + 1];
             btns[btns.IndexOf(BtnFocused)].Img = BtnSelected;
             return;
         }
     }
 }
示例#7
0
        /// <summary>
        /// Carga el contenido necesario en memoria.
        /// </summary>
        public void LoadContent()
        {
            BtnSelected = Game.Content.Load <Texture2D>("Sprites/btnSelected");
            BtnDefault  = Game.Content.Load <Texture2D>("Sprites/btnDefault");
            ErrorFont   = Game.Content.Load <SpriteFont>("Fuentes/Error");
            BtnBack     = new Boton(
                ScreenWidth / 2 - ScreenWidth / 4 / 2,
                ScreenHeight * 3 / 5,
                BtnSelected,
                ScreenWidth / 4,
                ErrorFont,
                "Volver"
                );

            Font = Game.Content.Load <SpriteFont>("Fuentes/Fuente");
        }
示例#8
0
 /// <summary>
 /// Carga el contenido necesario en memoria.
 /// </summary>
 public void LoadContent()
 {
     ErrorFont   = Game.Content.Load <SpriteFont>("Fuentes/Error");
     BtnSelected = Game.Content.Load <Texture2D>("Sprites/btnSelected");
     BtnDefault  = Game.Content.Load <Texture2D>("Sprites/btnDefault");
     BtnStart    = new Boton(
         ScreenWidth / 2 - ScreenWidth / 8,
         ScreenHeight * 17 / 20,
         Game.Content.Load <Texture2D>("Sprites/btnDefault"),
         ScreenWidth / 4,
         ErrorFont,
         "Join room"
         );
     BtnBack = new Boton(
         0,
         0,
         Game.Content.Load <Texture2D>("Sprites/btnBack"),
         ScreenWidth / 12
         );
     InputDefault  = Game.Content.Load <Texture2D>("Sprites/textBox");
     InputSelected = Game.Content.Load <Texture2D>("Sprites/textBoxSelected");
     DefaultFont   = Game.Content.Load <SpriteFont>("Fuentes/File");
     InputFont     = Game.Content.Load <SpriteFont>("Fuentes/FuenteValor");
     TxtInputRoom  = new TextBox(
         ScreenWidth / 2 - ScreenWidth * 3 / 8,
         ScreenHeight * 7 / 20 - InputDefault.Height,
         InputSelected,
         InputDefault,
         ScreenWidth * 3 / 4,
         InputFont,
         true
         );
     Focused      = TxtInputRoom;
     TxtInputName = new TextBox(
         ScreenWidth / 2 - ScreenWidth * 3 / 8,
         ScreenHeight * 15 / 20 - InputDefault.Height,
         InputSelected,
         InputDefault,
         ScreenWidth * 3 / 4,
         InputFont,
         false
         );
     inputs.Add(TxtInputName);
     inputs.Add(TxtInputRoom);
 }
示例#9
0
 /// <summary>
 /// Carga el contenido necesario en memoria.
 /// </summary>
 public void LoadContent()
 {
     BtnSelected = Game.Content.Load <Texture2D>("Sprites/btnSelected");
     BtnDefault  = Game.Content.Load <Texture2D>("Sprites/btnDefault");
     ErrorFont   = Game.Content.Load <SpriteFont>("Fuentes/Error");
     Font        = Game.Content.Load <SpriteFont>("Fuentes/File");
     BtnStart    = new Boton(
         ScreenWidth / 2 - ScreenWidth / 4 / 2,
         ScreenHeight * 4 / 5,
         BtnDefault,
         ScreenWidth / 4,
         ErrorFont,
         "Start game"
         );
     BtnBack = new Boton(
         0,
         0,
         Game.Content.Load <Texture2D>("Sprites/btnBack"),
         ScreenWidth / 12
         );
 }
示例#10
0
 /// <summary>
 /// Carga el contenido necesario en memoria.
 /// </summary>
 public void LoadContent()
 {
     for (int i = 3; i < 8; i++)
     {
         ImgCards.Add(i.ToString(), Game.Content.Load <Texture2D>("Sprites/" + i));
     }
     ImgCards.Add("bucle", Game.Content.Load <Texture2D>("Sprites/bucle"));
     ImgCards.Add("minus", Game.Content.Load <Texture2D>("Sprites/minus"));
     ImgCards.Add("plus", Game.Content.Load <Texture2D>("Sprites/plus"));
     ImgCards.Add("selectedCard", Game.Content.Load <Texture2D>("Sprites/selectedCard"));
     //Cargamos la fuente del juego
     DefaultFont     = Game.Content.Load <SpriteFont>("Fuentes/Fuente");
     FontValue       = Game.Content.Load <SpriteFont>("Fuentes/FuenteValor");
     ExampleCard     = ImgCards["3"];
     CardPosition    = new Vector2(Column / 10, ScreenHeight * 7 / 8 - ExampleCard.Height / 2);
     BtnPlay         = new Boton(ScreenWidth / 2 - ScreenWidth / 8, ScreenHeight / 2, Game.Content.Load <Texture2D>("Sprites/btnJugar"), ScreenWidth / 8);
     BtnPass         = new Boton(ScreenWidth / 2, ScreenHeight / 2, Game.Content.Load <Texture2D>("Sprites/btnPasar"), ScreenWidth / 8);
     BtnNextCard     = new Boton(ScreenWidth - ScreenWidth / 15, ScreenHeight - ScreenWidth / 15, Game.Content.Load <Texture2D>("Sprites/btnNextCard"), ScreenWidth / 15);
     BtnPreviousCard = new Boton(0, ScreenHeight - ScreenWidth / 15, Game.Content.Load <Texture2D>("Sprites/btnPreviousCard"), ScreenWidth / 15);
     BtnSelectedCard = new Boton(0, 0, ImgCards["selectedCard"], Column);
     ConnectThread   = new Thread(() => refreshData());
     ConnectThread.Start();
 }
示例#11
0
 /// <summary>
 /// Inicializa todas las propiedades y variables de la clase.
 /// </summary>
 public void Initialize()
 {
     ScreenWidth  = Game.Graphics.GraphicsDevice.Viewport.Width;
     ScreenHeight = Game.Graphics.GraphicsDevice.Viewport.Height;
     BtnFocused   = null;
 }