Пример #1
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (ModHelper.MouseInRectangle(uiRectangle) && inventoryItem.type != ItemID.None && inventoryItem != null)
     {
         Main.hoverItemName = inventoryItem.Name;
         Main.HoverItem     = inventoryItem.Clone();
     }
     spriteBatch.Draw(buttonImage, uiPosition, uiColor);
     if (inventoryItem.type != ItemID.None && inventoryItem != null)
     {
         var   frame    = Main.itemAnimations[inventoryItem.type] != null ? Main.itemAnimations[inventoryItem.type].GetFrame(Main.itemTexture[inventoryItem.type]) : Main.itemTexture[inventoryItem.type].Frame(1, 1, 0, 0);
         var   size     = frame.Size();
         float texScale = 1f;
         if ((size.X > uiRectangle.Width || size.Y > uiRectangle.Height) && useScaleChange)
         {
             texScale = size.X > size.Y ? size.X / uiRectangle.Width : size.Y / uiRectangle.Height;
             texScale = 0.8f / texScale;
             size    *= texScale;
         }
         spriteBatch.Draw(Main.itemTexture[inventoryItem.type], uiPosition + uiCenter - size / 2 + itemOffset, new Rectangle?(frame), uiColor, 0, Vector2.Zero, texScale, 0, 0);
         if (inventoryItem.stack > 1)
         {
             spriteBatch.DrawString(Main.fontMouseText, inventoryItem.stack.ToString(), new Vector2(uiRectangle.X + 10, uiRectangle.Y + uiRectangle.Height - 20), Color.White);
         }
     }
 }
Пример #2
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     base.Draw(spriteBatch);
     if (slotActive && (Main.npcShop != 0 || Main.HoverItem.favorited || Main.LocalPlayer.chest != -1))
     {
         slotActive = false;
     }
     if (!slotActive)
     {
         return;
     }
     for (int i = 0; i < 9; i++)
     {
         if (Grid[i] == null)
         {
             continue;
         }
         Grid[i].uiColor = new Color(215, 215, 215, 215);
         if (ModHelper.MouseInRectangle(Grid[i].uiRectangle))
         {
             Grid[i].uiColor = Color.White;
         }
         Grid[i].Start();
     }
 }
Пример #3
0
 public int HoverOnSlot()
 {
     foreach (CardInventoryGridSlot Gri in Grid)
     {
         if (ModHelper.MouseInRectangle(Gri.uiRectangle))
         {
             return(Grid.IndexOf(Gri));
         }
     }
     return(-1);
 }
Пример #4
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Player         clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);
            bool           Animationing    = StartAnimation && AnimationTimer >= 1 ? true : false;

            uiWidth  = 38;
            uiHeight = 50;
            float alpha = 0.36f;

            if (!Animationing && ModHelper.MouseInRectangle(uiRectangle) && inventoryItem.type != ItemID.None && inventoryItem != null)
            {
                if (PlayerTurn && clientModPlayer.CardGameLeftCard > 0)
                {
                    Main.hoverItemName = $"{inventoryItem.Name}\n点击以使用";
                    alpha = 1f;
                }
            }
            // 没有UI贴图
            //spriteBatch.Draw(ModContent.GetTexture("Entrogic/UI/Cards/HelpGrid"), finalUIPosition, uiColor);
            if (!Animationing && inventoryItem.type != ItemID.None && inventoryItem != null)
            {
                Texture2D t     = Main.itemTexture[inventoryItem.type];
                var       frame = Main.itemAnimations[inventoryItem.type] != null ? Main.itemAnimations[inventoryItem.type].GetFrame(Main.itemTexture[inventoryItem.type]) : Main.itemTexture[inventoryItem.type].Frame(1, 1, 0, 0);
                spriteBatch.Draw(t, finalUIPosition, (Rectangle?)frame, Color.White * alpha);
            }

            if (Animationing)
            {
                Texture2D t     = Main.itemTexture[inventoryItem.type];
                var       frame = Main.itemAnimations[inventoryItem.type] != null ? Main.itemAnimations[inventoryItem.type].GetFrame(Main.itemTexture[inventoryItem.type]) : Main.itemTexture[inventoryItem.type].Frame(1, 1, 0, 0);

                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.UIScaleMatrix);
                // Retrieve reference to shader
                var whiteBlur = GameShaders.Misc["Entrogic:WhiteBlur"];
                // Reset back to default value.
                whiteBlur.UseOpacity(0f);
                if (AnimationTimer > 15f)
                {
                    whiteBlur.UseOpacity(MathHelper.Min((AnimationTimer - 15f) / 8f, 1f));
                }
                whiteBlur.Apply(null);

                spriteBatch.Draw(t, AnimationPosition + fatherPosition, (Rectangle?)frame, Color.White);

                // As mentioned above, be sure not to forget this step.
                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix);
            }
        }
Пример #5
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            int       frameHeight = buttonImage.Height / 3;
            Rectangle frame       = new Rectangle(0, 0, buttonImage.Width, frameHeight);

            uiHeight = frameHeight;
            Player         clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);

            if (ModHelper.MouseInRectangle(uiRectangle) && clientModPlayer.CardGamePlayerTurn)
            {
                Main.hoverItemName = "确认";
                frame = new Rectangle(0, 1 * frameHeight, buttonImage.Width, frameHeight);
            }
            if (!clientModPlayer.CardGamePlayerTurn)
            {
                frame = new Rectangle(0, 2 * frameHeight, buttonImage.Width, frameHeight);
            }
            spriteBatch.Draw(buttonImage, finalUIPosition, (Rectangle?)frame, uiColor);
        }
Пример #6
0
 /// <summary>
 /// 启用UI。
 /// </summary>
 public void Start( )
 {
     PreEvent();
     UIEvent();
     Click      += ClickEvent;
     RightClick += RightClickEvent;
     Pressed    += PressedEvent;
     Released   += ReleasedEvent;
     if (ModHelper.MouseInRectangle(uiRectangle))
     {
         if (!canUseItem)
         {
             Main.LocalPlayer.mouseInterface = true;
         }
         if (Main.mouseLeft && Main.mouseLeftRelease)
         {
             Click.Invoke();
         }
         if (Main.mouseRight && Main.mouseRightRelease)
         {
             RightClick.Invoke();
         }
         else if (Main.mouseLeft)
         {
             Pressed.Invoke();
         }
         else if (Main.mouseLeftRelease)
         {
             Released.Invoke();
         }
     }
     Click      -= ClickEvent;
     RightClick -= RightClickEvent;
     Pressed    -= PressedEvent;
     Released   -= ReleasedEvent;
     Draw(Main.spriteBatch);
     PostEvent();
 }
Пример #7
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Player         clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);

            GamePanel.Left.Pixels = PanelPos.X;
            GamePanel.Top.Pixels  = PanelPos.Y;
            // 原版很香
            base.Draw(spriteBatch);
            if (!IsUseBiggerTexture)
            {
                DrawBulletsParticles(spriteBatch);
            }

            // 再Draw一个透明板子
            switch (IsUseBiggerTexture)
            {
            case false:
                spriteBatch.Draw(GetTexture("Entrogic/UI/CardGame/CardGamePanel_Front"), PanelPos, Color.White);
                break;
            }
            // Draw确认按钮
            ConfirmButton.fatherPosition = PanelPos;
            ConfirmButton.Start();
            // 对局魔力值显示
            if (clientModPlayer.CardGameLeftCard >= 1)
            {
                spriteBatch.Draw(GetTexture("Entrogic/UI/CardGame/ManaCrystal"), PanelPos + new Vector2(424, 342), Color.White);
            }
            if (clientModPlayer.CardGameLeftCard >= 2)
            {
                spriteBatch.Draw(GetTexture("Entrogic/UI/CardGame/ManaCrystal"), PanelPos + new Vector2(456, 342), Color.White);
            }
            if (clientModPlayer.CardGameLeftCard >= 3)
            {
                spriteBatch.Draw(GetTexture("Entrogic/UI/CardGame/ManaCrystal"), PanelPos + new Vector2(488, 342), Color.White);
            }

            if (clientModPlayer.CardGameNPCIndex == -1)
            {
                goto IL_DRAWBIGTEXTUREPARTICLES;
            }
            NPC npc = Main.npc[clientModPlayer.CardGameNPCIndex];
            CardFightableNPC fightNPC    = (CardFightableNPC)npc.modNPC;
            string           ImgPath     = "Entrogic/Images/CardFightPlayer";
            Vector2          ImgPosition = new Vector2(274f, 12f);

            fightNPC.SetupContents(ref ImgPath, ref ImgPosition);
            // Deathing: 0.没失败者, 1.玩家失败, 2.NPC失败
            if (Deathing == 0)
            {
                // Draw玩家&NPC血条
                // 构成:第一层:FightPanel
                //       第二层:原贴图
                //       第三层:Surface
                //       第四层:Bar
                // 玩家:
                Texture2D FightPanel_Player = Entrogic.ModTexturesTable["CardFightPlayer_FightPanel"];
                Texture2D Surface_Player    = Entrogic.ModTexturesTable["CardFightPlayer_Surface"];
                Texture2D Bar_Player        = Entrogic.ModTexturesTable["CardFightPlayer_Bar"];
                Texture2D Player            = Entrogic.ModTexturesTable["CardFightPlayer"];
                Vector2   drawPosition      = new Vector2(274f, 314f);
                spriteBatch.Draw(FightPanel_Player, PanelPos + drawPosition, Color.White * (1f - clientModPlayer.CardGameHealthAlpha));
                // 只有在血量变动的时候显示血量
                spriteBatch.Draw(Player, PanelPos + drawPosition, Color.White * clientModPlayer.CardGameHealthAlpha);
                // 计算出1所占的像素
                int   maxhealth   = Math.Max(1000, clientModPlayer.CardGamePlayerMaxHealth); // 防止除以0
                float tpercentone = (float)(Surface_Player.Height - 4) / (float)maxhealth;   // -4去掉上下的光边面积
                // 这个值跑满了是(Surface_Player.Height - 4)
                int varhealth = LastRecordHealthPlayer - clientModPlayer.CardGamePlayerHealth;
                DelayHealthPercentPlayer = Math.Min(DelayHealthPercentPlayer + 0.05f, 1f);
                int tdrawHeight = (int)(tpercentone * (LastRecordHealthPlayer - (varhealth * DelayHealthPercentPlayer)));
                // 所以这里-2,X值纠正到跑满了是2,刚好是丢掉光边的顶端X值。Height+1把光边补上来,1px玩家不会在意的
                Rectangle tPerRectangle = new Rectangle(0, Surface_Player.Height - 2 - tdrawHeight, Surface_Player.Width, tdrawHeight + 1);
                Vector2   drawPos       = PanelPos + drawPosition;
                drawPos.Y += Surface_Player.Height - 2 - tdrawHeight;
                spriteBatch.Draw(Surface_Player, drawPos.NoShake(), (Rectangle?)tPerRectangle, Color.White * (1f - clientModPlayer.CardGameHealthAlpha));
                // 水面比水下多出2像素,所以水下的要-2
                tPerRectangle.Y      += 2;
                tPerRectangle.Height -= 2;
                drawPos.Y            += 2f;
                spriteBatch.Draw(Bar_Player, drawPos.NoShake(), (Rectangle?)tPerRectangle, Color.White * (1f - clientModPlayer.CardGameHealthAlpha));
                // 玩家鼠标移上去显示血量
                if (ModHelper.MouseInRectangle(new Rectangle((int)(PanelPos + drawPosition).X, (int)(PanelPos + drawPosition).Y, Player.Width, Player.Height)))
                {
                    Main.hoverItemName = $"{Language.GetTextValue("Mods.Entrogic.Common.You")}: {clientModPlayer.CardGamePlayerHealth} / {clientModPlayer.CardGamePlayerMaxHealth}";
                }
                // NPC:
                Texture2D FightPanel_NPC = GetTexture($"{ImgPath}_FightPanel");
                Texture2D Surface_NPC    = GetTexture($"{ImgPath}_Surface");
                Texture2D Bar_NPC        = GetTexture($"{ImgPath}_Bar");
                Texture2D NPC            = GetTexture($"{ImgPath}_Fight");
                //Texture2D FightPanel_NPC = Entrogic.ModTexturesTable["CardFightPlayer_FightPanel"];
                //Texture2D Surface_NPC = Entrogic.ModTexturesTable["CardFightPlayer_Surface"];
                //Texture2D Bar_NPC = Entrogic.ModTexturesTable["CardFightPlayer_Bar"];
                //Texture2D NPC = Entrogic.ModTexturesTable["CardFightPlayer"];
                spriteBatch.Draw(FightPanel_NPC, PanelPos + ImgPosition, Color.White * (1f - clientModPlayer.CardGameNPCHealthAlpha));
                // 只有在血量变动的时候显示血量
                spriteBatch.Draw(NPC, PanelPos + ImgPosition, Color.White * clientModPlayer.CardGameNPCHealthAlpha);
                // 计算出1所占的像素
                maxhealth   = Math.Max(1000, clientModPlayer.CardGameNPCMaxHealth); // 防止除以0
                tpercentone = (float)(Surface_NPC.Height - 4) / (float)maxhealth;   // -4去掉上下的光边面积
                // 这个值跑满了是(Surface_NPC.Height - 4)
                varhealth             = LastRecordHealthNPC - clientModPlayer.CardGameNPCHealth;
                DelayHealthPercentNPC = Math.Min(DelayHealthPercentNPC + 0.05f, 1f);
                tdrawHeight           = (int)(tpercentone * (LastRecordHealthNPC - (varhealth * DelayHealthPercentNPC)));
                // 所以这里-2,X值纠正到跑满了是2,刚好是丢掉光边的顶端X值。Height+1把光边补上来,1px玩家不会在意的
                tPerRectangle = new Rectangle(0, Surface_NPC.Height - 2 - tdrawHeight, Surface_NPC.Width, tdrawHeight + 1);
                drawPos       = PanelPos + ImgPosition;
                drawPos.Y    += Surface_NPC.Height - 2 - tdrawHeight;
                spriteBatch.Draw(Surface_NPC, drawPos.NoShake(), (Rectangle?)tPerRectangle, Color.White * (1f - clientModPlayer.CardGameNPCHealthAlpha));
                // 水面比水下多出2像素,所以水下的要-2
                tPerRectangle.Y      += 2;
                tPerRectangle.Height -= 2;
                drawPos.Y            += 2f;
                spriteBatch.Draw(Bar_NPC, drawPos.NoShake(), (Rectangle?)tPerRectangle, Color.White * (1f - clientModPlayer.CardGameNPCHealthAlpha));
                // 玩家鼠标移上去显示血量
                if (ModHelper.MouseInRectangle(new Rectangle((int)(PanelPos + ImgPosition).X, (int)(PanelPos + ImgPosition).Y, Player.Width, Player.Height)))
                {
                    Main.hoverItemName = $"{npc.GivenName}: {clientModPlayer.CardGameNPCHealth} / {clientModPlayer.CardGameNPCMaxHealth}";
                }
                //Main.hoverItemName = $"{Language.GetTextValue($"Mods.{fightNPC.mod.ToString().Split('.')[0]}.NPCName.{fightNPC.Name}")}: {clientModPlayer.CardGameNPCHealth} / {clientModPlayer.CardGameNPCMaxHealth}";
            }
            else
            {
                DeathTimer++;
                Texture2D Tex          = Deathing == 1 ? Entrogic.ModTexturesTable["CardFightPlayer"] : GetTexture($"{ImgPath}_Fight");
                Vector2   drawPosition = new Vector2(274f, 314f);
                if (DeathTimer <= 120f + 20f)
                {
                    Main.spriteBatch.SafeEnd();
                    Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.UIScaleMatrix);
                    // Retrieve reference to shader
                    var deathShader = GameShaders.Misc["ExampleMod:DeathAnimation"];
                    // Reset back to default value.
                    deathShader.UseOpacity(1f);
                    // We use AnimationTimer as a counter since the real death.
                    if (DeathTimer > 20f)
                    {
                        // Our shader uses the Opacity register to drive the effect. See ExampleEffectDeath.fx to see how the Opacity parameter factors into the shader math.
                        deathShader.UseOpacity(1f - (DeathTimer - 20f) / 120f);
                        if (DeathTimer % 60f == 21f)
                        {
                            Main.PlaySound(SoundID.NPCDeath22, npc.Center); // every second while dying, play a sound
                        }
                    }
                    // Call Apply to apply the shader to the SpriteBatch. Only 1 shader can be active at a time.
                    deathShader.Apply(null);

                    spriteBatch.Draw(Tex, PanelPos + (Deathing == 1 ? drawPosition : ImgPosition), Color.White);

                    // As mentioned above, be sure not to forget this step.
                    Main.spriteBatch.SafeEnd();
                    Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix);
                }
                Tex = Deathing == 2 ? Entrogic.ModTexturesTable["CardFightPlayer"] : GetTexture($"{ImgPath}_Fight");
                spriteBatch.Draw(Tex, PanelPos + (Deathing == 2 ? drawPosition : ImgPosition), Color.White);
                if (DeathTimer >= 150f + 20f)
                {
                    QuitGame();
                }
            }
IL_DRAWBIGTEXTUREPARTICLES:
            // Draw槽
            NPCCardSlot.fatherPosition = PanelPos;
            NPCCardSlot.Start();
            foreach (var slot in HandCardSlots)
            {
                slot.fatherPosition = PanelPos;
                slot.Start();
            }
            if (IsUseBiggerTexture)
            {
                DrawBulletsParticles(spriteBatch, true);
            }

IL_DRAWTIP:
            Texture2D TipTexture = GetTexture("Entrogic/UI/CardGame/CardGameTurnTip");
            int max = 15;

            if (TimerCountdown < 60)
            {
                AnimationTimer = Math.Min(AnimationTimer + 1, max);
                if (AnimationTimer >= max)
                {
                    TimerCountdown++;
                }
            }
            else
            {
                AnimationTimer--;
            }
            if (AnimationTimer <= 0)
            {
                return;
            }
            // 计算出1所占的像素
            float     percentone   = (float)TipTexture.Height / (float)max;
            int       drawHeight   = (int)(percentone * AnimationTimer);
            Rectangle PerRectangle = new Rectangle(0, TipTexture.Height - drawHeight, TipTexture.Width, drawHeight);
            Vector2   AniPos       = new Vector2(PanelCenter.X - TipTexture.Width / 2f, PanelPos.Y); // Panel左边多出10px

            spriteBatch.Draw(TipTexture, AniPos.NoShake(), (Rectangle?)PerRectangle, Color.White);
            // 提示信息
            if (AnimationTimer != max)
            {
                goto IL_DRAWTOPBAR;
            }
            float   hsize   = Main.fontMouseText.MeasureString(TurnText).X / 2f;
            Vector2 textPos = PanelCenter;

            textPos.X -= hsize;
            textPos.Y  = PanelPos.Y + 12f;
            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, TurnText, textPos, TurnTextColor, 0f, Vector2.Zero, Vector2.One);
            // 再Draw顶端,看起来好看一点
IL_DRAWTOPBAR:
            spriteBatch.Draw(GetTexture("Entrogic/UI/CardGame/CardGameTop"), PanelPos, Color.White);
        }