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


C# ICollidable.getBoundingSpheres方法代码示例

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


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

示例1: collisionOccured

        public Boolean collisionOccured(ICollidable collideObject)
        {
            List<BoundingSphere> bss = collideObject.getBoundingSpheres();

            foreach (BoundingSphere bs in bss) {
                if (bs.Intersects(displayState.CollisionArea))
                    return true;
            }
            return false;
        }
开发者ID:Nesokas,项目名称:hs,代码行数:10,代码来源:Disk.cs

示例2: collisionOccured

        public Boolean collisionOccured(ICollidable collideObject)
        {
            List<BoundingSphere> bss = collideObject.getBoundingSpheres();

            foreach (BoundingSphere bs in bss) {
                if (bs.Intersects(stick))
                    return true;
                if (bs.Intersects(upBody))
                    return true;
                if (bs.Intersects(downBody))
                    return true;
            }

            return false;
        }
开发者ID:shadowpt,项目名称:hs,代码行数:15,代码来源:Player.cs

示例3: collisionOccured

        public bool collisionOccured(ICollidable collideObject)
        {
            bool collisionOccured = false;
            bool isObjectPlayer = collideObject is Player;
            Vector3 playerPosition = Vector3.Zero;
            bool[] deactivateKeys = new bool[4];
            Player player = null;
            if (isObjectPlayer) {
                player = (Player)collideObject;
                playerPosition = player.getPositionVector();
                for (int i = 0; i < 4; i++)
                    deactivateKeys[i] = false;
            }

            List<BoundingSphere> bs = collideObject.getBoundingSpheres();
            foreach (BoundingSphere sphere in bs) {
                if (!collisionOccured) {
                    if (_leftBox.Intersects(sphere)) {
                        Vector2 bounceVelocity = collideObject.getVelocity();
                        if(bounceVelocity.X > 0)
                            bounceVelocity.X *= -1;
                        collideObject.bounce(bounceVelocity);
                        if (isObjectPlayer)
                            deactivateKeys[(int)KeyboardKey.LEFT] = true;
                        collisionOccured = true;
                    }
                    if (_rightBox.Intersects(sphere)) {
                        Vector2 bounceVelocity = collideObject.getVelocity();
                        if(bounceVelocity.X < 0)
                            bounceVelocity.X *= -1;
                        collideObject.bounce(bounceVelocity);
                        if (isObjectPlayer)
                            deactivateKeys[(int)KeyboardKey.RIGHT] = true;
                        collisionOccured = true;
                    }
                    if (_backBox.Intersects(sphere)) {
                        Vector2 bounceVelocity = collideObject.getVelocity();
                        if(bounceVelocity.Y < 0)
                            bounceVelocity.Y *= -1;
                        collideObject.bounce(bounceVelocity);
                        if (isObjectPlayer)
                            deactivateKeys[(int)KeyboardKey.UP] = true;
                        collisionOccured = true;
                    }
                    if (_frontBox.Intersects(sphere)) {
                        Vector2 bounceVelocity = collideObject.getVelocity();
                        if(bounceVelocity.Y > 0)
                            bounceVelocity.Y *= -1;
                        collideObject.bounce(bounceVelocity);
                        if (isObjectPlayer)
                            deactivateKeys[(int)KeyboardKey.DOWN] = true;
                        collisionOccured = true;
                    }

                    if (isObjectPlayer)
                        player.deactivateKeys(deactivateKeys);
                }

            }

            return collisionOccured;
        }
开发者ID:Nesokas,项目名称:hs,代码行数:62,代码来源:Court.cs


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