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


C# PhysicsObject.getCenterPoint方法代码示例

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


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

示例1: painting_clicked_select

        //End of the callbacks, beginning of the helper fuctions
        //Used when the user clicks in the painting area while using the select tool.
        // This will select the object who's center is closest to the mouse.
        private void painting_clicked_select(MouseEventArgs e)
        {
            XnaPoint mousePosition = Conversion.PointToPoint(pb_Level.PointToClient(MousePosition));
            currentlySelectedObject = null;

            //Find all possible objects that we might be selecting.
            List<PhysicsObject> candidates = new List<PhysicsObject>();

            foreach (PhysicsObject obj in world.Objects)
            {
                if (obj.getBBRelativeToWorld().Contains(mousePosition))
                {
                    candidates.Add(obj);
                }
            }

            //If the room is the currently selected room, the player is not null, and the click is close enough
            // to the player's location, add the player to the list of possible candidates.
            /*
            if(currentState == State.EDITING_WORLD &&
                currentlySelectedRoom == world.CurrentRoom &&
                world.player != null &&
                world.player.getBBRelativeToWorld().Contains(mousePosition))
            {
                candidates.Add(world.player);
            }
            */

            //Find the object whose center is closest to the current mouse position. If there is no
            // possible selection, then the currentlySelectedObject continues to be null.
            foreach (PhysicsObject cand in candidates)
            {
                if (currentlySelectedObject == null ||
                        dist(mousePosition, cand.getCenterPoint()) < dist(mousePosition, currentlySelectedObject.getCenterPoint()))
                {

                    currentlySelectedObject = cand;

                    refreshResizeObjectBox();
                }
            }

            //If the currently selected item is a door, enable the door menu item. Otherwise, disable it.
            /*
            if (currentlySelectedObject != null &&
                currentlySelectedObject is Door)
            {

                menu_door.Enabled = true;
            }
            else
            {
                menu_door.Enabled = false;
            }
            */

            // Set fields in Object Properties panel
            if (currentlySelectedObject != null)
            {
                tb_Density.Enabled = true;
                tb_Rotation.Enabled = true;
                tb_bound1.Enabled = true;
                tb_bound2.Enabled = true;
                b_ApplyProperties.Enabled = true;
                b_Front.Enabled = true;
                tb_Scale.Enabled = true;
                cBox_StaticObject.Enabled = true;
                tb_Rotation.Text = (currentlySelectedObject.Angle * 180.0f / MathHelper.Pi).ToString();
                tb_Density.Text = currentlySelectedObject.Body.GetMass().ToString();
                tb_Scale.Text = currentlySelectedObject.scale.ToString();
                tb_bound1.Text = currentlySelectedObject.scale.ToString();
                tb_bound2.Text = currentlySelectedObject.scale.ToString();
                cBox_StaticObject.Checked = (currentlySelectedObject.Body.GetMass() == 0);

                /*
                if (currentlySelectedObject is HazardStatic)
                {
                    tb_Damage.Text = ((HazardStatic)currentlySelectedObject).Damage.ToString();
                    tb_Damage.Enabled = true;
                }
                else if (currentlySelectedObject is HazardDynamic)
                {
                    // Other
                    tb_Damage.Text = ((HazardDynamic)currentlySelectedObject).Damage.ToString();
                    tb_Damage.Enabled = true;
                }
                else if (currentlySelectedObject is Survivor || currentlySelectedObject is VanishWall)
                {
                    tb_SLevel.Enabled = true;
                }
                */

                //SetScriptingFields();
            }
            else
            {
                // Clear all the properties fields
//.........这里部分代码省略.........
开发者ID:danielpcox,项目名称:Crisis-at-Swiss-Station,代码行数:101,代码来源:Editor.cs


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