Esempio n. 1
0
 //Metodo che viene assegnato ai bottoni della griglia
 private void OperationGrid(IButton button)
 {
     if (button.GetType() == typeof(ButtonGrid))
     {
         button.Activated = true;
         ButtonGrid bg = (ButtonGrid)button;
         if (_gameAdapter.GameActive && !bg.Used)
         {
             _gameAdapter.Play(bg.Place);
             bg.Used = true;
         }
     }
 }
Esempio n. 2
0
        //Metodo utilizato per caricare i contenuti
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatchExt(GraphicsDevice);
            //Carica i Texture
            _oTexture   = Content.Load <Texture2D>("O");
            _xTexture   = Content.Load <Texture2D>("X");
            _grid       = Content.Load <Texture2D>("Grid");
            _background = Content.Load <Texture2D>("Sfondo");
            _empty      = Content.Load <Texture2D>("Empty");
            //Carica i font
            _font = Content.Load <SpriteFont>("SpriteFont1");
            //Inizializzazzione  interfaccia utente
            //Griglia
            _gridPosition.X = (Window.ClientBounds.Width - 320) / 2;
            _gridPosition.Y = (Window.ClientBounds.Height - 320) / 2;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    IButton button = new ButtonGrid(_empty, new Rectangle(((int)_gridPosition.X) + 110 * i, ((int)_gridPosition.Y) + 110 * j, 100, 100), i * 3 + j + 1);
                    button.Operation = OperationGrid;
                    _list.Add(button);
                }
            }
            //Bottone New Play
            ButtonWithLabel buttonPlay = new ButtonWithLabel(_font, "New Game", new Vector2(20, 20), _background);

            buttonPlay.Operation = OperationNewGame;
            _list.Add(buttonPlay);
            //Bottoni della selectMode
            _buttonFirst            = new ButtonWithLabel(_font, "I want to go first!", new Vector2(Window.ClientBounds.Width / 8, Window.ClientBounds.Height - 40), _background);
            _buttonSecond           = new ButtonWithLabel(_font, "I want to go second!", new Vector2(5 * Window.ClientBounds.Width / 8, Window.ClientBounds.Height - 40), _background);
            _buttonFirst.Operation  = OperationFirst;
            _buttonSecond.Operation = OperationSecond;
            //Bottone inverti icona
            _buttonInvert           = new ButtonWithLabel(_font, "Your icon " + (_invertedIcon?"O":"X"), new Vector2(20, 50), _background);
            _buttonInvert.Operation = OperationInvert;
            _list.Add(_buttonInvert);
        }
Esempio n. 3
0
 public void DrawButton(ButtonGrid button, Color color)//Disegna un ButtonGrid
 {
     base.Draw(button.Texture, button.Rectangle, Color.White);
 }