本文整理汇总了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
//.........这里部分代码省略.........