public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            //Vector2 upperleft2 = GetDimensions().ToRectangle().TopLeft();
            //spriteBatch.Draw(Main.magicPixel, new Rectangle((int)(upperleft2.X ), (int)(upperleft2.Y), 16, 16),
            //			null, Color.White);
            Vector2 upperleft = tilePanel.GetDimensions().ToRectangle().TopLeft();

            if (preview != null)
            {
                spriteBatch.Draw(preview, tilePanel.GetDimensions().ToRectangle(), Color.White);
            }
        }
        public override void OnInitialize()
        {
            _collapseOn = false;
            windowPanel = new UIAdvPanel(ServerSideCharacter2.ModTexturesTable["AdvInvBack1"]);
            windowPanel.Left.Set(Main.screenWidth / 2 - TOOLBAR_INIT_WIDTH / 2, 0f);
            windowPanel.Top.Set(Main.screenHeight - 12f, 0f);
            windowPanel.Width.Set(TOOLBAR_INIT_WIDTH, 0f);
            windowPanel.Height.Set(TOOLBAR_INIT_HEIGHT, 0f);
            windowPanel.Color      = Color.Transparent;
            windowPanel.CornerSize = new Vector2(12, 12);

            _openButton = new UIButton(ServerSideCharacter2.ModTexturesTable["CollapseButtonUp"], false);
            _openButton.Left.Set(Main.screenWidth / 2 - 122f, 0f);
            _openButton.Top.Set(windowPanel.GetDimensions().Position().Y - 12f, 0f);
            _openButton.Width.Set(48f, 0f);
            _openButton.Height.Set(14f, 0f);
            _openButton.ButtonDefaultColor = Color.White;
            _openButton.ButtonChangeColor  = new Color(0.8f, 0.8f, 0.8f, 1f);
            _openButton.Tooltip            = "打开底栏";
            _openButton.OnClick           += OpenPanel_OnClick;

            SetUpButtons();
            ShowButtons();
            base.Append(_openButton);
            base.Append(windowPanel);
        }
        public override void Update(GameTime gameTime)
        {
            var maxH = Main.screenHeight - TOOLBAR_INIT_HEIGHT - 12f;

            if (_collapseOn && windowPanel.Top.Pixels > maxH)
            {
                windowPanel.Top.Set(windowPanel.Top.Pixels - 6f, 0f);
                if (windowPanel.Top.Pixels < maxH)
                {
                    windowPanel.Top.Pixels = maxH;
                }
                windowPanel.Color = Color.White;
            }
            else if (!_collapseOn && windowPanel.Top.Pixels < Main.screenHeight)
            {
                windowPanel.Top.Set(windowPanel.Top.Pixels + 6f, 0f);
                if (windowPanel.Top.Pixels >= Main.screenHeight)
                {
                    windowPanel.Color      = Color.Transparent;
                    windowPanel.Top.Pixels = Main.screenHeight;
                }
            }
            if (windowPanel.Top.Pixels > Main.screenHeight)
            {
                windowPanel.Top.Set(Main.screenHeight, 0f);
            }
            _openButton.Left.Set(windowPanel.GetDimensions().Center().X - 24f, 0f);
            _openButton.Top.Set(windowPanel.Top.Pixels - 12f, 0f);
            base.Update(gameTime);
        }
Beispiel #4
0
 private IEnumerator <ICoroutineInstruction> _lotteryTask(List <Item> items)
 {
     listItems.Clear();
     for (int i = 0; i < 3; i++)
     {
         chestImage.Frame = i;
         yield return(new WaitForFrames(20));
     }
     for (int i = 0; i < items.Count; i++)
     {
         var    dim  = chestImage.GetDimensions().Center();
         UISlot slot = new UISlot();
         slot.Width.Set(50, 0f);
         slot.Height.Set(50, 0f);
         slot.Top.Pixels    = dim.Y - 25f;
         slot.Left.Pixels   = dim.X - 25f;
         slot.ContainedItem = items[i].Clone();
         unionsPanel.Append(slot);
         listItems.Add(slot);
         Vector2 targetpos = new Vector2(5 + 55 * i, 5);
         Vector2 startPos  = new Vector2(dim.X - 25f - unionsPanel.GetDimensions().X, dim.Y - 25f - unionsPanel.GetDimensions().Y);
         for (int j = 0; j <= 30; j++)
         {
             float   factor = j / 30f;
             Vector2 pos    = Vector2.Lerp(startPos, targetpos, factor);
             slot.Top.Pixels  = pos.Y;
             slot.Left.Pixels = pos.X;
             slot.Opacity     = factor;
             slot.Recalculate();
             yield return(new SkipFrame());
         }
     }
 }