示例#1
0
        public void ActiveAnimation()
        {
            StartAnimation = true;
            AnimationTimer = 0;

            Player           clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer   clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);
            NPC              npc             = Main.npc[clientModPlayer.CardGameNPCIndex];
            CardFightableNPC fightNPC        = (CardFightableNPC)npc.modNPC;
            Item             item            = new Item();
            // 命名空间的第一个字符串即为Mod内部名(当然乱命名也没法了)
            Mod currentCardMod = ModLoader.GetMod(fightNPC.currentCard.GetType().FullName.Split('.')[0]);

            // 通过类名寻找相应物品
            item.SetDefaults(currentCardMod.GetItem(fightNPC.currentCard.GetType().Name).item.type);
            inventoryItem = item;
            //foreach (var card in Entrogic.ModItems)
            //{
            //    // 通过命名空间寻找相应卡牌
            //    if (card.GetType().FullName == fightNPC.currentCard.GetType().FullName)
            //    {
            //        Item item = new Item();
            //        item.SetDefaults(card.item.type);
            //        inventoryItem = item;
            //    }
            //}
        }
示例#2
0
        public void StartGame()
        {
            Player           clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer   clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);
            NPC              npc             = Main.npc[clientModPlayer.CardGameNPCIndex];
            CardFightableNPC fightNPC        = (CardFightableNPC)npc.modNPC;

            clientModPlayer.CardGamePlayerHealth = clientModPlayer.CardGamePlayerMaxHealth;
            clientModPlayer.CardGameActive       = true;
            clientModPlayer.CardGaming           = true;
            fightNPC.CardGameHealth = fightNPC.CardGameHealthMax;
            fightNPC.CardGaming     = true;
            Main.npcChatText        = "";

            PlayerTurnOver = false;
            clientModPlayer.CardGamePlayerTurn = true;
            IsUseBiggerTexture = true;
            clientModPlayer._bullets.Clear();
            clientModPlayer._particles.Clear();
            clientModPlayer.CardGameLeftCard = 1;
            //List<int> buffer = new List<int>();
            //foreach (int card in clientModPlayer.CardType)
            //    buffer.Add(card);
            //for (int i = 0; i < clientModPlayer.CardGameType.Length; i++)
            //{
            //    int chosed = Main.rand.Next(0, buffer.Count);
            //    clientModPlayer.CardGameType[i] = buffer[chosed];
            //    buffer.RemoveAt(chosed);
            //}

            Main.PlaySound(Entrogic.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/CGChangeTurn"));
            TimerCountdown = 0;
            AnimationTimer = 0;
            TurnText       = Language.GetTextValue("Mods.Entrogic.Common.PlayerTurn");
        }
示例#3
0
        public override void Update(GameTime gameTime, Player attackPlayer, NPC attackNPC)
        {
            Velocity *= 1.1f;
            for (int i = 0; i < 2; i++)
            {
                ArcaneMissleParticle particle = new ArcaneMissleParticle()
                {
                    Position        = CardGameUI.ToUIPos(Position),
                    Velocity        = Vector2.Zero,
                    UIPosition      = UIPosition,
                    IsPanelParticle = true
                };
                particle.Setup(Size, 1f, attackPlayer);
                attackPlayer.GetModPlayer <EntrogicPlayer>()._particles.Add(particle);
            }

            if (Vector2.Distance(CardGameUI.ToUIPos(Position), TargetPosition) < 36f)
            {
                IsRemoved = true;
                CardFightableNPC fightNPC = (CardFightableNPC)attackNPC.modNPC;
                fightNPC.CardGameHealth -= 120 / 6; // 总伤害120,,因为一射6个
            }

            base.Update(gameTime, attackPlayer, attackNPC);
        }
示例#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;
            NPC npc = Main.npc[clientModPlayer.CardGameNPCIndex];
            CardFightableNPC fightNPC = (CardFightableNPC)npc.modNPC;

            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.SafeEnd();
                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) / 14f, 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.SafeEnd();
                Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix);
            }
        }
示例#5
0
        public override void ClickEvent()
        {
            if (Main.dedServ || StartAnimation)
            {
                return;
            }
            Player         clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);

            if (clientModPlayer.CardGameNPCIndex == -1)
            {
                return;
            }
            NPC npc = Main.npc[clientModPlayer.CardGameNPCIndex];
            CardFightableNPC fightNPC = (CardFightableNPC)npc.modNPC;

            if (!PlayerTurn || clientModPlayer.CardGameLeftCard <= 0)
            {
                return;
            }
            clientModPlayer.CardGameLeftCard--;
            //Clicked = true;
            StartAnimation = true;
            AnimationTimer = 0;
        }
示例#6
0
        public override void Update(GameTime gameTime, Player attackPlayer, NPC attackNPC)
        {
            for (int i = 0; i < 3; i++)
            {
                FireParticle particle = new FireParticle()
                {
                    Position        = CardGameUI.ToUIPos(Position) + new Vector2(0f, -10f),
                    Velocity        = Vector2.Zero,
                    UIPosition      = UIPosition,
                    Alpha           = 100,
                    IsPanelParticle = true
                };
                particle.Setup(Size, 1f, attackPlayer);
                particle.Velocity *= 0.85f;
                attackPlayer.GetModPlayer <EntrogicPlayer>()._particles.Add(particle);
            }
            Velocity.Y -= 0.1f;

            if (Vector2.Distance(CardGameUI.ToUIPos(Position + Size / 2f), TargetPosition + new Vector2(0, 12f)) < 10f)
            {
                IsRemoved = true;
                CardFightableNPC fightNPC = (CardFightableNPC)attackNPC.modNPC;
                fightNPC.CardGameHealth -= 46;
            }

            base.Update(gameTime, attackPlayer, attackNPC);
        }
示例#7
0
        public override void Update(GameTime gameTime, Player attackPlayer, NPC attackNPC)
        {
            //if (LifeSpan > 4.96 && LifeSpan <= 5.1f)
            //    Velocity += -ModHelper.GetFromToVector(CardGameUI.ToUIPos(Center), TargetPosition) * 0.4f;
            //else if (LifeSpan <= 5.1f)
            Velocity += ModHelper.GetFromToVector(CardGameUI.ToUIPos(Center), TargetPosition) * 0.9f;
            _rotation = MathHelper.ToRadians(45f) + ModHelper.GetFromToRadians(CardGameUI.ToUIPos(Center), TargetPosition);

            if (Vector2.Distance(CardGameUI.ToUIPos(Center), TargetPosition) < 20f)
            {
                IsRemoved = true;
                CardFightableNPC fightNPC = (CardFightableNPC)attackNPC.modNPC;
                fightNPC.CardGameHealth -= 120 / 5; // 总伤害120,,因为一射5个
            }
            base.Update(gameTime, attackPlayer, attackNPC);
        }
示例#8
0
        public void Update()
        {
            if (Main.dedServ)
            {
                return;
            }
            Player         clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);

            if (clientModPlayer.CardGameNPCIndex == -1)
            {
                return;
            }
            NPC npc = Main.npc[clientModPlayer.CardGameNPCIndex];
            CardFightableNPC fightNPC = (CardFightableNPC)npc.modNPC;

            if (StartAnimation)
            {
                Vector2 TargetPosition = new Vector2(274f, 252f);
                AnimationTimer++;
                if (AnimationTimer <= 15f)
                {
                    AnimationPosition = (TargetPosition - uiPosition) / 15f * AnimationTimer + uiPosition;
                }
                else if (AnimationTimer >= 25f)
                {
                    // 出击
                    if (inventoryItem.modItem is ModCard)
                    {
                        ModCard card         = (ModCard)inventoryItem.modItem;
                        Vector2 drawPosition = new Vector2(274f, 314f) + new Vector2(17f, 28f); // 元件在UI中的位置
                        drawPosition = CardGameUI.ToPlaygroundPos(drawPosition);
                        card.CardGameAttack(clientPlayer, npc, drawPosition, new Vector2(292f, 64f), PanelPos);

                        clientModPlayer.CardGameType[Index] = 0;
                    }
                    StartAnimation = false;
                }
            }
        }
示例#9
0
        public override void Update(GameTime gameTime, Player attackPlayer, NPC attackNPC)
        {
            InvisibleSpan -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (InvisibleSpan > 0f)
            {
                return;
            }
            for (int extraUpdates = 0; extraUpdates < 2; extraUpdates++)
            {
                for (int i = 0; i < 2; i++)
                {
                    ArcaneMissleParticle particle = new ArcaneMissleParticle()
                    {
                        Position        = CardGameUI.ToUIPos(Position),
                        Velocity        = Vector2.Zero,
                        UIPosition      = UIPosition,
                        IsPanelParticle = true
                    };
                    particle.Setup(Size, 2f, attackPlayer);
                    attackPlayer.GetModPlayer <EntrogicPlayer>()._particles.Add(particle);
                }
                // 计算朝向目标的向量
                Vector2 targetVec = TargetPosition - CardGameUI.ToUIPos(Position + Size / 2f);
                targetVec.Normalize();
                // 目标向量是朝向目标的大小为15的向量
                targetVec *= 8f;
                // 朝向npc的单位向量*15 + 一些(?)偏移量
                Velocity = (Velocity * 8f + targetVec) / 9f;

                if (Vector2.Distance(CardGameUI.ToUIPos(Position), TargetPosition) < 10f)
                {
                    IsRemoved = true;
                    CardFightableNPC fightNPC = (CardFightableNPC)attackNPC.modNPC;
                    fightNPC.CardGameHealth -= 46;
                }

                base.Update(gameTime, attackPlayer, attackNPC);
            }
        }
示例#10
0
        private void QuitGame()
        {
            if (Main.dedServ)
            {
                return;
            }
            Player         clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);

            if (clientModPlayer.CardGameNPCIndex == -1)
            {
                goto IL_BackToDefault;
            }
            NPC npc = Main.npc[clientModPlayer.CardGameNPCIndex];

            if (npc.type != NPCID.None && npc.modNPC is CardFightableNPC) // 表示此ModNPC属于CardFightableNPC
            {
                CardFightableNPC fightNPC = (CardFightableNPC)npc.modNPC;

                fightNPC.CardGaming = false;
            }
IL_BackToDefault:
            // 一切都要回到初始状态
            clientModPlayer.CardGaming         = false;
            clientModPlayer.CardGameActive     = false;
            clientModPlayer.CardGameNPCIndex   = -1;
            clientModPlayer.CardGamePlayerTurn = true;
            Array.Clear(clientModPlayer.CardGameType, 0, clientModPlayer.CardGameType.Length);
            AnimationTimer     = 0;
            TimerCountdown     = 60;
            TurnTextColor      = Color.White;
            TurnText           = " ";
            Deathing           = 0;
            DeathTimer         = 0;
            IsUseBiggerTexture = false;
        }
示例#11
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);
        }
示例#12
0
        public override void Update(GameTime gameTime)
        {
            if (Main.dedServ)
            {
                return;
            }
            Player         clientPlayer    = Main.LocalPlayer;
            EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer);

            for (int i = 0; i < HandCardSlots.Count; i++)
            {
                Item slotitem = new Item();
                slotitem.SetDefaults(clientModPlayer.CardGameType[i]);
                HandCardSlots[i].inventoryItem = slotitem;
                HandCardSlots[i].Update();
            }
            NPCCardSlot.Update();

            bool pause = (!Main.hasFocus || Main.gamePaused) && Main.netMode == NetmodeID.SinglePlayer;

            if (pause)
            {
                return;
            }
            if (clientModPlayer.CardGameNPCIndex == -1)
            {
                return;
            }
            //clientModPlayer._bullets = new List<CardFightBullet>() // 意思意思
            //{
            //    new MushroomBullet()
            //    {
            //        Position = new Vector2(100f, 100f)
            //    }
            //};
            NPC npc = Main.npc[clientModPlayer.CardGameNPCIndex];

            if (npc.type != NPCID.None && npc.modNPC is CardFightableNPC) // 表示此ModNPC属于CardFightableNPC
            {
                CardFightableNPC fightNPC = (CardFightableNPC)npc.modNPC;
                fightNPC.PanelPosition = PanelPos;
                if (clientModPlayer.CardGaming != fightNPC.CardGaming)
                {
                    QuitGame();                                                    // 必须要同为一个状态的
                }
                if (fightNPC.CardGaming && clientModPlayer.CardGaming)
                {
                    if (!clientPlayer.active || clientPlayer.dead || !npc.active)
                    {
                        QuitGame();
                        return;
                    }
                    clientPlayer.stoned            = true;
                    clientPlayer.noKnockback       = true;
                    npc.dontTakeDamageFromHostiles = true;
                    npc.dontTakeDamage             = true;
                    #region NPC Stand
                    if (npc.ai[0] != 0f)
                    {
                        npc.netUpdate = true;
                    }
                    npc.ai[0]      = 0f;
                    npc.ai[1]      = 300f;
                    npc.localAI[3] = 100f;
                    if (Main.LocalPlayer.Center.X < npc.Center.X)
                    {
                        npc.direction = -1;
                    }
                    else
                    {
                        npc.direction = 1;
                    }
                    npc.spriteDirection = npc.direction;
                    #endregion
                    clientModPlayer.CardGameNPCHealth    = fightNPC.CardGameHealth;
                    clientModPlayer.CardGameNPCMaxHealth = fightNPC.CardGameHealthMax;
                    if (Deathing != 0)
                    {
                        return;
                    }
                    if (clientModPlayer.CardGamePlayerTurn) // 玩家局
                    {
                        foreach (HandCardSlot slot in HandCardSlots)
                        {
                            slot.PlayerTurn = true;
                        }
                        if (PlayerTurnOver) // 转NPC局
                        {
                            IsUseBiggerTexture = false;
                            clientModPlayer.CardGamePlayerTurn = false;
                            fightNPC.PreStartRound(false);
                            Main.PlaySound(Entrogic.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/CGChangeTurn"));

                            TimerCountdown = 0;
                            AnimationTimer = 0;
                            TurnText       = Language.GetTextValue("Mods.Entrogic.Common.NPCTurn");

                            CardGamePlayer player = new CardGamePlayer()
                            {
                                Center     = PlaygroundSize / 2f,
                                UIPosition = PanelPos
                            };
                            clientModPlayer._bullets.Add(player);
                            for (int i = 0; i < HandCardSlots.Count; i++)
                            {
                                clientModPlayer.CardGameType[i] = ItemID.None;
                            }
                            NPCCardSlot.ActiveAnimation();
                        }
                    }
                    if (!clientModPlayer.CardGamePlayerTurn) // NPC局
                    {
                        foreach (HandCardSlot slot in HandCardSlots)
                        {
                            slot.PlayerTurn = false;
                            slot.Clicked    = false;
                        }
                        fightNPC.GameAI();
                        fightNPC.RoundDuration -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                        if (fightNPC.RoundDuration <= 0) // 转玩家局
                        {
                            PlayerTurnOver = false;
                            clientModPlayer.CardGamePlayerTurn = true;
                            fightNPC.PreStartRound(true);
                            IsUseBiggerTexture = true;
                            Main.PlaySound(Entrogic.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/CGChangeTurn"));
                            for (int i = 0; i < clientModPlayer._bullets.Count; i++)
                            {
                                if (clientModPlayer._bullets[i].IsFriendly == false)
                                {
                                    clientModPlayer._bullets[i].Kill(clientPlayer);
                                    clientModPlayer._bullets.RemoveAt(i);
                                    i--;
                                }
                            }

                            clientModPlayer.CardGameLeftCard = 1; // 设置出牌机会
                            //List<int> buffer = new List<int>();
                            //foreach (int card in clientModPlayer.CardType)
                            //    buffer.Add(card);
                            //for (int i = 0; i < clientModPlayer.CardGameType.Length; i++)
                            //{
                            //    int chosed = Main.rand.Next(0, buffer.Count);
                            //    clientModPlayer.CardGameType[i] = buffer[chosed];
                            //    buffer.RemoveAt(chosed);
                            //}

                            TimerCountdown = 0;
                            AnimationTimer = 0;
                            TurnText       = Language.GetTextValue("Mods.Entrogic.Common.PlayerTurn");
                        }
                    }
                    foreach (var bullet in clientModPlayer._bullets.ToArray())
                    {
                        bullet.Update(gameTime, clientPlayer, npc);
                    }
                    for (int i = 0; i < clientModPlayer._bullets.Count; i++)
                    {
                        if (clientModPlayer._bullets[i].IsRemoved)
                        {
                            clientModPlayer._bullets[i].Kill(clientPlayer);
                            clientModPlayer._bullets.RemoveAt(i);
                            i--;
                        }
                    }
                    foreach (var particle in clientModPlayer._particles.ToArray())
                    {
                        particle.Update(gameTime);
                    }
                    for (int i = 0; i < clientModPlayer._particles.Count; i++)
                    {
                        if (clientModPlayer._particles[i].IsRemoved)
                        {
                            clientModPlayer._particles.RemoveAt(i);
                            i--;
                        }
                    }
                    clientModPlayer.CardGamePlayerHealth   = Math.Min(clientModPlayer.CardGamePlayerHealth, clientModPlayer.CardGamePlayerMaxHealth);
                    clientModPlayer.CardGameHealthAlpha    = Math.Min(clientModPlayer.CardGameHealthAlpha + 0.02f, 1f);
                    clientModPlayer.CardGameNPCHealthAlpha = Math.Min(clientModPlayer.CardGameNPCHealthAlpha + 0.02f, 1f);
                    if (clientModPlayer.CardGamePlayerLastHealth != clientModPlayer.CardGamePlayerHealth)
                    {
                        clientModPlayer.CardGameHealthAlpha = -2; // 这样就不用再搞Delay变量了
                        DelayHealthPercentPlayer            = 0f;
                        LastRecordHealthPlayer = clientModPlayer.CardGamePlayerLastHealth;
                    }
                    if (clientModPlayer.CardGameNPCLastHealth != clientModPlayer.CardGameNPCHealth)
                    {
                        clientModPlayer.CardGameNPCHealthAlpha = -2; // 这样就不用再搞Delay变量了
                        DelayHealthPercentNPC = 0f;
                        LastRecordHealthNPC   = clientModPlayer.CardGameNPCLastHealth;
                    }
                    clientModPlayer.CardGamePlayerLastHealth = clientModPlayer.CardGamePlayerHealth;
                    clientModPlayer.CardGameNPCLastHealth    = clientModPlayer.CardGameNPCHealth;
                    // NPC没血,NPC输玩家赢
                    if (clientModPlayer.CardGameNPCHealth <= 0)
                    {
                        fightNPC.CardGameLost();
                        PlayerWin();
                        clientModPlayer._bullets.Clear();
                        Deathing = 2; // NPC死

                        TimerCountdown = 0;
                        AnimationTimer = 0;
                        TurnTextColor  = new Color(228, 196, 74);
                        TurnText       = Language.GetTextValue("Mods.Entrogic.Common.YouWin");
                    }
                    // 玩家没血,NPC赢玩家输
                    if (clientModPlayer.CardGamePlayerHealth <= 0)
                    {
                        fightNPC.CardGameWin();
                        PlayerLost();
                        clientModPlayer._bullets.Clear();
                        Deathing = 1; // 玩家死

                        TimerCountdown = 0;
                        AnimationTimer = 0;
                        TurnTextColor  = new Color(242, 12, 12);
                        TurnText       = Language.GetTextValue("Mods.Entrogic.Common.YouLost");
                    }
                }
            }
            else
            {
                clientModPlayer.CardGameNPCIndex = -1;
            }

            base.Update(gameTime);
        }
示例#13
0
        public override void Update(GameTime gameTime, Player attackPlayer, NPC attackNPC)
        {
            for (int extraUpdates = 0; extraUpdates < 2; extraUpdates++)
            {
                if (!State2)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        FireParticle particle = new FireParticle()
                        {
                            Position        = CardGameUI.ToUIPos(Position) + new Vector2(0f, -10f),
                            Velocity        = Vector2.Zero,
                            UIPosition      = UIPosition,
                            Alpha           = 100,
                            IsPanelParticle = true
                        };
                        particle.Setup(Size, 1.2f, attackPlayer);
                        particle.Velocity *= 0.5f * 1.1f;
                        attackPlayer.GetModPlayer <EntrogicPlayer>()._particles.Add(particle);
                    }
                    Velocity += new Vector2(0f, -0.8f);
                }
                else
                {
                    if (localAI == 0f)
                    {
                        Vector2 screenCenter = new Vector2(Main.screenWidth, Main.screenHeight) / 2f + Main.screenPosition;
                        Main.PlaySound(SoundID.Item74, (int)screenCenter.X, (int)screenCenter.Y + -30);
                        localAI += 1f;
                    }
                    ai += 1f;
                    ai += 3f;
                    float num466 = 25f;
                    if (ai > 180f)
                    {
                        num466 -= (ai - 180f) / 2f;
                    }
                    num466 *= 0.7f;
                    int num467 = 0;
                    while ((float)num467 < num466)
                    {
                        float num468 = (float)Main.rand.Next(-10, 11);
                        float num469 = (float)Main.rand.Next(-10, 11);
                        float num470 = (float)Main.rand.Next(3, 9);
                        float num471 = (float)Math.Sqrt((double)(num468 * num468 + num469 * num469));
                        num471  = num470 / num471;
                        num468 *= num471;
                        num469 *= num471;

                        FireParticle particle = new FireParticle()
                        {
                            Position        = CardGameUI.ToUIPos(Position) + new Vector2(0f, -10f),
                            Velocity        = Vector2.Zero,
                            UIPosition      = UIPosition,
                            Alpha           = 100,
                            IsPanelParticle = true
                        };
                        particle.Setup(Size, 1.5f, attackPlayer);
                        particle.Position  = CardGameUI.ToUIPos(Position) + Size / 2f;
                        particle.Position += new Vector2(Main.rand.Next(-10, 11), Main.rand.Next(-10, 11));
                        particle.Velocity  = new Vector2(num468, num469) * 0.75f;
                        attackPlayer.GetModPlayer <EntrogicPlayer>()._particles.Add(particle);

                        int num3 = num467;
                        num467 = num3 + 1;
                    }
                    Velocity = Vector2.Zero;
                }

                base.Update(gameTime, attackPlayer, attackNPC);

                if (!State2 && Vector2.Distance(CardGameUI.ToUIPos(Position + Size / 2f), TargetPosition + new Vector2(0, 12f)) < 10f)
                {
                    State2 = true;
                    CardFightableNPC fightNPC = (CardFightableNPC)attackNPC.modNPC;
                    fightNPC.CardGameHealth -= GetDamage(Damage);
                }
            }
        }