當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。