当前位置: 首页>>代码示例>>C#>>正文


C# Terraria.Projectile类代码示例

本文整理汇总了C#中Terraria.Projectile的典型用法代码示例。如果您正苦于以下问题:C# Projectile类的具体用法?C# Projectile怎么用?C# Projectile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Projectile类属于Terraria命名空间,在下文中一共展示了Projectile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PreAI

		public override bool PreAI(Projectile projectile)
		{
			if (projectile.aiStyle == 52)
			{
				Player player = Main.player[(int)projectile.ai[0]];
				Vector2 center = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f);
				float offsetX = player.Center.X - center.X;
				float offsetY = player.Center.Y - center.Y;
				float distance = (float)Math.Sqrt(offsetX * offsetX + offsetY * offsetY);
				if (distance < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y)
				{
					if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech)
					{
						int heal = (int)projectile.ai[1];
						int damage = player.statLifeMax2 - player.statLife;
						if (heal > damage)
						{
							heal = damage;
						}
						if (heal > 0)
						{
							player.AddBuff(mod.BuffType("Undead2"), 2 * heal, false);
						}
					}
				}
			}
			return base.PreAI(projectile);
		}
开发者ID:DrakoGlyph,项目名称:tModLoader,代码行数:28,代码来源:HealProj.cs

示例2: 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

示例3: SetupProjectile

		internal void SetupProjectile(Projectile projectile)
		{
			ModProjectile newProjectile = (ModProjectile)Activator.CreateInstance(GetType());
			newProjectile.projectile = projectile;
			projectile.modProjectile = newProjectile;
			newProjectile.mod = mod;
			newProjectile.SetDefaults();
		}
开发者ID:DrakoGlyph,项目名称:tModLoader,代码行数:8,代码来源:ModProjectile.cs

示例4: OnColliding

        internal static bool OnColliding(Projectile pr, Rectangle p, Rectangle t)
        {
            var bh = pr.P_BHandler as ProjBHandler;

            if (bh == null)
                return pr.RealColliding(p, t);

            return bh.IsColliding(p, t);
        }
开发者ID:TerrariaPrismTeam,项目名称:Prism,代码行数:9,代码来源:ProjHooks.cs

示例5: SetupProjectile

		internal void SetupProjectile(Projectile projectile)
		{
			ModProjectile newProjectile = (ModProjectile)(CloneNewInstances ? MemberwiseClone()
				: Activator.CreateInstance(GetType()));
			newProjectile.projectile = projectile;
			projectile.modProjectile = newProjectile;
			newProjectile.mod = mod;
			newProjectile.SetDefaults();
		}
开发者ID:JavidPack,项目名称:TerraCustom,代码行数:9,代码来源:ModProjectile.cs

示例6: AI

 internal static void AI(Projectile projectile)
 {
     if (IsModProjectile(projectile))
     {
         projectile.modProjectile.AI();
     }
     foreach (GlobalProjectile globalProjectile in globalProjectiles)
     {
         globalProjectile.AI(projectile);
     }
 }
开发者ID:Phantom139,项目名称:tModLoader,代码行数:11,代码来源:ProjectileLoader.cs

示例7: OnKill

        internal static void OnKill(Projectile pr)
        {
            var bh = pr.P_BHandler as ProjBHandler;

            if (bh == null || bh.PreDestroyed())
            {
                pr.RealKill();

                if (bh != null)
                    bh.OnDestroyed();
            }
        }
开发者ID:TerrariaPrismTeam,项目名称:Prism,代码行数:12,代码来源:ProjHooks.cs

示例8: OnAI

        internal static void OnAI(Projectile pr)
        {
            var bh = pr.P_BHandler as ProjBHandler;

            if (bh == null || bh.PreAI())
            {
                pr.RealAI();

                if (bh != null)
                    bh.OnAI();
            }
        }
开发者ID:TerrariaPrismTeam,项目名称:Prism,代码行数:12,代码来源:ProjHooks.cs

示例9: OnSetDefaults

 public static void OnSetDefaults(ref int type, Projectile proj)
 {
     if (SetDefaults == null)
     {
         return;
     }
     SetDefaultsEventArgs<Projectile, int> setDefaultsEventArgs = new SetDefaultsEventArgs<Projectile, int>
     {
         Object = proj,
         Info = type
     };
     SetDefaults(setDefaultsEventArgs);
     type = setDefaultsEventArgs.Info;
 }
开发者ID:Icehawk78,项目名称:TerrariaAPI-Server,代码行数:14,代码来源:ProjectileHooks.cs

示例10: CanHitPlayer

 //in Terraria.Projectile.Damage for damaging my player, add this before collision check
 internal static bool CanHitPlayer(Projectile projectile, Player target, ref int cooldownSlot)
 {
     foreach (GlobalProjectile globalProjectile in globalProjectiles)
     {
         if (!globalProjectile.CanHitPlayer(projectile, target, ref cooldownSlot))
         {
             return false;
         }
     }
     if (IsModProjectile(projectile))
     {
         return projectile.modProjectile.CanHitPlayer(target, ref cooldownSlot);
     }
     return true;
 }
开发者ID:Phantom139,项目名称:tModLoader,代码行数:16,代码来源:ProjectileLoader.cs

示例11: SetupProjectile

		//in Terraria.Projectile.SetDefaults get rid of bad type check
		//in Terraria.Projectile.SetDefaults before scaling size call ProjectileLoader.SetupProjectile(this);
		internal static void SetupProjectile(Projectile projectile)
		{
			projectile.projectileInfo.Clear();
			foreach (ProjectileInfo info in infoList)
			{
				projectile.projectileInfo.Add(info.Clone());
			}
			if (IsModProjectile(projectile))
			{
				GetProjectile(projectile.type).SetupProjectile(projectile);
			}
			foreach (GlobalProjectile globalProjectile in globalProjectiles)
			{
				globalProjectile.SetDefaults(projectile);
			}
		}
开发者ID:DrakoGlyph,项目名称:tModLoader,代码行数:18,代码来源:ProjectileLoader.cs

示例12: OnUpdate

        internal static void OnUpdate(Projectile pr, int id)
        {
            if (!pr.active)
                return;

            pr.whoAmI = id;
            pr.numUpdates = pr.extraUpdates;

            var bh = pr.P_BHandler as ProjBHandler;

            if (bh == null || bh.PreUpdate())
            {
                pr.RealUpdate(id);

                if (bh != null)
                    bh.OnUpdate();
            }
        }
开发者ID:TerrariaPrismTeam,项目名称:Prism,代码行数:18,代码来源:ProjHooks.cs

示例13: FillVanilla

        /// <summary>
        /// Adds all the original vanilla projectiles.
        /// </summary>
        internal static void FillVanilla()
        {
            for (int i = -65; i < ProjectileID.Count; i++)
            {
                if (i == 0)
                    continue;

                Projectile p = new Projectile();
                p.SetDefaults(i);

                ProjectileDef def = new ProjectileDef();

                def.InternalName = p.name;
                def.Type = p.type;

                CopyProjectileToDef(def, p);

                DefFromType.Add(i, def);
                VanillaDefFromName.Add(p.name, def);
            }
        }
开发者ID:chatrat12,项目名称:Prism,代码行数:24,代码来源:ProjectileDefHandler.cs

示例14: ExplosionEffect

 public static void ExplosionEffect(Projectile p)
 {
     Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 14);
     for (int num500 = 0; num500 < 10; num500++)
     {
         Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 31, 0f, 0f, 100, default(Color), 1.5f);
     }
     for (int num501 = 0; num501 < 5; num501++)
     {
         int num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 2.5f);
         Main.dust[num502].noGravity = true;
         Main.dust[num502].velocity *= 3f;
         num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 1.5f);
         Main.dust[num502].velocity *= 2f;
     }
     int num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
     Main.gore[num503].velocity *= 0.4f;
     Gore expr_105D2_cp_0 = Main.gore[num503];
     expr_105D2_cp_0.velocity.X = expr_105D2_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
     Gore expr_10602_cp_0 = Main.gore[num503];
     expr_10602_cp_0.velocity.Y = expr_10602_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
     num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
     Main.gore[num503].velocity *= 0.4f;
     Gore expr_10696_cp_0 = Main.gore[num503];
     expr_10696_cp_0.velocity.X = expr_10696_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
     Gore expr_106C6_cp_0 = Main.gore[num503];
     expr_106C6_cp_0.velocity.Y = expr_106C6_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
     if (p.owner == Main.myPlayer)
     {
         p.penetrate = -1;
         p.position.X = p.position.X + (float)(p.width / 2);
         p.position.Y = p.position.Y + (float)(p.height / 2);
         p.width = 48;
         p.height = 48;
         p.position.X = p.position.X - (float)(p.width / 2);
         p.position.Y = p.position.Y - (float)(p.height / 2);
         p.Damage();
     }
 }
开发者ID:thegamingboffin,项目名称:Ulterraria_Reborn_GitHub,代码行数:39,代码来源:UlterrariaProjectiles.cs

示例15: ModifyHitByProjectile

 public virtual void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit)
 {
 }
开发者ID:guyde2011,项目名称:tModLoader,代码行数:3,代码来源:ModNPC.cs


注:本文中的Terraria.Projectile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。