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


C# Objects.doDamage方法代码示例

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


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

示例1: checkTwoObjects

 private void checkTwoObjects(Objects.StaticObject obj1, Objects.StaticObject obj2)
 {
     if (obj1 is Objects.Projectile || obj2 is Objects.Projectile)
     {
         if (obj1 is Objects.Projectile)
         {
             if (obj2.Equals(((Objects.Projectile)obj1).parent))
                 return;
             obj1.doDamage(10000);
             obj2.doDamage(((Objects.Projectile)obj1).damage);
             if (obj2 is Objects.playerObject)
             {
                 if (numPlayers.Equals(Players.two))
                 {
                     explosion.Play();
                 }
                 else
                 {
                     if (obj2.Team.Equals(Team.Red))
                         explosion.Play();
                 }
             }
         }
         else
         {
             if (obj1.Equals(((Objects.Projectile)obj2).parent))
                 return;
             obj2.doDamage(10000);
             obj1.doDamage(((Objects.Projectile)obj2).damage);
             if (obj1 is Objects.playerObject)
             {
                 if (numPlayers.Equals(Players.two))
                 {
                     explosion.Play();
                 }
                 else
                 {
                     if (obj1.Team.Equals(Team.Red))
                         explosion.Play();
                 }
             }
         }
     }
     else
     {
         // add object collision settings
         if (obj1 is Objects.DynamicObject && obj2 is Objects.DynamicObject)
         {
             Objects.DynamicObject d1 = obj1 as Objects.DynamicObject;
             Objects.DynamicObject d2 = obj2 as Objects.DynamicObject;
             d1.bumpVelocity += Vector3.Normalize(Matrix.CreateFromQuaternion(d2.rotation).Forward) * d2.Mass * d2.ShipMovementInfo.speed / d1.Mass * COLLISION_SPEED_PRESERVATION;
             d2.bumpVelocity += Vector3.Normalize(Matrix.CreateFromQuaternion(d1.rotation).Forward) * d1.Mass * d1.ShipMovementInfo.speed / d2.Mass * COLLISION_SPEED_PRESERVATION;
         }
         else if (obj1 is Objects.DynamicObject)
         {
             Objects.DynamicObject d = obj1 as Objects.DynamicObject;
             d.bumpVelocity += Vector3.Normalize(Matrix.CreateFromQuaternion(d.rotation).Backward) * d.ShipMovementInfo.speed * COLLISION_SPEED_PRESERVATION;
         }
         else if (obj2 is Objects.DynamicObject)
         {
             Objects.DynamicObject d = obj2 as Objects.DynamicObject;
             d.bumpVelocity += Vector3.Normalize(Matrix.CreateFromQuaternion(d.rotation).Backward) * d.ShipMovementInfo.speed * COLLISION_SPEED_PRESERVATION;
         }
         obj1.ShipMovementInfo.speed = 0;
         obj2.ShipMovementInfo.speed = 0;
     }
 }
开发者ID:nthfloor,项目名称:Nebulon12,代码行数:67,代码来源:GameController.cs


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