Пример #1
0
 public override void Initialize()
 {
     this.Data = InitializeGameData();
     this.Data.Town.Initialize();
     _ui = InitializeUI();
     _ui.Initialize(this.Data.Town);
     this.Data.Town.AddCards(_ui.ScrollBox);
     this.Data.Town.SetResourceLabel = _ui.UpdateResourceCounts;
 }
Пример #2
0
        private BuildStateUI InitializeUI()
        {
            SpriteFont   buttonFont      = Content.Load <SpriteFont>("DebugFont");
            BuildStateUI newBuildStateUI = new BuildStateUI();

            #region Resource Labels
            TextBox woodLabel = new TextBox(buttonFont);
            TextBox woodCount = new TextBox(buttonFont);
            woodLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_WOOD;
            woodCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_WOOD;
            woodLabel.TextAlignment = TextBox.TextAlign.Left;
            woodCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(woodLabel);
            newBuildStateUI.RegisterResourceLabel(woodCount, GameCode.Resource.ResourceType.Wood);

            TextBox stoneLabel = new TextBox(buttonFont);
            TextBox stoneCount = new TextBox(buttonFont);
            stoneLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_STONE;
            stoneCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_STONE;
            stoneLabel.TextAlignment = TextBox.TextAlign.Left;
            stoneCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(stoneLabel);
            newBuildStateUI.RegisterResourceLabel(stoneCount, GameCode.Resource.ResourceType.Stone);

            TextBox oreLabel = new TextBox(buttonFont);
            TextBox oreCount = new TextBox(buttonFont);
            oreLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_ORE;
            oreCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_ORE;
            oreLabel.TextAlignment = TextBox.TextAlign.Left;
            oreCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(oreLabel);
            newBuildStateUI.RegisterResourceLabel(oreCount, GameCode.Resource.ResourceType.Ore);

            TextBox metalLabel = new TextBox(buttonFont);
            TextBox metalCount = new TextBox(buttonFont);
            metalLabel.TextBoxInfo   = ControlConstants.RESOURCE_LABEL_METAL;
            metalCount.TextBoxInfo   = ControlConstants.RESOURCE_COUNTER_METAL;
            metalLabel.TextAlignment = TextBox.TextAlign.Left;
            metalCount.TextAlignment = TextBox.TextAlign.Right;
            newBuildStateUI.Add(metalLabel);
            newBuildStateUI.RegisterResourceLabel(metalCount, GameCode.Resource.ResourceType.Metal);
            #endregion

            #region ScrollBox

            ScrollBox scrollBox = new ScrollBox(Content, ControlConstants.BUILD_SCROLLBOX);
            newBuildStateUI.Add(scrollBox);
            newBuildStateUI.RegisterScrollBox(scrollBox);


            #endregion

            #region Cancel Button

            Button cancelButton = new Button(Content, ControlConstants.CANCEL_BUTTON_INFO);
            cancelButton.BackColour  = ControlConstants.CANCEL_BUTTON_COLOR;
            cancelButton.HoverColour = ControlConstants.CANCEL_BUTTON_HOVER_COLOR;
            cancelButton.Click      += Data.Town.CancelPlacementButton_Click;
            newBuildStateUI.Add(cancelButton);

            Button removeStructure = new Button(Content, ControlConstants.REMOVE_STRUCTURE_BUTTON_INFO);
            removeStructure.BackColour  = ControlConstants.REMOVE_STRUCTURE_BUTTON_COLOR;
            removeStructure.HoverColour = ControlConstants.REMOVE_STRUCTURE_BUTTON_HOVER_COLOR;
            removeStructure.Click      += Data.Town.RemoveStructureButton_Click;
            newBuildStateUI.Add(removeStructure);


            #endregion

            return(newBuildStateUI);
        }