当前位置: 首页>>代码示例>>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;未经允许,请勿转载。