public override bool HaveDrawCard(Player player, int number, int a, ref int type, ref int cost)
        {
            NPC   target      = null;
            float distanceMax = 128000f;

            foreach (NPC npc in Main.npc)
            {
                if (npc.active && !npc.friendly)
                {
                    // 计算与玩家的距离
                    float currentDistance = Vector2.Distance(npc.Center, Main.MouseWorld);
                    if (currentDistance < distanceMax)
                    {
                        distanceMax = currentDistance;
                        target      = npc;
                    }
                }
            }
            Item i = new Item();

            i.SetDefaults(type);
            ModCard        card    = (ModCard)i.modItem;
            EntrogicPlayer ePlayer = EntrogicPlayer.ModPlayer(player);
            float          power   = 1f;

            if (ePlayer.GetHoldItem() != null)
            {
                power = ePlayer.GetHoldItem().shootSpeed * 0.8f;
            }
            if (target != null)
            {
                Vector2 vec = (target.Center - player.Center).ToRotation().ToRotationVector2() * i.shootSpeed;
                card.AttackEffects(player, i.shoot, player.Center, target.Center, vec.X, vec.Y, player.GetWeaponDamage(i), player.GetWeaponKnockback(i, 0.5f), i.shootSpeed + power);
            }
            else
            {
                card.AttackEffects(player, i.shoot, player.Center, player.Center, Main.rand.NextFloat(-10f, 10f), Main.rand.NextFloat(-10f, 10f), player.GetWeaponDamage(i), player.GetWeaponKnockback(i, 0.5f), i.shootSpeed + power);
            }
            return(true);
        }
Beispiel #2
0
        public override bool Shoot(Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            EntrogicItem   eItem   = item.GetGlobalItem <EntrogicItem>();
            EntrogicPlayer ePlayer = EntrogicPlayer.ModPlayer(player);

            if (eItem.glove && attackCardRemainingTimes > 0 && mCard != null && card != null)
            {
                Vector2 vec        = (Main.MouseWorld - player.Center).ToRotation().ToRotationVector2() * (card.shootSpeed + item.shootSpeed);
                int     Tdamage    = player.GetWeaponDamage(card) + damage;
                float   TknockBack = player.GetWeaponKnockback(card, card.knockBack) + knockBack;
                int     Tshoot     = card.shoot;
                if (((ModCard)item.modItem).ModifyGloveShootCard(player, ref position, ref vec.X, ref vec.Y, ref Tshoot, ref Tdamage, ref TknockBack))
                {
                    for (int i = 0; i < ((ModCard)item.modItem).ShootCardTimes(player); i++)
                    {
                        mCard.AttackEffects(player, Tshoot, position, Main.MouseWorld, vec.X, vec.Y, Tdamage, TknockBack, card.shootSpeed + item.shootSpeed);
                        attackCardRemainingTimes -= ((ModCard)item.modItem).AttackCardRemainingTimesReduce(player);
                        if (attackCardRemainingTimes <= 0 && CEntrogicCardConfig.Instance.AutoUseCard)
                        {
                            for (int index = 0; index < ePlayer.CardHandType.Length; index++)
                            {
                                int handCard = ePlayer.CardHandType[index];
                                if (handCard == card.type)
                                {
                                    Entrogic.Instance.CardUI.Grid[index].UseThisCard();
                                    return(false);
                                }
                            }
                        }
                        if (itemSound != null)
                        {
                            Main.PlaySound(itemSound, position);
                        }
                    }
                }
                return(false);
            }
            return(true);
        }