Ejemplo n.º 1
0
 public override bool CanUseItem(Player player)
 {
     if (player == Main.player[Main.myPlayer])
     {
         OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();
         Item[]          cards     = modPlayer.gamblerCardsItem;
         int             count     = OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer);
         if (OrchidModGamblerHelper.containsGamblerCard(item, player, modPlayer) || player.altFunctionUse == 2 || count < this.cardRequirement || count >= 20)
         {
             return(false);
         }
         else
         {
             if (OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) <= 0)
             {
                 bool found = false;
                 for (int i = 0; i < Main.maxInventory; i++)
                 {
                     Item item = Main.LocalPlayer.inventory[i];
                     if (item.type != 0)
                     {
                         OrchidModGlobalItem orchidItem = item.GetGlobalItem <OrchidModGlobalItem>();
                         if (orchidItem.gamblerDeck)
                         {
                             found = true;
                             break;
                         }
                     }
                 }
                 if (!found)
                 {
                     int gamblerDeck = ItemType <Gambler.Decks.GamblerAttack>();
                     player.QuickSpawnItem(gamblerDeck, 1);
                 }
             }
             item.useAnimation = 20;
             item.useTime      = 20;
             for (int i = 0; i < 20; i++)
             {
                 if (cards[i].type == 0)
                 {
                     cards[i] = new Item();
                     cards[i].SetDefaults(item.type, true);
                     OrchidModGamblerHelper.clearGamblerCardCurrent(player, modPlayer);
                     OrchidModGamblerHelper.clearGamblerCardsNext(player, modPlayer);
                     modPlayer.gamblerShuffleCooldown = 0;
                     modPlayer.gamblerRedraws         = 0;
                     OrchidModGamblerHelper.drawGamblerCard(player, modPlayer);
                     return(true);
                 }
             }
             //item.TurnToAir();
         }
     }
     return(base.CanUseItem(player));
 }
Ejemplo n.º 2
0
 public override bool CanUseItem(Player player)
 {
     if (player == Main.LocalPlayer)
     {
         OrchidModPlayer modPlayer   = player.GetModPlayer <OrchidModPlayer>();
         Item            currentCard = modPlayer.gamblerCardCurrent;
         if (OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) > 0)
         {
             if (player.altFunctionUse == 2)
             {
                 if (modPlayer.gamblerRedraws > 0 && modPlayer.gamblerRedrawCooldownUse <= 0)
                 {
                     modPlayer.gamblerRedraws--;
                     modPlayer.gamblerRedrawCooldownUse = 30;
                     Main.PlaySound(SoundID.Item64, player.position);
                     OrchidModGamblerHelper.drawGamblerCard(player, modPlayer);
                     currentCard = modPlayer.gamblerCardCurrent;
                     this.checkStats(currentCard, player, modPlayer);
                 }
                 return(false);
             }
             else
             {
                 if (modPlayer.gamblerShuffleCooldown <= 0)
                 {
                     OrchidModGamblerHelper.drawGamblerCard(player, modPlayer);
                     Main.PlaySound(SoundID.Item64, player.position);
                     currentCard = modPlayer.gamblerCardCurrent;
                     this.checkStats(currentCard, player, modPlayer);
                 }
             }
         }
         else
         {
             return(false);
         }
     }
     return(base.CanUseItem(player));
 }