RemoveFromContainer() public method

public RemoveFromContainer ( ) : void
return void
    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
                bubble.y=point.y-totalPointerLength-totalHeight*0.5f;
            }
            bubble.x=point.x;
            if (bubble.x+totalWidth*0.5f>visibleArea.xMax) {
                bubble.x=visibleArea.xMax-totalWidth*0.5f;
            } else if (bubble.x-totalWidth*0.5f<visibleArea.xMin) {
                bubble.x=visibleArea.xMin+totalWidth*0.5f;
            }
        } else {
            //vertical
            if (point.x<visibleArea.center.x) {
                //more space on the right
                bubble.x=point.x+totalPointerLength+totalWidth*0.5f;
            } else {
                //more space on the left
                bubble.x=point.x-totalPointerLength-totalWidth*0.5f;
            }
            bubble.y=point.y;
            if (bubble.y+totalHeight*0.5f>visibleArea.yMax) {
                bubble.y=visibleArea.yMax-totalHeight*0.5f;
            } else if (bubble.y-totalHeight*0.5f<visibleArea.yMin) {
                bubble.y=visibleArea.yMin+totalHeight*0.5f;
            }
        }

        bubble.SetSizeAndPointer(totalWidth,totalHeight,point-bubble.GetPosition(),pointerMargin);

        //bubble.alpha=0.25f;

        return bubble;
    }
Beispiel #2
0
    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();
    }