本文整理汇总了C#中FNode.RemoveFromContainer方法的典型用法代码示例。如果您正苦于以下问题:C# FNode.RemoveFromContainer方法的具体用法?C# FNode.RemoveFromContainer怎么用?C# FNode.RemoveFromContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FNode
的用法示例。
在下文中一共展示了FNode.RemoveFromContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
public FSpeechBubble Show(FNode node, float width, float height, float contentMarginX, float contentMarginY, Vector2 point, float pointerLength, float pointerMargin, Color backgroundColor, FContainer container, Rect visibleArea)
{
FSpeechBubble bubble=new FSpeechBubble();
bubble.backgroundColor=backgroundColor;
if (node!=null) {
if (node.container!=null) node.RemoveFromContainer();
bubble.AddChild(node);
}
container.AddChild(bubble);
//size fo the bubble with content margin taken into account
float totalWidth=width+contentMarginX*2;
float totalHeight=height+contentMarginY*2;
float totalPointerLength=pointerLength+pointerMargin;
float verticalFreeWidth=0,verticalFreeHeight=0;
float horizontalFreeWidth=0,horizontalFreeHeight=0;
//Try first the space on top/bottom or left/right
//Determine which space is best suited
if (point.x<visibleArea.center.x) {
//more space on the right
verticalFreeWidth=visibleArea.xMax-point.x-totalPointerLength;
verticalFreeHeight=visibleArea.height;
} else {
//more space on the left
verticalFreeWidth=point.x-visibleArea.xMin-totalPointerLength;
verticalFreeHeight=visibleArea.height;
}
if (point.y<visibleArea.center.y) {
//more space on the top
horizontalFreeWidth=visibleArea.width;
horizontalFreeHeight=visibleArea.yMax-point.y-totalPointerLength;
} else {
//more space on the bottom
horizontalFreeWidth=visibleArea.width;
horizontalFreeHeight=point.y-visibleArea.yMin-totalPointerLength;
}
float verticalRemainingSurface=-1,horizontalRemainingSurface=-1;
float verticalHiddenSurface=0,horizontalHiddenSurface=0;
bool verticalFit=false,horizontalFit=false;
if ((totalWidth<=verticalFreeWidth)&&(totalHeight<=verticalFreeHeight)) {
verticalFit=true;
} else {
if (totalWidth>verticalFreeWidth) {
verticalHiddenSurface+=(totalWidth-verticalFreeWidth)*totalHeight;
}
if (totalHeight>verticalFreeHeight) {
verticalHiddenSurface+=(totalHeight-verticalFreeHeight)*totalWidth;
}
}
verticalRemainingSurface=verticalFreeWidth*verticalFreeHeight-totalWidth*totalHeight;
if ((totalWidth<=horizontalFreeWidth)&&(totalHeight<=horizontalFreeHeight)) {
horizontalFit=true;
} else {
if (totalWidth>horizontalFreeWidth) {
horizontalHiddenSurface+=(totalWidth-horizontalFreeWidth)*totalHeight;
}
if (totalHeight>horizontalFreeHeight) {
horizontalHiddenSurface+=(totalHeight-horizontalFreeHeight)*totalWidth;
}
}
horizontalRemainingSurface=horizontalFreeWidth*horizontalFreeHeight-totalWidth*totalHeight;
bool chooseHorizontal;
if (verticalFit && horizontalFit) {
if (verticalRemainingSurface>horizontalRemainingSurface) {
//choose vertical
chooseHorizontal=false;
} else {
//choose horizontal
chooseHorizontal=true;
}
} else if (horizontalFit) {
//choose horizontal
chooseHorizontal=true;
} else if (verticalFit) {
//choose vertical
chooseHorizontal=false;
} else {
if (verticalHiddenSurface<horizontalHiddenSurface) {
//choose vertical
chooseHorizontal=false;
} else {
//choose horizontal
chooseHorizontal=true;
}
}
if (chooseHorizontal) {
//horizontal
if (point.y<visibleArea.center.y) {
//more space on the top
bubble.y=point.y+totalPointerLength+totalHeight*0.5f;
} else {
//more space on the bottom
//.........这里部分代码省略.........
示例2: removeObject
public void removeObject(FNode objectToRemove)
{
if (objectToRemove is Knight || objectToRemove is Arrow || objectToRemove is Heart || objectToRemove is MagicOrb || objectToRemove is Ghost || objectToRemove is SoulPickup)
{
damageObjects.Remove((FutilePlatformerBaseObject)objectToRemove);
}
else
if (objectToRemove is FutilePlatformerBaseObject)
collisionObjects.Remove((FutilePlatformerBaseObject)objectToRemove);
if (objectToRemove is Sign)
signs.Remove((Sign)objectToRemove);
if (objectToRemove is Villager)
villagers.Remove((Villager)objectToRemove);
if (objectToRemove is HitSwitch)
hitSwitches.Remove((HitSwitch)objectToRemove);
objectToRemove.RemoveFromContainer();
}