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


C# Thing.TakeDamage方法代码示例

本文整理汇总了C#中Thing.TakeDamage方法的典型用法代码示例。如果您正苦于以下问题:C# Thing.TakeDamage方法的具体用法?C# Thing.TakeDamage怎么用?C# Thing.TakeDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thing的用法示例。


在下文中一共展示了Thing.TakeDamage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Impact

 /// <summary>
 /// Impacts a pawn/object or the ground.
 /// </summary>
 protected override void Impact(Thing hitThing)
 {
     base.Impact(hitThing);
     if (hitThing != null)
     {
         int damageAmountBase = this.def.projectile.damageAmountBase;
         BodyPartDamageInfo value = new BodyPartDamageInfo(null, null);
         DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(value), this.equipmentDef);
         hitThing.TakeDamage(dinfo);
         Pawn pawn = hitThing as Pawn;
         if (pawn != null && !pawn.Downed && Rand.Value < compED.chanceToProc)
         {
             MoteThrower.ThrowMicroSparks(this.destination);
             hitThing.TakeDamage(new DamageInfo(DefDatabase<DamageDef>.GetNamed(compED.damageDef, true), compED.damageAmount, this.launcher, null, null));
         }
     }
     else
     {
         SoundDefOf.BulletImpactGround.PlayOneShot(base.Position);
         MoteThrower.ThrowStatic(this.ExactPosition, ThingDefOf.Mote_ShotHit_Dirt, 1f);
         ThrowMicroSparksBlue(this.ExactPosition);
     }
 }
开发者ID:Skullywag,项目名称:GaussWeapons,代码行数:26,代码来源:Projectile_Gauss.cs

示例2: Impact

 protected override void Impact(Thing hitThing)
 {
     base.Impact(hitThing);
     if (hitThing != null)
     {
         int damageAmountBase = this.def.projectile.damageAmountBase;
         BodyPartDamageInfo value = new BodyPartDamageInfo(null, null);
         DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(value), this.equipment);
         hitThing.TakeDamage(dinfo);
         ExplosionThing(hitThing.Position);//Explosion method luncher
     }
     else
     {
         SoundDefOf.BulletImpactGround.PlayOneShot(base.Position);
         MoteThrower.ThrowStatic(this.ExactPosition, ThingDefOf.Mote_ShotHit_Dirt, 1f);
         ExplosionThing(this.Position);//Explosion method luncher
     }
 }
开发者ID:RimWorldProjectArmory,项目名称:-OLD-ProjectArmory,代码行数:18,代码来源:Projectile_PABullet.cs

示例3: Impact

 protected override void Impact(Thing hitThing)
 {
     base.Impact(hitThing);
     if (hitThing != null)
     {
         float height = this.GetProjectileHeight(this.shotHeight, this.distanceFromOrigin, this.shotAngle, this.shotSpeed);
         int damageAmountBase = this.def.projectile.damageAmountBase;
         BodyPartHeight? bodyPartHeight = null;
         Pawn pawn = hitThing as Pawn;
         if (pawn != null && pawn.GetPosture() == PawnPosture.Standing)	//Downed pawns randomly get damaged wherever, I guess
         {
             float fullHeight = Utility.GetCollisionHeight(hitThing);
             float percentOfBodySize = height / fullHeight;
             if (percentOfBodySize >= 0.8)
             {
                 bodyPartHeight = BodyPartHeight.Top;
             }
             else
             {
                 if (percentOfBodySize < 0.45)
                 {
                     bodyPartHeight = BodyPartHeight.Bottom;
                 }
                 else
                 {
                     bodyPartHeight = BodyPartHeight.Middle;
                 }
             }
         }
             //All the rest is handled further on - Even the BodyPartHeight not existing doesn't matter.
         BodyPartDamageInfo value = new BodyPartDamageInfo(bodyPartHeight, null);
         DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(value), this.equipmentDef);
         hitThing.TakeDamage(dinfo);
     }
     else
     {
         SoundDefOf.BulletImpactGround.PlayOneShot(base.Position);
         MoteThrower.ThrowStatic(this.ExactPosition, ThingDefOf.Mote_ShotHit_Dirt, 1f);
     }
 }
开发者ID:RimWorldMod,项目名称:CombatRealism,代码行数:40,代码来源:BulletCR.cs

示例4: Impact

 /// <summary>
 /// Impacts a pawn/object or the ground.
 /// </summary>
 protected override void Impact(Thing hitThing)
 {
     base.Impact(hitThing);
     if (hitThing != null)
     {
         int damageAmountBase = this.def.projectile.damageAmountBase;
         BodyPartDamageInfo value = new BodyPartDamageInfo(null, null);
         DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(value), this.equipmentDef);
         hitThing.TakeDamage(dinfo);
         Pawn pawn = hitThing as Pawn;
         if (pawn != null && !pawn.Downed && Rand.Value < Projectile_Plasma.burnChance)
         {
             MoteThrower.ThrowMicroSparks(this.destination);
             hitThing.TryAttachFire(0.1f);
         }
     }
     else
     {
         SoundDefOf.BulletImpactGround.PlayOneShot(base.Position);
         MoteThrower.ThrowStatic(this.ExactPosition, ThingDefOf.Mote_ShotHit_Dirt, 1f);
         ThrowMicroSparksGreen(this.ExactPosition);
     }
 }
开发者ID:Skullywag,项目名称:PlasmaWeapons,代码行数:26,代码来源:Projectile_Plasma.cs

示例5: Impact

 /// <summary>
 /// Impacts a pawn/object or the ground.
 /// </summary>
 protected override void Impact(Thing hitThing)
 {
     if (hitThing != null)
     {
         int damageAmountBase = this.def.projectile.damageAmountBase;
         BodyPartDamageInfo value = new BodyPartDamageInfo(null, null);
         DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(value), this.equipmentDef);
         hitThing.TakeDamage(dinfo);
         hitThing.def.soundImpactDefault.PlayOneShot(this.DestinationCell);
         Pawn pawn = hitThing as Pawn;
         if (pawn != null && !pawn.Downed && Rand.Value < Projectile_LaserRifle.stunChance)
         {
             hitThing.TakeDamage(new DamageInfo(DamageDefOf.Stun, 10, this.launcher, null, null));
         }
     }
     else
     {
         MoteThrower.ThrowStatic(this.destination, ThingDefOf.Mote_MicroSparks);
     }
 }
开发者ID:RimWorldMod,项目名称:CombatRealism,代码行数:23,代码来源:Projectile_LaserRifle.cs

示例6: CheckApplySpreadDamage

 /// <summary>
 /// Reduces damage applied on spread out damage by random amount
 /// </summary>
 /// <param name="dinfo"></param>
 /// <param name="t"></param>
 private void CheckApplySpreadDamage(DamageInfo dinfo, Thing t)
 {
     if (UnityEngine.Random.value < 0.5f)
     {
         dinfo.SetAmount(Mathf.CeilToInt((float)dinfo.Amount * Rand.Range(0.35f, 0.7f)));
         t.TakeDamage(dinfo);
     }
 }
开发者ID:RimWorldMod,项目名称:CombatRealism,代码行数:13,代码来源:DamageWorker_AddInjuryCR.cs

示例7: ApplyArmor

        private static bool ApplyArmor(ref float damAmount, ref float pierceAmount, float armorRating, Thing armorThing, DamageDef damageDef)
        {
            float originalDamage = damAmount;
            bool deflected = false;
            float penetrationChance = Mathf.Clamp((pierceAmount - armorRating) * 4, 0, 1);

            //Shot is deflected
            if (penetrationChance == 0 || Rand.Value > penetrationChance)
            {
                deflected = true;
            }
            //Damage calculations
            damAmount *= 1 - Mathf.Clamp(2 * armorRating - pierceAmount, 0, 1);

            //Damage armor
            if (armorThing != null)
            {
                float absorbedDamage = 0f;
                if (damageDef == absorbDamageDef)
                {
                    absorbedDamage = (originalDamage - damAmount) * (1 + pierceAmount);
                }
                else
                {
                    absorbedDamage = originalDamage * Mathf.Min(pierceAmount, 1f);
                }
                if (armorThing as Pawn == null)
                {
                    armorThing.TakeDamage(new DamageInfo(damageDef, Mathf.CeilToInt(absorbedDamage), null, null, null));
                }
                else
                {
                    damAmount += absorbedDamage;
                }
            }

            pierceAmount *= Mathf.Max(0, 1 - armorRating);
            return deflected;
        }
开发者ID:RimWorldMod,项目名称:CombatRealism,代码行数:39,代码来源:Utility.cs


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