當前位置: 首頁>>代碼示例>>C#>>正文


C# Terraria.NPC類代碼示例

本文整理匯總了C#中Terraria.NPC的典型用法代碼示例。如果您正苦於以下問題:C# NPC類的具體用法?C# NPC怎麽用?C# NPC使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NPC類屬於Terraria命名空間,在下文中一共展示了NPC類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnHitNPC

 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (Main.rand.Next(8) == 0)
     {
         target.AddBuff(BuffID.Confused, 240, true);
     }
 }
開發者ID:ColinAV516,項目名稱:Spirit-Mod,代碼行數:7,代碼來源:TaoP.cs

示例2: OnHitByNPC

 public virtual void OnHitByNPC(NPC npc, int damage, bool crit)
 {
     if (Main.rand.Next(4) == 0)
     {
         npc.AddBuff(BuffID.ShadowFlame, 200, true);
     }
 }
開發者ID:ColinAV516,項目名稱:Spirit-Mod,代碼行數:7,代碼來源:DuskHood.cs

示例3: OnHitNPC

		public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
		{
			if (Main.rand.Next(2) == 0)
			{
				target.AddBuff(mod.BuffType("EtherealFlames"), 300);
			}
		}
開發者ID:DrakoGlyph,項目名稱:tModLoader,代碼行數:7,代碼來源:Wisp.cs

示例4: OnHitNPC

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            if (Main.rand.Next(10) == 0) // 10% chance to inflict slow on an enemy.
                target.AddBuff(BuffID.Slow, 5);

            base.OnHitNPC(target, damage, knockback, crit);
        }
開發者ID:Eldrazi,項目名稱:Gyrolite,代碼行數:7,代碼來源:Streambolt.cs

示例5: NPCLoot

 public override void NPCLoot(NPC npc)
 {
     if (npc.type == NPCID.Plantera)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ThornbloomKnife"), Main.rand.Next(40, 60));
     }
 }
開發者ID:ColinAV516,項目名稱:Spirit-Mod,代碼行數:7,代碼來源:NPCHook.cs

示例6: ModifyHitNPC

        public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
        {
            Vector2 loc = player.itemLocation;
            loc.Y -= 20;

            Random rand = new Random();
            int r = rand.Next(0, 6);

            if (r == 0)
            {
                for (int i = 0; i < 9; i++)
                {
                    Dust.NewDust(loc, 50, 30, mod.DustType("Garnsworddust"), 0.0F, 0.0F, 0, default(Color), 4.5F);
                }

                damage += (int) (damage * 0.4);

                int healamount = (int)(damage * 0.33);
                player.HealEffect(healamount, true);

                if (player.statLife + healamount <= (player.statLifeMax + player.statLifeMax2))
                {
                    player.statLife += healamount;
                }
                else
                {
                    player.statLife = (player.statLifeMax + player.statLifeMax2);
                }
            }
        }
開發者ID:Garnetty97,項目名稱:Garnmod,代碼行數:30,代碼來源:Garnsword.cs

示例7: OnHitNPC

 public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
 {
     if(Main.rand.Next(2) == 0)
     {
         target.AddBuff(BuffID.OnFire, 500);
     }
 }
開發者ID:rpetit3-fun,項目名稱:terraria-plus-one,代碼行數:7,代碼來源:FieryGreatswordPlusOne.cs

示例8: DamageNPC

        /// <summary>
        /// When an <see cref="NPC" /> is damaged by the <see cref="Projectile" />.
        /// </summary>
        /// <param name="n">The <see cref="NPC" /> that got damaged.</param>
        /// <param name="dir">In which direction the <see cref="NPC"/> got hit.</param>
        /// <param name="dmg">The damage dealt to the <see cref="NPC" />.</param>
        /// <param name="kb">The knockback the <see cref="NPC" /> wil receive.</param>
        /// <param name="crit">Wether it was a critical hit or not.</param>
        /// <param name="cMult">The damage multiplier of a critical hit.</param>
        public override void DamageNPC(NPC n, int dir, ref int dmg, ref float kb, ref bool crit, ref float cMult)
        {
            base.DamageNPC(n, dir, ref dmg, ref kb, ref crit, ref cMult);

            if (Main.rand.Next(3) == 0)
                n.AddBuff(20, 300);
        }
開發者ID:RainbowDashGaming,項目名稱:Terraria-Avalon-MODIFIED,代碼行數:16,代碼來源:Sporalash+Ball.cs

示例9: OnHitNPC

 public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
 {
     if(!target.boss)
     {
     target.velocity.Y -= 5;
     }
 }
開發者ID:ColinAV516,項目名稱:EnergyMod,代碼行數:7,代碼來源:SoaringBat.cs

示例10: OnHitNPC

 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (Main.rand.Next(0) == 0)
     {
         target.AddBuff(mod.BuffType("ElectrifiedV2"), 540, true);
     }
 }
開發者ID:ColinAV516,項目名稱:Spirit-Mod,代碼行數:7,代碼來源:TeslaSpikeProjectile.cs

示例11: OnHitNPC

 public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
 {
     target.AddBuff(BuffID.OnFire, 10);
     target.AddBuff(BuffID.Electrified, 3);
     target.AddBuff(BuffID.Venom, 5);
     target.AddBuff(BuffID.CursedInferno, 4);
 }
開發者ID:MountainDrew8,項目名稱:CalamityMod,代碼行數:7,代碼來源:CataclysmicTerrorBlade.cs

示例12: CanHitNPC

 //in Terraria.Projectile.Damage for damaging NPCs before flag2 is checked... just check the patch files
 internal static bool? CanHitNPC(Projectile projectile, NPC target)
 {
     bool? flag = null;
     foreach (GlobalProjectile globalProjectile in globalProjectiles)
     {
         bool? canHit = globalProjectile.CanHitNPC(projectile, target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     if (IsModProjectile(projectile))
     {
         bool? canHit = projectile.modProjectile.CanHitNPC(target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     return flag;
 }
開發者ID:Phantom139,項目名稱:tModLoader,代碼行數:30,代碼來源:ProjectileLoader.cs

示例13: CanHitNPC

 //in Terraria.Player.ItemCheck before checking whether npc type can be hit add
 //  bool? modCanHit = ItemLoader.CanHitNPC(item, this, Main.npc[num292]);
 //  if(modCanHit.HasValue && !modCanHit.Value) { continue; }
 //in if statement afterwards add || (modCanHit.HasValue && modCanHit.Value)
 internal static bool? CanHitNPC(Item item, Player player, NPC target)
 {
     bool? flag = null;
     foreach (GlobalItem globalItem in globalItems)
     {
         bool? canHit = globalItem.CanHitNPC(item, player, target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     if (IsModItem(item))
     {
         bool? canHit = item.modItem.CanHitNPC(player, target);
         if (canHit.HasValue && !canHit.Value)
         {
             return false;
         }
         if (canHit.HasValue)
         {
             flag = canHit.Value;
         }
     }
     return flag;
 }
開發者ID:guyde2011,項目名稱:tModLoader,代碼行數:33,代碼來源:ItemLoader.cs

示例14: NPCLoot

 public override void NPCLoot(NPC npc)
 {
     if (Main.player[Main.myPlayer].ZoneSnow && Main.rand.Next(5) == 3)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceEssense"), 1);
     }
 }
開發者ID:ColinAV516,項目名稱:Spirit-Mod,代碼行數:7,代碼來源:IceEssense.cs

示例15: OnHitNPC

		public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
		{
			if (Main.rand.Next(10) == 0)
			{
				target.AddBuff(BuffID.OnFire, 180, false);
			}
		}
開發者ID:DrakoGlyph,項目名稱:tModLoader,代碼行數:7,代碼來源:MoltenDrill.cs


注:本文中的Terraria.NPC類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。