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


C# BoundingSphere.Intersects方法代码示例

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


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

示例1: CheckForBulletAsteroidCollision

 public void CheckForBulletAsteroidCollision(float bulletRadius, float asteroidRadius)
 {
     for (int i = 0; i < GamePlay.asteroidList.Length; i++)
     {
         if (GamePlay.asteroidList[i].isActive)
         {
             BoundingSphere asteroidSphere = new BoundingSphere(GamePlay.asteroidList[i].position, asteroidRadius * 0.95f);
             for (int j = 0; j < bulletList.Length; j++)
             {
                 if (bulletList[j].isActive)
                 {
                     BoundingSphere bulletSphere = new BoundingSphere(bulletList[j].position, bulletRadius);
                     if (asteroidSphere.Intersects(bulletSphere))
                     {
                         MainClass.soundBank.PlayCue("explosion2");
                         GamePlay.asteroidList[i].isActive = false;
                         bulletList[j].isActive = false;
                         bulletList[j].startTimer = false;
                         bulletList[j].timer = 0;
                         score += GameConstants.KillBonus;
                         if (GamePlay.random.Next(4) == 0 && !powerUp.isActive)
                             powerUp.Initialize(GamePlay.asteroidList[i].position);
                         return; //no need to check other bullets
                     }
                 }
             }
         }
     }
 }
开发者ID:hassanselim0,项目名称:Asteroids-Game,代码行数:29,代码来源:Player.cs

示例2: Update

        public void Update(GameTime gameTime)
        {
            if (timer > 0)
            {
                timer -= gameTime.ElapsedGameTime.TotalSeconds;
                scale += 0.12f;
                alpha -= 0.016f;
            }
            else
                isActive = false;

            BoundingSphere bombSphere = new BoundingSphere(position, explosionModel.Meshes[0].BoundingSphere.Radius * scale);
            for (int i = 0; i < GamePlay.asteroidList.Length; i++)
            {
                if (GamePlay.asteroidList[i].isActive)
                {
                    BoundingSphere asteroidSphere = new BoundingSphere(GamePlay.asteroidList[i].position,
                        GamePlay.asteroidModel.Meshes[0].BoundingSphere.Radius * 0.95f);
                    if (asteroidSphere.Intersects(bombSphere))
                    {
                        //destroy asteroid
                        MainClass.soundBank.PlayCue("explosion2");
                        GamePlay.asteroidList[i].isActive = false;
                        GamePlay.playerList[index].score += GameConstants.KillBonus;
                        return; //exit the loop
                    }
                }
            }
        }
开发者ID:hassanselim0,项目名称:Asteroids-Game,代码行数:29,代码来源:Bomb.cs

示例3: VisitTree

 public static void VisitTree(OctCell root, BoundingSphere bounds, Action<OctCell> callback)
 {
     if (bounds.Intersects(root.Bounds))
     {
         if (root.Leaf) callback(root);
         else foreach (var child in root.Children) VisitTree(child, bounds, callback);
     }
 }
开发者ID:Blecki,项目名称:GemgineCore,代码行数:8,代码来源:OctTree.cs

示例4: DoWork

        public override void DoWork()
        {
            MySphereSensorElement sphere = (MySphereSensorElement) m_SensorElement;

            BoundingSphere seSphere = new BoundingSphere(sphere.GetGlobalTransformation().Translation, sphere.Radius);
            BoundingBox oeAABB = m_RBElement.GetWorldSpaceAABB();
            seSphere.Intersects(ref oeAABB, out m_IsInside);
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:8,代码来源:MySphereOtherSensorInteraction.cs

示例5: Intersects

 public override bool Intersects(Ray ray)
 {
     Matrix worldInverted = Matrix.Invert(Transform.World);
     ray.Position = Vector3.Transform(ray.Position, worldInverted);
     ray.Direction = Vector3.Normalize(Vector3.TransformNormal(ray.Direction, worldInverted));
     BoundingSphere sphere = new BoundingSphere(Vector3.Zero, Radius);
     return sphere.Intersects(ray) != null;
 }
开发者ID:ravikamath,项目名称:CPI311,代码行数:8,代码来源:SphereCollider.cs

示例6: KnockOutEnemies

 //Knock out any enemy that you crash into
 public static void KnockOutEnemies(BoundingSphere boundingSphere, Vector3 Position, int MaxRangeX, int MaxRangeZ, BaseEnemy[] enemies, ref int enemiesAmount, SwimmingObject[] fishes, int fishAmount, AudioLibrary audio, GameMode gameMode)
 {
     for (int i = 0; i < enemiesAmount; i++)
     {
         if (boundingSphere.Intersects(enemies[i].BoundingSphere))
         {
             PoseidonGame.audio.bodyHit.Play();
             float healthiness = HydroBot.currentEnergy / GameConstants.PlayerStartingEnergy;
             if (healthiness > 1) healthiness = 1.0f;
             Vector3 oldPosition = enemies[i].Position;
             Vector3 pushVector = enemies[i].Position - Position;
             pushVector.Normalize();
             //can't stun a submarine
             if (!(enemies[i] is Submarine))
             {
                 enemies[i].stunned = true;
                 enemies[i].stunnedStartTime = PoseidonGame.playTime.TotalSeconds;
                 if (HydroBot.sonicHipnotiseMode)
                 {
                     enemies[i].setHypnotise();
                 }
             }
             enemies[i].Position += (pushVector * GameConstants.ThorPushFactor);
             enemies[i].Position.X = MathHelper.Clamp(enemies[i].Position.X, -MaxRangeX, MaxRangeX);
             enemies[i].Position.Z = MathHelper.Clamp(enemies[i].Position.Z, -MaxRangeZ, MaxRangeZ);
             enemies[i].BoundingSphere.Center = enemies[i].Position;
             if (Collision.isBarrierVsBarrierCollision(enemies[i], enemies[i].BoundingSphere, fishes, fishAmount)
                 || Collision.isBarrierVsBarrierCollision(enemies[i], enemies[i].BoundingSphere, enemies, enemiesAmount))
             {
                 enemies[i].Position = oldPosition;
                 enemies[i].BoundingSphere.Center = oldPosition;
             }
             int healthloss = (int)(GameConstants.HermesDamage * healthiness * HydroBot.speed * HydroBot.speedUp * HydroBot.sandalPower);
             enemies[i].health -= healthloss;
             //audio.Shooting.Play();
             //if (enemies[i].health <= 0)
             //{
             //    if (enemies[i].isBigBoss == true) PlayGameScene.isBossKilled = true;
             //    for (int k = i + 1; k < enemiesAmount; k++)
             //    {
             //        enemies[k - 1] = enemies[k];
             //    }
             //    enemies[--enemiesAmount] = null;
             //    i--;
             //}
             Point point = new Point();
             String point_string = "-" + healthloss.ToString() + "HP";
             point.LoadContent(PoseidonGame.contentManager, point_string, enemies[i].Position, Color.DarkRed);
             if (gameMode == GameMode.ShipWreck)
                 ShipWreckScene.points.Add(point);
             else if (gameMode == GameMode.MainGame)
                 PlayGameScene.points.Add(point);
             else if (gameMode == GameMode.SurvivalMode)
                 SurvivalGameScene.points.Add(point);
         }
     }
 }
开发者ID:khoatle,项目名称:game,代码行数:58,代码来源:CastSkill.cs

示例7: Collision3D

 public static bool Collision3D(BoundingSphere player, Object3D object1, Vector3 pos)
 {
     for (int i = 0; i < object1.Model.Meshes.Count; i++)
     {
         BoundingSphere bs1 = object1.Model.Meshes[i].BoundingSphere;
         bs1.Center += object1.Position;
         if (player.Intersects(bs1))
             return true;
     }
     return false;
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:11,代码来源:Collision.cs

示例8: isAchieving

        public Boolean isAchieving(Football football)
        {
            float radius = this.vecDimensions.X / 2;
            BoundingSphere starSphere = new BoundingSphere(new Vector3(vecPosition.X + radius, vecPosition.Y + radius, 0), radius);
            BoundingSphere footballsphere = new BoundingSphere(new Vector3(football.position.X + football.radius, football.position.Y + football.radius, 0), football.radius);
            if (starSphere.Intersects(footballsphere))
            {

                return true;
            }
            return false;
        }
开发者ID:kanavarora,项目名称:Bouncy-Ball-WPS-game,代码行数:12,代码来源:Star.cs

示例9: isAchieving

 public override Boolean isAchieving(Football football)
 {
     float radius = this.dimensions.X / 2;
     BoundingSphere bonusball = new BoundingSphere(new Vector3(vecPosition.X + radius, vecPosition.Y + radius, 0), radius);
     BoundingSphere footballsphere = new BoundingSphere(new Vector3(football.position.X + football.radius, football.position.Y + football.radius, 0), football.radius);
     if (bonusball.Intersects(footballsphere))
     {
         UpdateStatsOnAchieving();
         return true;
     }
     return false;
 }
开发者ID:kanavarora,项目名称:Bouncy-Ball-WPS-game,代码行数:12,代码来源:TimeBonusObject.cs

示例10: intersects

 public bool intersects(BoundingSphere otherFrame)
 {
     boundingFrame = new Rectangle((int)worldPosition.X, (int)worldPosition.Y, texture.Bounds.Width, texture.Bounds.Height);
     if (otherFrame.Intersects(new BoundingBox(new Vector3(boundingFrame.X, boundingFrame.Y, 0), new Vector3(boundingFrame.X + boundingFrame.Width, boundingFrame.Y + boundingFrame.Height, 0))))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:ProjPossibility,项目名称:USC-AccessibleKinect,代码行数:12,代码来源:Actor.cs

示例11: CheckForCollision

 public bool CheckForCollision(BoundingSphere bulletBoundingSphere, Debris[] barriers)
 {
     for (int curBarrier = 0; curBarrier < barriers.Length; curBarrier++)
     {
         if (bulletBoundingSphere.Intersects(
             barriers[curBarrier].BoundingSphere) && !barriers[curBarrier].Destroyed)
         {
             barriers[curBarrier].Destroyed = true;
             return true;
         }
     }
     return false;
 }
开发者ID:ChrisLau90,项目名称:Programming-for-3D-Assignment,代码行数:13,代码来源:Bullet.cs

示例12: calculatePlacingPosition

        public static Vector3 calculatePlacingPosition(float radius, HydroBot bot, BaseEnemy[] enemies, int enemiesAmount, Fish[] fish, int fishAmount)
        {
            Random random = new Random();
            BoundingSphere newSphere = new BoundingSphere(new Vector3(), radius);
            float X, Y = bot.Position.Y, Z;
            do {
                X = (float)random.NextDouble() * (2 * bot.Position.X + 50) - bot.Position.X - 25f;
                //X = bot.Position.X + (float)random.NextDouble() * 50f;
                Z = (float)random.NextDouble() * (2 * bot.Position.Z + 50) - bot.Position.Z - 25f;
                newSphere.Center = new Vector3(X, Y, Z);
            } while (IsSurfaceOccupied(newSphere, enemiesAmount, fishAmount, enemies, fish) || newSphere.Intersects(bot.BoundingSphere));

            return new Vector3(X, Y, Z);
        }
开发者ID:khoatle,项目名称:game,代码行数:14,代码来源:AddingObjects.cs

示例13: Collision

        public bool Collision(BoundingSphere primarySphere, BoundingSphere secondarySphere)
        {
            //example of what a circle code should look like
            //primarySphere = new BoundingSphere(new Vector3(center, 0), center.Length());

            ContainmentType contains = primarySphere.Contains(secondarySphere);

            if (primarySphere.Intersects(secondarySphere) || contains == ContainmentType.Intersects)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:Harmonickey,项目名称:AlexCSPortfolio,代码行数:16,代码来源:GameObject.cs

示例14: BuildTree

 public static void BuildTree(OctCell root, BoundingSphere bounds, Action<OctCell> forLeaves, float leafSize)
 {
     if (bounds.Intersects(root.box))
     {
         if ((root.box.Max.X - root.box.Min.X) <= leafSize)
         {
             if (root.contents == null) root.contents = new List<OctNode>();
             forLeaves(root);
         }
         else
         {
             if (root.children == null) root.children = splitCell(root);
             foreach (var child in root.children) BuildTree(child, bounds, forLeaves, leafSize);
         }
     }
 }
开发者ID:hvp,项目名称:Gemgine,代码行数:16,代码来源:OctTree.cs

示例15: GetIntersectingNodes

 public bool GetIntersectingNodes(ref BoundingSphere sphere, ref List<OCTreeNode> nodes)
 {
     if (sphere.Intersects(Bounds))
     {
         if (Indices != null)
         {
             nodes.Add(this);
         }
         if (Children != null)
         {
             for (var i = 0; i < Children.Length; i++)
             {
                 Children[i].GetIntersectingNodes(ref sphere, ref nodes);
             }
         }
     }
     return (nodes.Count > 0);
 }
开发者ID:KroneckerX,项目名称:WCell,代码行数:18,代码来源:OCTreeNode.cs


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