コード例 #1
0
 private void OnHit(Player player, bool crit)
 {
     if (Equipped(player) && crit)
     {
         if (Main.rand.NextFloat() < 0.1f)
         {
             DisinfectantWipes.ReduceDebuffDurations(player);
         }
         if (Main.rand.NextFloat() < 0.25f)
         {
             SanitizerSpray.TransferRandomDebuffToNearbyEnemies(player);
         }
     }
 }
コード例 #2
0
        public static void CleanDebuff(Player player, int type)
        {
            StarlightPlayer slp = player.GetModPlayer <StarlightPlayer>();
            //short cooldown = slp.DisinfectCooldown;//unused
            bool       clean = false;
            List <int> buffs = new List <int>();

            for (int i = 0; i < Player.MaxBuffs; i += 1)
            {
                if (Helper.IsValidDebuff(player, i))
                {
                    if (type == 1)
                    {
                        buffs.Add(i);
                        clean = true;
                    }

                    if (type == 0 && slp.DisinfectCooldown < 1)
                    {
                        player.buffTime[i] = (int)MathHelper.Max(player.buffTime[i] - 60 * 3, 5);
                        clean = true;
                    }
                }
            }

            if (clean)
            {
                if (type == 1)
                {
                    if (buffs.Count > 0)
                    {
                        int buffid = Main.rand.Next(0, buffs.Count);
                        if (SanitizerSpray.SanitizeEnemies(player, player.buffType[buffid], 60 * 5, 300))
                        {
                            player.buffTime[buffid] = (int)MathHelper.Max(player.buffTime[buffid] - 60 * 5, 5);
                            MakeDusts(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), 2, Color.Blue, ModContent.DustType <Content.Dusts.Air>());
                        }
                    }
                    else
                    {
                        slp.DisinfectCooldown = 20;
                        MakeDusts(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), 5, Color.White, ModContent.DustType <Content.Dusts.Air>());
                    }
                }
                Main.PlaySound(SoundID.Item, (int)player.Center.X, (int)player.Center.Y, 100, 0.65f, -Main.rand.NextFloat(0.35f, 0.75f));
            }
        }