Exemplo n.º 1
0
        private void initPickZoneDialog(int player, int nbOfZone)
        {
            UIElements.SimpleButton button = new UIElements.SimpleButton(
            _buttonStretchImage,
            new Rectangle(0, 0, 150, 90),
            "OK");

            Rectangle boxArea = new Rectangle(0, 0, 400, 600);

            _pickZoneDialog = new DialogBoxes.TargetedDialogBox(
                _miniUIs[player], button, 0.7f,
                PlayerData.Instance[player].Name + "\n"
                + "Please, pick " + nbOfZone + " free territories",
                boxArea
                , _messageStretchImage);

            _pickZoneDialog.Position = MyGame.ScreenCenter;
            _pickZoneDialog.Show();

            _currentDialog = _pickZoneDialog;
        }
Exemplo n.º 2
0
        private void initProgressBar()
        {
            _timeSinceLastQuestion = 0f;
            //_questionId = questionInfo.id;

            Rectangle progressArea = new Rectangle((int)MyGame.ScreenCenter.X - 300, (int)MyGame.ScreenCenter.Y - 300
                , 600, 50);
            //_progressBar = new UIElements.ProgressBar(_UIBack, _UIBack, progressArea);
            _animatedFire = new UIElements.AnimatedTexture(_fireSprite, _fireSprite.Width / 4, _fireSprite.Height, 0.1f, true);
            _animatedFire.Scale = 0.3f;
            _progressBar = new UIElements.AnimatedProgressBar(_animatedFire, _ropeSprite, progressArea);

            MessageDialogBox msgBox = new MessageDialogBox("You should be answering questions on your phone right now",
                new Rectangle(0, 0, 400, 600), _messageStretchImage);
            msgBox.Position = MyGame.ScreenCenter;
            msgBox.Show();

            _currentDialog = msgBox;
        }
Exemplo n.º 3
0
        private void initCommandersInstructionsDialog()
        {
            UIElements.SimpleButton button = new UIElements.SimpleButton(
            _buttonStretchImage,
            new Rectangle((int)MyGame.ScreenCenter.X - 150, (int)MyGame.ScreenCenter.Y + MyGame.ScreenArea.Height / 4
                , 300, 125),
            "OK");

            Rectangle boxArea = new Rectangle(0, 0, 400, 600);

            _commanderInstructionsDialog = new DialogBoxes.ButtonDialogBox(
                button,
                "Spread your commanders on the territories you own.\nChoose wisely.",
                boxArea,
                _messageStretchImage);

            _commanderInstructionsDialog.Position = MyGame.ScreenCenter;
            _commanderInstructionsDialog.Show();

            _currentDialog = _commanderInstructionsDialog;
        }
Exemplo n.º 4
0
 private void clearProgressAndDialog()
 {
     if (_progressBar != null)
     {
         lock (_progressBar)
         {
             _progressBar = null;
         }
     }
     _currentDialog = null;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Handle the picking of new zones by the players
        /// </summary>
        /// <param name="players"> An ordonated list of the players </param>
        /// <param name="nbOfZones"> An ordonated list (same order as the players') of the bumber of zones each player can pick</param>
        /// <param name="dt"></param>
        public void pickZonesForPLayers(List<int> players, List<int> nbOfZones, float dt)
        {
            if (_pickZoneData == null)
            {
                _pickZoneData = new PickZoneData();
                _pickZoneData.currentIndex = 0;

                //init for first player

                //display dialog
                initPickZoneDialog(players[_pickZoneData.currentIndex],
                    nbOfZones[_pickZoneData.currentIndex]);
            }

            commonUpdate(dt);

            if (pickZonesForPlayer(players[_pickZoneData.currentIndex]
                , nbOfZones[_pickZoneData.currentIndex], dt))
            {
                Console.WriteLine("\nzones captured for player : " + players[_pickZoneData.currentIndex] + "\n"
                    + " captured : " + _pickZoneData.zonePicked[players[_pickZoneData.currentIndex]].Count);
                //send added territories for this player
                ServerCom.Instance.Socket.Emit("capturedTerritories", new
                {
                    gameID = players[_pickZoneData.currentIndex]
                    ,
                    territories = _pickZoneData.zonePicked[players[_pickZoneData.currentIndex]]
                });

                //move to next player
                ++_pickZoneData.currentIndex;
                _afterButtonTimer = 0f;

                //re display dialog for new player
                if (_pickZoneData.currentIndex < players.Count)
                {
                    if (nbOfZones[_pickZoneData.currentIndex] == 0)
                    {
                        //TODO send empty capturedTerritories message
                        ServerCom.Instance.Socket.Emit("capturedTerritories", new
                                                       {
                                                           gameID = players[_pickZoneData.currentIndex]
                            ,
                                                           territories = new List<int>()
                                                       });

                        ++_pickZoneData.currentIndex;
                    }
                    else
                    {
                        initPickZoneDialog(players[_pickZoneData.currentIndex],
                            nbOfZones[_pickZoneData.currentIndex]);
                    }
                }

                //all players have picked zones
                if (_pickZoneData.currentIndex >= players.Count)
                {
                    _pickZoneData = null;
                    //send message to server
                    _currentDialog = null;
                    //_updateAction = oldUpdate;
                    //_updateAction = placeCommanderUpdate;
                    Console.WriteLine("\nsetting update method to empty\n");
                    _updateAction = emptyUpdate;
                }
            }
        }
Exemplo n.º 6
0
        private void questionWaitUpdate(float dt)
        {
            if (_progressBar == null)
            {
                initProgressBar();
            }

            lock (_progressBar)
            {
                if (_animatedFire != null)
                {
                    _animatedFire.update(dt);
                    updateDialogBox(dt);
                }

                commonUpdate(dt);

                _timeSinceLastQuestion += dt;
                //display progress bar
                _progressBar.Progress = _timeSinceLastQuestion / _questionMaxAllowedTime;

                bool cheat = false;

                KeyboardState keyState = Keyboard.GetState();
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter)
                    && keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space))
                {
                    cheat = true;
                }

                //send timeout onEnd
                if (_timeSinceLastQuestion >= _questionMaxAllowedTime || cheat)
                {
                    Console.WriteLine("send timeout");
                    ServerCom.Instance.Socket.Emit("timeout", new
                    {
                        id = 0//_questionId
                    });

                    _progressBar = null;
                    _currentDialog = null;
                    UpdateAction = emptyUpdate;
                }
            }
        }
Exemplo n.º 7
0
        public WaitingRoom()
        {
            Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(
                (int)MyGame.ScreenCenter.X - _buttonWidth / 2
                , (int)(MyGame.ScreenCenter.Y * 1.75f) - _buttonHeight / 2
                , _buttonWidth
                , _buttonHeight);

            _buttonBack = MyGame.ContentManager.Load<Texture2D>("Images/buttonScroll");
            _roomBackground = MyGame.ContentManager.Load<Texture2D>("Images/WaitingBack");
            _playerUIBack = MyGame.ContentManager.Load<Texture2D>("Images/playerScroll");

            Texture2D messageBack = MyGame.ContentManager.Load<Texture2D>("Images/messageScroll");

            Rectangle stretchAreaButton = new Rectangle(15, 20, 70, 60);

            UIElements.StretchableImage stretchButtonTexture = new UIElements.StretchableImage(_buttonBack, stretchAreaButton);

            _startButton = new UIElements.SimpleButton(stretchButtonTexture, area, "Start Game");

            _playerUIs = new List<UIElements.LargePLayerUI>();

            _posStart = new Vector2(MyGame.ScreenArea.Width / 5, 470f);
            _offset = new Vector2(MyGame.ScreenArea.Width / 5, 0f);

            //Create QR Code

            QRCodeEncoder encoder = new QRCodeEncoder();
            string ip = Utils.LocalIPAddress();

            Console.WriteLine("\n\n\n\nServer ip : " + ip + "\n\n\n");

            if (ip == "")
            {

                Rectangle stretchAreaMessage = new Rectangle(30, 30, 40, 40);
                UIElements.StretchableImage stretchImg = new UIElements.StretchableImage(messageBack, stretchAreaMessage);

                Console.WriteLine("Creating dialog");
                _dialog = new ConditionalDialogBox(
                    delegate() { return Utils.LocalIPAddress() != ""; }
                    , "Network could not be reached\n"
                    + "Please find de way to connect to a reliable, working network\n"
                    + "(Unice hotsport is NOT one of those networks...)"
                    , new Microsoft.Xna.Framework.Rectangle((int)MyGame.ScreenCenter.X , (int)MyGame.ScreenCenter.Y , 600, 600)
                    , stretchImg);

                _dialog.Position = MyGame.ScreenCenter;
                _dialog.Show();
            }
            else
            {

                System.Drawing.Bitmap qrCodeImage = encoder.Encode(ip);

                Color[] pixels = new Color[qrCodeImage.Width * qrCodeImage.Height];
                for (int y = 0; y < qrCodeImage.Height; y++)
                {
                    for (int x = 0; x < qrCodeImage.Width; x++)
                    {
                        System.Drawing.Color c = qrCodeImage.GetPixel(x, y);
                        pixels[(y * qrCodeImage.Width) + x] = new Color(c.R, c.G, c.B, c.A);
                    }
                }

                _QRCode = new Texture2D(
                  MyGame.SpriteBatch.GraphicsDevice,
                  qrCodeImage.Width,
                  qrCodeImage.Height);

                _QRCode.SetData<Color>(pixels);

                int recWidth = MyGame.ScreenArea.Width / 8;
                _QrCodeArea = new Rectangle((int)(MyGame.ScreenCenter.X - recWidth / 2), 30, recWidth, recWidth);

                NodeJSClient.ServerCom.Instance.playerConnectCB = OnPlayerConnect;
                NodeJSClient.ServerCom.Instance.Execute();

                //initializeRadialUI();
            }
        }