コード例 #1
0
        private void InitUI()
        {
            uiSimpleHost = new SimpleHost();

            const float rectWidth  = 200f;
            const float rectHeight = 30f;

            uiEngineRectangle    = new Rectangle();
            uiBattalionRectangle = new Rectangle();
            uiRescueRectangle    = new Rectangle();

            uiEngineRectangle.Location    = AdvancedUI.Util.ConvertToCurrentCoordSystem(new PointF(1920 / 2 - rectWidth * 1.75f, 40));
            uiBattalionRectangle.Location = AdvancedUI.Util.ConvertToCurrentCoordSystem(new PointF(1920 / 2 - rectWidth * 0.5f, 40));
            uiRescueRectangle.Location    = AdvancedUI.Util.ConvertToCurrentCoordSystem(new PointF(1920 / 2 + rectWidth * 0.75f, 40));

            uiEngineRectangle.Size = uiBattalionRectangle.Size = uiRescueRectangle.Size = AdvancedUI.Util.ConvertToCurrentCoordSystem(new SizeF(rectWidth, rectHeight));

            uiEngineRectangle.Color = uiBattalionRectangle.Color = uiRescueRectangle.Color = Color.FromArgb(165, 5, 5, 5);

            uiEngineLabel    = new Label();
            uiBattalionLabel = new Label();
            uiRescueLabel    = new Label();

            uiEngineLabel.Text    = FirefighterRole.Engine.ToString();
            uiBattalionLabel.Text = FirefighterRole.Battalion.ToString();
            uiRescueLabel.Text    = FirefighterRole.Rescue.ToString();

            uiEngineLabel.Alignment = uiBattalionLabel.Alignment = uiRescueLabel.Alignment = TextAlignment.Center;

            uiEngineLabel.Color = uiBattalionLabel.Color = uiRescueLabel.Color = Color.White;

            uiEngineLabel.Location    = new PointF(uiEngineRectangle.Location.X + uiEngineRectangle.Size.Width / 2, uiEngineRectangle.Location.Y);
            uiBattalionLabel.Location = new PointF(uiBattalionRectangle.Location.X + uiBattalionRectangle.Size.Width / 2, uiBattalionRectangle.Location.Y);
            uiRescueLabel.Location    = new PointF(uiRescueRectangle.Location.X + uiRescueRectangle.Size.Width / 2, uiRescueRectangle.Location.Y);

            uiSelectionRectangle          = new Rectangle();
            uiSelectionRectangle.Color    = Color.FromArgb(160, Color.Red);
            uiSelectionRectangle.Size     = new SizeF(rectWidth + 10, rectHeight + 10);
            uiSelectionRectangle.Location = new PointF(uiEngineRectangle.Location.X - 5, uiEngineRectangle.Location.Y - 5);

            uiSimpleHost.Elements.Add(uiSelectionRectangle);
            uiSimpleHost.Elements.Add(uiEngineRectangle);
            uiSimpleHost.Elements.Add(uiBattalionRectangle);
            uiSimpleHost.Elements.Add(uiRescueRectangle);
            uiSimpleHost.Elements.Add(uiEngineLabel);
            uiSimpleHost.Elements.Add(uiBattalionLabel);
            uiSimpleHost.Elements.Add(uiRescueLabel);

            uiSimpleHost.Elements.ShowAll();
        }
コード例 #2
0
        private void MoveUISelection(FirefighterRole role)
        {
            GameFiber.StartNew(() =>
            {
                PointF origLoc    = uiSelectionRectangle.Location;
                Rectangle objRect = GetUIRectangleForRole(role);
                PointF objLoc     = new PointF(objRect.Location.X - 5, objRect.Location.Y - 5);

                float percent = 0.0f;
                while (percent < 1.0f)
                {
                    GameFiber.Sleep(5);

                    float x = MathHelper.Lerp(origLoc.X, objLoc.X, percent);
                    uiSelectionRectangle.Location = new PointF(x, uiSelectionRectangle.Location.Y);

                    percent += 0.0425f;
                }
                uiSelectionRectangle.Location = objLoc;
            });
        }