本文整理汇总了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
}
}
}
}
}
}
示例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
}
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
}
}
示例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);
}