Example #1
0
    public Slot(Player player, float width, float height)
    {
        this.player = player;

        _width  = width;
        _height = height;

        nameCell = new Cell();

        AddChild(handleBox = new HandleBox(this));
        AddChild(nameBox   = new NameBox(this));
        AddChild(scoreBox  = new ScoreBox(this));
        AddChild(minusBox  = new MathBox(this, MathType.Minus));
        AddChild(plusBox   = new MathBox(this, MathType.Plus));

        minusBox.SignalTick    += HandleMinusTick;
        plusBox.SignalTick     += HandlePlusTick;
        scoreBox.SignalRelease += HandleScoreTap;
        nameBox.SignalRelease  += HandleNameTap;

        ListenForUpdate(HandleUpdate);
        DoLayout();

        _resetTweenable  = new RXTweenable(0.0f, HandleResetTweenableChange);
        buildInTweenable = new RXTweenable(0.0f, HandleBuildInChange);

        HandleBuildInChange();
    }
Example #2
0
    public ScoreBox(Slot slot)
    {
        this.slot = slot;

        mathMode = new RXTweenable(0.0f,HandleMathModeChange);

        base.Init(slot.player);

        contentContainer.AddChild(_scoreLabel = new FLabel("Raleway",""));
        _scoreLabel.color = Color.black;

        _baseLabel = new FLabel("Raleway","123");
        _baseLabel.color = Color.black;

        _deltaLabel = new FLabel("Raleway","22");
        _deltaLabel.color = Color.black;

        _signIcon = new FSprite("Icons/Plus");
        _signIcon.color = Color.black;

        _equalsIcon = new FSprite("Icons/Equals");
        _equalsIcon.color = Color.black;

        _skullSprite = new FSprite("Icons/Skull");
        _skullSprite.color = Color.black;

        slot.player.SignalScoreChange += HandleScoreChange;

        ListenForUpdate(HandleUpdate);
        HandleMathModeChange();
        HandleScoreChange();
    }
Example #3
0
    public ScoreBox(Slot slot)
    {
        this.slot = slot;

        mathMode = new RXTweenable(0.0f, HandleMathModeChange);

        base.Init(slot.player);

        contentContainer.AddChild(_scoreLabel = new FLabel("Raleway", ""));
        _scoreLabel.color = Color.black;

        _baseLabel       = new FLabel("Raleway", "123");
        _baseLabel.color = Color.black;

        _deltaLabel       = new FLabel("Raleway", "22");
        _deltaLabel.color = Color.black;

        _signIcon       = new FSprite("Icons/Plus");
        _signIcon.color = Color.black;

        _equalsIcon       = new FSprite("Icons/Equals");
        _equalsIcon.color = Color.black;

        _skullSprite       = new FSprite("Icons/Skull");
        _skullSprite.color = Color.black;

        slot.player.SignalScoreChange += HandleScoreChange;

        ListenForUpdate(HandleUpdate);
        HandleMathModeChange();
        HandleScoreChange();
    }
Example #4
0
    public static RXTweenable DelayAction(float delay, Action action)
    {
        RXTweenable rt = new RXTweenable(0.0f);

        rt.To(1.0f, delay, new TweenConfig().onComplete((t) => { action(); }));
        return(rt);
    }
Example #5
0
    public Slot(Player player, float width, float height)
    {
        this.player = player;

        _width = width;
        _height = height;

        nameCell = new Cell();

        AddChild(handleBox = new HandleBox(this));
        AddChild(nameBox = new NameBox(this));
        AddChild(scoreBox = new ScoreBox(this));
        AddChild(minusBox = new MathBox(this, MathType.Minus));
        AddChild(plusBox = new MathBox(this, MathType.Plus));

        minusBox.SignalTick += HandleMinusTick;
        plusBox.SignalTick += HandlePlusTick;
        scoreBox.SignalRelease += HandleScoreTap;
        nameBox.SignalRelease += HandleNameTap;

        ListenForUpdate(HandleUpdate);
        DoLayout();

        _resetTweenable = new RXTweenable(0.0f, HandleResetTweenableChange);
        buildInTweenable = new RXTweenable(0.0f, HandleBuildInChange);

        HandleBuildInChange();
    }
Example #6
0
    public Box()
    {
        _alphaTweenable = new RXTweenable(1.0f);
        _alphaTweenable.SignalChange += () =>
        {
            this.alpha = _alphaTweenable.amount;
        };

        _colorTweenable = new RXTweenable(1.0f);

        _colorDelayTweenable = new RXTweenable(0.0f);
    }
Example #7
0
    public Box()
    {
        _alphaTweenable = new RXTweenable(1.0f);
        _alphaTweenable.SignalChange += () =>
        {
            this.alpha = _alphaTweenable.amount;
        };

        _colorTweenable = new RXTweenable(1.0f);

        _colorDelayTweenable = new RXTweenable(0.0f);
    }
Example #8
0
    private void HandlePlayerColorChange()
    {
        Color newColor = _player.color.color;

        RXTweenable delayTweenable = new RXTweenable(0.0f);

        delayTweenable.To(1.0f, colorTweenDelay + 0.001f, new TweenConfig().onComplete(
                              () =>
        {
            Color oldColor = boxSprite.color;

            //note: intentionally not using +=
            _colorTweenable.SignalChange = () =>
            {
                boxSprite.color = oldColor + (newColor - oldColor) * _colorTweenable.amount;
            };

            _colorTweenable.amount = 0.0f;

            _colorTweenable.To(1.0f, 0.3f);
        }
                              ));
    }
Example #9
0
    public VolumeBox()
    {
        base.Init(Player.NullPlayer);

        contentContainer.AddChild(mainSprite = new FSprite("Icons/Volume_Main"));
        contentSprites.Add(mainSprite);
        mainSprite.color = Color.black;

        contentContainer.AddChild(barASprite = new FSliceSprite("Icons/Volume_Bar", 6, 20, 8, 0, 8, 0));
        contentSprites.Add(barASprite);
        barASprite.color = Color.black;

        contentContainer.AddChild(barBSprite = new FSliceSprite("Icons/Volume_Bar", 6, 20, 8, 0, 8, 0));
        contentSprites.Add(barBSprite);
        barBSprite.color = Color.black;

        FSoundManager.Init();
        _isMuted = FSoundManager.isMuted;

        //1.0f = muted (X), 0.0f = unmuted (||)
        muteTweenable = new RXTweenable(_isMuted ? 1.0f : 0.0f);
        muteTweenable.SignalChange += HandleMuteChange;
        HandleMuteChange();
    }
Example #10
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;
    }
Example #11
0
    private void HandlePlayerColorChange()
    {
        Color newColor = _player.color.color;

        RXTweenable delayTweenable = new RXTweenable(0.0f);

        delayTweenable.To(1.0f,colorTweenDelay+0.001f,new TweenConfig().onComplete(
        ()=>
        {
            Color oldColor = boxSprite.color;

            //note: intentionally not using +=
            _colorTweenable.SignalChange = () =>
            {
                boxSprite.color = oldColor + (newColor - oldColor) * _colorTweenable.amount;
            };

            _colorTweenable.amount = 0.0f;

            _colorTweenable.To(1.0f,0.3f);
        }
        ));
    }
Example #12
0
    public VolumeBox()
    {
        base.Init(Player.NullPlayer);

        contentContainer.AddChild(mainSprite = new FSprite("Icons/Volume_Main"));
        contentSprites.Add(mainSprite);
        mainSprite.color = Color.black;

        contentContainer.AddChild(barASprite = new FSliceSprite("Icons/Volume_Bar",6,20,8,0,8,0));
        contentSprites.Add(barASprite);
        barASprite.color = Color.black;

        contentContainer.AddChild(barBSprite = new FSliceSprite("Icons/Volume_Bar",6,20,8,0,8,0));
        contentSprites.Add(barBSprite);
        barBSprite.color = Color.black;

        FSoundManager.Init();
        _isMuted = FSoundManager.isMuted;

        //1.0f = muted (X), 0.0f = unmuted (||)
        muteTweenable = new RXTweenable(_isMuted ? 1.0f : 0.0f);
        muteTweenable.SignalChange += HandleMuteChange;
        HandleMuteChange();
    }
Example #13
0
 public PlayerEditor()
 {
     deleteModeTweenable = new RXTweenable(0.0f);
     deleteModeTweenable.SignalChange   += HandleDeleteModeChange;
     AddChild(keyboardAndSwatchContainer = new FContainer());
 }
Example #14
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;
    }
Example #15
0
 public PlayerEditor()
 {
     deleteModeTweenable = new RXTweenable(0.0f);
     deleteModeTweenable.SignalChange += HandleDeleteModeChange;
     AddChild(keyboardAndSwatchContainer = new FContainer());
 }