AddChildAtIndex() public méthode

public AddChildAtIndex ( FNode, node, int newIndex ) : void
node FNode,
newIndex int
Résultat void
Exemple #1
0
 public void MoveToBack()
 {
     if (_container != null)
     {
         _container.AddChildAtIndex(this, 0);
     }
 }
Exemple #2
0
    private void SwitchRoom(Room room, Direction dir)
    {
        // position room offset in direction we need
        switch (dir)
        {
        case Direction.N:
            room.y += _dungeon.RoomHeight;
            break;

        case Direction.S:
            room.y -= _dungeon.RoomHeight;
            break;

        case Direction.W:
            room.x -= _dungeon.RoomWidth;
            break;

        case Direction.E:
            room.x += _dungeon.RoomWidth;
            break;
        }

        // put up room we want to transition to
        Dungeon_Container.AddChildAtIndex(room, 0);
        _roomTransitionDirection = dir;
    }
Exemple #3
0
    public static FContainer getGameUIContainer(GamePage game)
    {
        if (GameUIContainer == null)
        {
            GameUIContainer = new FContainer();

            // add background
            FSprite bg = new FSprite("UI_background.png");
            bg.x = 0;
            bg.y = Futile.screen.halfHeight - (bg.height / 2);
            GameUIContainer.AddChildAtIndex(bg, 99);

            // add minimap
            GameUIContainer.AddChild(game._dungeon.minimap);

            // add gold count
            playerGold.text = "g: " + game.player.GoldCount;
            playerGold.x += -140;
            playerGold.y += Futile.screen.halfHeight - 20;
            GameUIContainer.AddChild(playerGold);

            // add sanity count
            playerSanity.text = game.player.HP.ToString();
            playerSanity.x += 260;
            playerSanity.y += Futile.screen.halfHeight - 60;
            GameUIContainer.AddChild(playerSanity);

            return GameUIContainer;
        }
        else return GameUIContainer;
    }
Exemple #4
0
    public static FContainer getGameUIContainer(GamePage game)
    {
        if (GameUIContainer == null)
        {
            GameUIContainer = new FContainer();

            // add background
            FSprite bg = new FSprite("UI_background.png");
            bg.x = 0;
            bg.y = Futile.screen.halfHeight - (bg.height / 2);
            GameUIContainer.AddChildAtIndex(bg, 99);

            // add minimap
            GameUIContainer.AddChild(game._dungeon.minimap);

            // add gold count
            playerGold.text = "g: " + game.player.GoldCount;
            playerGold.x   += -140;
            playerGold.y   += Futile.screen.halfHeight - 20;
            GameUIContainer.AddChild(playerGold);

            // add sanity count
            playerSanity.text = game.player.HP.ToString();
            playerSanity.x   += 260;
            playerSanity.y   += Futile.screen.halfHeight - 60;
            GameUIContainer.AddChild(playerSanity);

            return(GameUIContainer);
        }
        else
        {
            return(GameUIContainer);
        }
    }
Exemple #5
0
 private void MoveGoodThingiesToBottom()
 {
     foreach (Thingy thingy in thingies)
     {
         if (thingy.isGood)
         {
             thingyContainer.AddChildAtIndex(thingy, 0);
         }
     }
 }
    public virtual void finalize()
    {
        if (buttons.Keys.Count < 1)
        {
            throw new FutileException("You need to add more states to your toggle first!");
        }

        isFinalized = true;

        //kind of arbitrary... just pick one of the button states to offset the others by...
        offsetX = -1;
        offsetY = -1;
        int        lowestChild = -1;
        FContainer parent      = null;

        foreach (FButton button in buttons.Values)
        {
            if (offsetX == -1f)
            {
                offsetX = button.x;
            }
            if (offsetY == -1f)
            {
                offsetY = button.y;
            }

            if (button.container != null)
            {
                if (parent == null)
                {
                    parent = button.container;
                }
                if (lowestChild == -1 || parent.IndexOf(button) < lowestChild)
                {
                    lowestChild = parent.IndexOf(button);
                }
            }

            AddChild(button);
            button.x -= offsetX;
            button.y -= offsetY;
        }

        //place us back in the parent display tree
        parent.AddChildAtIndex(this, lowestChild);
        x = offsetX;
        y = offsetY;
    }
Exemple #7
0
    public void Reorder(bool shouldWaitUntilMathModeFinishes, bool shouldScrollToTop, bool isFlipping)
    {
        if (_slots.Count == 0)
        {
            return;                           //no need sorting things that don't exist :)
        }
        if (shouldWaitUntilMathModeFinishes)
        {
            for (int s = 0; s < _slots.Count; s++)
            {
                if (_slots[s].scoreBox.mathMode.amount > 0)
                {
                    return;                                                        //don't sort if one of them is in math mode
                }
            }
        }

        _isFlipping = isFlipping;

        List <Slot> originalSlots = new List <Slot>(_slots);       //create a copy

        Slot oldWinningSlot = _slots[0];

        float totalHeight = _slots.Count * (Config.SLOT_HEIGHT + Config.PADDING_M) - Config.PADDING_M;

        _minScrollY = Mathf.Min(0, -(totalHeight - _height) / 2 - Config.PADDING_M);
        _maxScrollY = Mathf.Max(0, (totalHeight - _height) / 2 + Config.PADDING_M);

        _canScroll = (totalHeight > _height);

        _slots.Sort(SlotSorter);

        for (int s = 0; s < _slots.Count; s++)
        {
            Slot slot = _slots[s];

            slotContainer.AddChildAtIndex(slot, 0);            //add at the bottom

            float newY = totalHeight * 0.5f - Config.SLOT_HEIGHT * 0.5f - (Config.SLOT_HEIGHT + Config.PADDING_M) * s;

            if (slot.index == -1)            //it's new!
            {
                slot.y = newY;

                float delay;

                if (_isInitializing)
                {
                    delay = 0.2f + (float)s * 0.1f;
                }
                else
                {
                    delay = _slots.Count == 1 ? 0 : 0.3f;                     //only delay if there are other players
                }

                //note how we make the tween longer AND delay it by the delay. weird effect :)
                Go.killAllTweensWithTarget(slot.buildInTweenable);
                Go.to(slot.buildInTweenable, 0.5f + delay, new TweenConfig().floatProp("amount", 1.0f).setDelay(delay));
            }
            else if (slot.index < s)            //moving down
            {
                Go.killAllTweensWithTarget(slot.buildInTweenable);
                Go.to(slot.buildInTweenable, 0.5f, new TweenConfig().floatProp("amount", 1.0f));

                Go.killAllTweensWithTarget(slot);
                Go.to(slot, 0.5f, new TweenConfig().floatProp("y", newY).setEaseType(EaseType.ExpoInOut));

                float delta       = s - slot.index;
                float scaleAmount = 0.04f + delta * 0.0075f;

                //slot shrink more the farther it travels downward

                RXTweenable tw = new RXTweenable(0.0f);
                tw.SignalChange += () =>
                {
                    slot.scale = 1.0f - scaleAmount * RXEase.UpDown(tw.amount, RXEase.SineIn);
                };

                Go.to(tw, 0.5f, new TweenConfig().floatProp("amount", 1.0f).setEaseType(EaseType.Linear));
            }
            else if (slot.index > s)            //moving up
            {
                Go.killAllTweensWithTarget(slot.buildInTweenable);
                Go.to(slot.buildInTweenable, 0.5f, new TweenConfig().floatProp("amount", 1.0f));

                Go.killAllTweensWithTarget(slot);
                Go.to(slot, 0.5f, new TweenConfig().floatProp("y", newY).setEaseType(EaseType.ExpoInOut));

                //slot grows more the farther it travels upward
                float delta       = slot.index - s;
                float scaleAmount = 0.04f + delta * 0.0075f;

                RXTweenable tw = new RXTweenable(0.0f);
                tw.SignalChange += () =>
                {
                    slot.scale = 1.0f + scaleAmount * RXEase.UpDown(tw.amount, RXEase.SineIn);
                };

                Go.to(tw, 0.5f, new TweenConfig().floatProp("amount", 1.0f).setEaseType(EaseType.Linear));
            }
            else
            {
                if (slot.y != newY)
                {
                    Go.killAllTweensWithTarget(slot.buildInTweenable);
                    Go.to(slot.buildInTweenable, 0.5f, new TweenConfig().floatProp("amount", 1.0f));

                    Go.killAllTweensWithTarget(slot);
                    Go.to(slot, 0.5f, new TweenConfig().floatProp("y", newY).setEaseType(EaseType.ExpoInOut));
                }
            }

            slot.index = s;
        }

        bool isThereANewWinner = (oldWinningSlot != _slots[0]);

        if (isThereANewWinner || shouldScrollToTop)
        {
            ScrollToTop(1.0f);
        }
        else if (!_canScroll)
        {
            ScrollToTop(0.5f);             //make sure it's always centered
        }

        if (isThereANewWinner)
        {
            //TODO: play winner sound
            _slots[0].player.color.PlayNormalSound();
        }

        if (!RXUtils.AreListsEqual(_slots, originalSlots))
        {
            FSoundManager.PlaySound("UI/Sort");
        }

        SKDataManager.MarkDirty();

        _isFlipping = false;
    }