示例#1
0
        // Methods
        /// Constructor
        public Menu()
        {
            buttons.Add(new HButton(Translation.GetString("play")));
            buttons.Add(new HButton(Translation.GetString("skills")));
            buttons.Add(new HButton(Translation.GetString("options")));
            buttons.Add(new HButton(Translation.GetString("code")));
            buttons.Add(new HButton(Translation.GetString("credits")));
            buttons.Add(new HButton(Translation.GetString("logout")));

            // Resizes the window
            HeadWars.Resize(250, 130 + (buttons.Count * 32));

            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].setPosition(0, 60 + (i * 45), "xcenter");
            }

            // Title
            label = new HLabel(Translation.GetString("menu"), Font.WindowTitle);
            label.setPosition(0, 0, "xcenter top");

            if (HeadWars.changedSoundtrack)
            {
                MediaPlayer.Play(Sound.MenuMusic);
                HeadWars.changedSoundtrack = false;
            }
        }
示例#2
0
        // Methods
        /// Constructor
        public Login()
        {
            // Resizes the window
            HeadWars.Resize(310, 220);

            HeadWars.playerName = "";

            // Nickname
            labels.Add(new HLabel(Translation.GetString("username"), Font.TextBold, 30, 90));
            textboxes.Add(new HTextBox(30, 110, 12, false, 110));
            // Password
            labels.Add(new HLabel(Translation.GetString("password"), Font.TextBold, 30, 150));
            textboxes.Add(new HTextBox(30, 170, 14, true, 110));

            // Warning
            labels.Add(new HLabel(warning = "", Font.Text));
            labels[2].textColor(Color.Yellow);

            // Title
            labels.Add(new HLabel(Translation.GetString("login"), Font.WindowTitle));
            labels[3].setPosition(0, 0, "xcenter top");

            buttons.Add(new HButton(Translation.GetString("login"), 155, 110));
            buttons.Add(new HButton(Translation.GetString("new_account"), 155, 170));
        }
示例#3
0
        // Methods
        /// Constructor
        public SkillTree()
        {
            // Resizes the window
            HeadWars.Resize(650, 430);

            // Title
            labels.Add(new HLabel(Translation.GetString("skill_tree"), Font.WindowTitle));
            labels[0].setPosition(0, 0, "xcenter top");

            // Points
            labels.Add(new HLabel(string.Format("{0}: {1:###}", Translation.GetString("points"), Info.levelPoint.ToString()), Font.BigTextBold));
            labels[1].setPosition(0, -50, "xcenter bottom");
            labels[1].textColor(Color.DeepSkyBlue);

            // Skills
            foreach (SkillManager.Skill skill in SkillManager.skillData.Values)
            {
                skillLabels[skill.ID] = skill.CurrentStage + "/" + skill.Stages;
                skillData.Add(skill);
            }
            summonTriangle(5, (int)HeadWars.ScreenDimension.X / 2, 100, 32);

            // Redistribute
            buttons.Add(new HButton(Translation.GetString("redistribute")));
            buttons[0].setPosition(-60, 0, "right bottom");

            sublabels.Add(new HLabel(Translation.GetString("redistribute_cost"), Font.Text));
            sublabels[15].textColor(Color.Yellow);
            subsquares.Add(new HSquare(0, 0, (int)sublabels[15].measureString().X, (int)sublabels[15].measureString().Y));

            // Back to Menu
            buttons.Add(new HButton(Translation.GetString("button_back")));
            buttons[1].setPosition(60, 0, "left bottom");

            // Level bar
            int total = (100 * (Info.totalExperience - SkillManager.levelToExp(Info.level))) / (SkillManager.levelToExp(Info.level + 1) - SkillManager.levelToExp(Info.level)) * 2;

            levelPanelTexture   = new Texture2D(HeadWars.Instance.GraphicsDevice, 204, 16);
            levelPanelRectangle = new Rectangle((int)HeadWars.ScreenDimension.X / 2 - 98 + total, (int)HeadWars.ScreenDimension.Y - 38, 196 - total, 16);

            levelBorderPanelTexture   = new Texture2D(HeadWars.Instance.GraphicsDevice, 200, 20);
            levelBorderPanelRectangle = new Rectangle((int)HeadWars.ScreenDimension.X / 2 - 100, (int)HeadWars.ScreenDimension.Y - 40, 200, 20);

            levelPanelTexture.Fill(levelPanelTexture.Width * levelPanelTexture.Height);
            levelBorderPanelTexture.Fill(levelBorderPanelRectangle.Width * levelBorderPanelRectangle.Height);

            labels.Add(new HLabel(Translation.GetString("level") + " " + Info.level, Font.SmallTextBold));
            labels[2].setPosition(0, (int)HeadWars.ScreenDimension.Y - 55, "xcenter");
            labels.Add(new HLabel(levelBorderPanelRectangle, (Info.totalExperience - SkillManager.levelToExp(Info.level)) + "/" + (SkillManager.levelToExp(Info.level + 1) - SkillManager.levelToExp(Info.level)), Font.Text));
            labels[3].textColor(Color.White);
            labels[3].Name = "ExperienceBar";
        }
示例#4
0
        // Methods
        /// Constructor
        public Code()
        {
            // Resizes the window
            HeadWars.Resize(320, 300);

            labels.Add(new HLabel(Translation.GetString("secret_code"), Font.WindowTitle));
            labels[0].setPosition(0, 0, "xcenter top");

            // Code
            textboxes.Add(new HTextBox(0, 0, 17, false, 250, 45));
            textboxes[0].setFont(Font.MediumTextBold);
            textboxes[0].setPosition(0, 40, "xcenter ycenter");

            buttons.Add(new HButton(Translation.GetString("validate"), 0, 0));
            buttons[0].setPosition(0, 90, "xcenter ycenter");

            labels.Add(new HLabel(message = "", Font.Text));
            labels[1].setPosition(0, 140, "xcenter");

            buttons.Add(new HButton(Translation.GetString("button_back"), 0, 0));
            buttons[1].setPosition(0, 0, "left bottom");

            // QR Code
            DatabaseManager.Connect();
            string data = DatabaseManager.getCode();

            DatabaseManager.Disconnect();

            if (data == null)
            {
                QRCodeTexture = Graphic.no_code;
            }
            else
            {
                BarcodeSettings settings = new BarcodeSettings
                {
                    Unit           = GraphicsUnit.Pixel,
                    Type           = BarCodeType.QRCode,
                    ResolutionType = ResolutionType.UseDpi,
                    BackColor      = System.Drawing.Color.White,
                    ForeColor      = System.Drawing.Color.Black,
                    X    = 4,
                    Data = data,
                    DpiY = 1,
                    DpiX = 1
                };

                BarCodeGenerator generator = new BarCodeGenerator(settings);
                QRCodeTexture = bitmapToTexture2D((Bitmap)generator.GenerateImage());
            }
            QrCodeRectangle = new Microsoft.Xna.Framework.Rectangle(0, 0, QRCodeTexture.Width, QRCodeTexture.Height);
        }
示例#5
0
        // Methods
        /// Constructor
        public Game(Boolean skipMusic = false)
        {
            // Resizes the window
            HeadWars.Resize(850, 600);

            // Texts
            labels.Add(new HLabel("", Font.Game));
            labels.Add(new HLabel("", Font.Game));
            labels.Add(new HLabel("", Font.Game));
            labels.Add(new HLabel(string.Format(Translation.GetString("menu_redirect"), 0), Font.BigTextBold));
            labels[3].setPosition(0, 270, "xcenter");

            labels[1].textColor(Color.Red);
            labels[2].textColor(Color.Yellow);

            // Buttons
            // Pause
            squares.Add(new HSquare(Graphic.pause));
            squares[0].setColor(Color.Transparent.Collection());
            squares[0].setClickSound = Sound.toggleButton;

            // Continue
            buttons.Add(new HButton(Translation.GetString("new_game"), 0, 0, 120, 50));
            buttons[0].setPosition(0, 370, "xcenter");

            // Resume
            buttons.Add(new HButton(Translation.GetString("resume"), 0, 0, 200, 50));
            buttons[1].setFont(Font.BigTextBold);
            buttons[1].setPosition(0, -50, "xcenter ycenter");

            // Leave game
            buttons.Add(new HButton(Translation.GetString("leave_game"), 0, 0, 200, 50));
            buttons[2].setFont(Font.BigTextBold);
            buttons[2].setPosition(0, 50, "xcenter ycenter");

            // Menu
            buttons.Add(new HButton(Translation.GetString("menu"), 0, 0, 120, 50));
            buttons[3].setPosition(0, 440, "xcenter");

            EntityManager.Clear();
            Score.Reset();
            EntityManager.New(Player.Instance);

            if (!skipMusic)
            {
                MediaPlayer.Play(Sound.GameMusic);
                HeadWars.changedSoundtrack = true;
            }

            gameOverTimer = 5f;
            hasRecorded   = false;
        }
示例#6
0
        // Methods
        /// Constructor
        public Settings()
        {
            // Resizes the window
            HeadWars.Resize(300, 400);

            // Title
            labels.Add(new HLabel(Translation.GetString("options"), Font.WindowTitle));
            labels[0].setPosition(0, 0, "xcenter top");

            // Volume slider
            labels.Add(new HLabel(Translation.GetString("music"), Font.TextBold, 25, 65));
            sliders.Add(new HSlider(30, 95, (int)musicVolume[0], 100, 100));

            labels.Add(new HLabel(Translation.GetString("sound"), Font.TextBold, 175, 65));
            sliders.Add(new HSlider(180, 95, (int)soundVolume[0], 100, 100));

            // Control
            labels.Add(new HLabel(Translation.GetString("movement"), Font.TextBold, 25, 125));
            labels.Add(new HLabel(Translation.GetString("aiming"), Font.TextBold, 185, 125));

            squares.Add(new HSquare(Graphic.reverse, 123, 120));
            squares[0].setColor(Color.Transparent.Collection());
            squares[0].setClickSound = Sound.toggleButton;

            for (int i = 0; i < 8; i++)
            {
                int     id = (i > 3 ? i - 4 : i);
                HButton b  = new HButton(controls[(i < 4 ? !inversed : inversed) ? 0 : 1, id], (i < 4 ? 25 : 185) + 21 * id, 155, 20, 20);
                b.setColor(Color.GhostWhite.Collection(), Color.Black.Collection());
                b.setFont(Font.TextBold);
                b.setClickSound = b.setHoverSound = null;
                buttons.Add(b);
            }

            // Fullscreen

            /*
             * labels.Add(new HLabel(Translation.GetString("fullscreen"), Font.TextBold, 25, 190));
             * buttons.Add(new HButton(HeadWars.fullscreen ? Translation.GetString("enabled") : Translation.GetString("disabled"), 25, 215));
             */

            // Languages
            labels.Add(new HLabel(Translation.GetString("language"), Font.TextBold, 175, 190));
            comboboxes.Add(new HComboBox(Translation.langues, 175, 215, Translation.langues.FindIndex(l => l == Translation.CurrentLanguage)));

            // Back to Menu
            buttons.Add(new HButton(Translation.GetString("button_back"), 25, 360));
        }
        // Methods
        /// Constructor
        public CharacterSelector()
        {
            sprites.Clear();

            // Resizes the window
            HeadWars.Resize(570, 320);

            // Title
            labels.Add(new HLabel(Translation.GetString("character_selector"), Font.WindowTitle));
            labels[0].setPosition(0, 0, "xcenter top");

            // Next and Previous
            buttons.Add(new HButton(">>>>"));
            buttons[0].setPosition(110, 0, "xcenter ycenter");

            buttons.Add(new HButton("<<<<"));
            buttons[1].setPosition(-110, 0, "xcenter ycenter");

            // Select
            buttons.Add(new HButton(Translation.GetString("select")));
            buttons[2].setPosition(-5, -5, "right bottom");

            // Back to Menu
            buttons.Add(new HButton(Translation.GetString("button_back")));
            buttons[3].setPosition(5, -5, "left bottom");

            // Textures
            characterPanelTexture   = new Texture2D(HeadWars.Instance.GraphicsDevice, 100, 100);
            characterPanelRectangle = new Rectangle((int)HeadWars.ScreenDimension.X / 2 - 50, (int)HeadWars.ScreenDimension.Y / 2 - 50, 100, 100);
            characterPosition       = new Vector2(characterPanelRectangle.X + 50, characterPanelRectangle.Y + 50);

            characterPanelTexture.Border(20, Color.CadetBlue);

            // spriteData
            SetSprites();
            NormalizeCharacter();

            // Texts
            labels.Add(new HLabel("« " + GetSprite("name") + " »", Font.MediumTextBold));
            labels[1].setPosition(0, -80, "xcenter ycenter");
            labels[1].textColor(Color.Yellow);

            labels.Add(new HLabel(GetSprite("description"), Font.TextBold));
            labels[2].setPosition(0, 80, "xcenter ycenter");
        }
示例#8
0
        // Methods
        /// Constructor
        public Credits()
        {
            // Resizes the window
            HeadWars.Resize(350, 150 + ((creditsData.Count - 1) * 40));

            // Title
            labels.Add(new HLabel(Translation.GetString("credits"), Font.WindowTitle));
            labels[0].setPosition(0, 0, "xcenter top");

            foreach (List <object> o in creditsData)
            {
                labels.Add(new HLabel((string)o[1], Font.TextBold, 20, 75 + ((int)o[0] * 40)));
                sublabels.Add(new HLabel(Translation.GetString((string)o[2]), Font.Text));
                squares.Add(new HSquare(0, 0, (int)sublabels[(int)o[0]].measureString().X, (int)sublabels[(int)o[0]].measureString().Y));
            }

            // Back to Menu
            buttons.Add(new HButton(Translation.GetString("button_back")));
            buttons[0].setPosition(0, 0, "left bottom");
        }
示例#9
0
        // Methods
        /// Constructor
        public GameMode()
        {
            HeadWars.mode = -1;

            buttons.Add(new HButton(Translation.GetString("normal")));
            buttons.Add(new HButton("ETECH"));
            // Back to Menu
            buttons.Add(new HButton(Translation.GetString("button_back")));

            // Resizes the window
            HeadWars.Resize(200, 70 + (buttons.Count * 40));

            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].setPosition(0, 70 + (i * 40), "xcenter");
            }

            // Title
            label = new HLabel(Translation.GetString("modes"), Font.WindowTitle);
            label.setPosition(0, 0, "xcenter top");
        }
示例#10
0
        // Methods
        /// Constructor
        public ModeOption()
        {
            if (HeadWars.mode == 1)
            {
                buttons.Add(new HButton("MB"));
                buttons.Add(new HButton("I"));
            }

            // Back to GameMode
            buttons.Add(new HButton(Translation.GetString("button_back")));

            // Resizes the window
            HeadWars.Resize(200, 70 + (buttons.Count * 40));

            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].setPosition(0, 70 + (i * 40), "xcenter");
            }

            // Title
            label = new HLabel(Translation.GetString("modes"), Font.WindowTitle);
            label.setPosition(0, 0, "xcenter top");
        }