示例#1
0
    public void SetAnimationFrameByFloat(HumanAnimation ani, float progress, float step)
    {
        float percent = Mathf.Clamp01(RXMath.Mod(progress, step) / step);
        int   frame   = Mathf.RoundToInt(percent * (float)(ani.numFrames - 1));

        SetAnimationFrame(ani, frame);
    }
    void HandleUpdate()
    {
        timeUntilTransition -= Time.deltaTime;
        if (timeUntilTransition < 0)
        {
            timeLeftInTransition = transitionTime + timeUntilTransition;
            float percent = Mathf.Clamp01((transitionTime - timeLeftInTransition) / transitionTime);

            NodeInfo current = infos[currentIndex];
            NodeInfo next    = infos[(currentIndex + 1) % infos.Count];

            if (next.node.container == null)
            {
                AddChild(next.node);
            }

            current.node.alpha = 1.0f - RXMath.GetSubPercent(percent, 0.0f, 0.55f);
            next.node.alpha    = RXMath.GetSubPercent(percent, 0.45f, 1.0f);

            if (timeLeftInTransition < 0)
            {
                current.node.RemoveFromContainer();
                currentIndex        = (currentIndex + 1) % infos.Count;
                timeUntilTransition = infos[currentIndex].showDuration;
            }
        }
    }
示例#3
0
    private void HandleBuildInChange()
    {
        float amount = buildInTweenable.amount;

        handleBox.scale = RXEase.ExpoOut(RXMath.GetSubPercent(amount, 0.0f, 0.4f));
        nameBox.scale   = RXEase.ExpoOut(RXMath.GetSubPercent(amount, 0.15f, 0.55f));
        scoreBox.scale  = RXEase.ExpoOut(RXMath.GetSubPercent(amount, 0.3f, 0.7f));
        minusBox.scale  = RXEase.ExpoOut(RXMath.GetSubPercent(amount, 0.45f, 0.85f)) * (1.0f - _resetTweenable.amount);
        plusBox.scale   = RXEase.ExpoOut(RXMath.GetSubPercent(amount, 0.6f, 1.0f)) * (1.0f - _resetTweenable.amount);
    }
示例#4
0
    private void HandleUpdate()
    {
        if (ResetGroup.instance != null)
        {
            _scoreTarget = ResetGroup.instance.zeroBox.resetAmount;
        }
        else
        {
            _scoreTarget = slot.player.score;
        }

        _easedScore += ((float)_scoreTarget - _easedScore) / 6.0f;
        int newScore = Mathf.RoundToInt(_easedScore);

        if (newScore != _displayScore)
        {
            _displayScore    = newScore;
            _scoreLabel.text = _displayScore.ToString();
            DoLayout();
        }

        if (mathMode.amount > 0 && !_isMathMode)
        {
            _isMathMode = true;
            StartMathMode();
        }
        else if (mathMode.amount == 0 && _isMathMode)
        {
            _isMathMode = false;
            EndMathMode();
        }

        if (_isMathMode)
        {
            _baseLabel.alpha  = RXMath.GetSubPercent(mathMode.amount, 0.4f, 1.0f);
            _signIcon.alpha   = RXMath.GetSubPercent(mathMode.amount, 0.5f, 1.0f);
            _deltaLabel.alpha = RXMath.GetSubPercent(mathMode.amount, 0.6f, 1.0f);
            _equalsIcon.alpha = RXMath.GetSubPercent(mathMode.amount, 0.7f, 1.0f);

            float scorePercent = RXEase.Linear(RXMath.GetSubPercent(mathMode.amount, 0.0f, 0.8f));
            float scoreTargetX = _scoreLabelFullX + (_scoreLabelCompactX - _scoreLabelFullX) * scorePercent;
            _scoreLabel.scale = _scoreLabelFullScale + (_scoreLabelCompactScale - _scoreLabelFullScale) * scorePercent;

            _scoreLabel.x += (scoreTargetX - _scoreLabel.x) * 0.5f;
            _deltaLabel.x += (_deltaTargetX - _deltaLabel.x) * 0.5f;
            _baseLabel.x  += (_baseTargetX - _baseLabel.x) * 0.5f;
            _signIcon.x   += (_signTargetX - _signIcon.x) * 0.5f;
            _equalsIcon.x += (_equalsTargetX - _equalsIcon.x) * 0.5f;
        }
        else
        {
            _scoreLabel.x     = _scoreLabelFullX;
            _scoreLabel.scale = _scoreLabelFullScale;
        }
    }
示例#5
0
    public NameBoxCursor()
    {
        AddChild(_sprite = new FSprite("Box"));
        _sprite.width    = 5.0f;
        _sprite.height   = 28.0f;
        _sprite.color    = Color.black;

        ListenForUpdate(() =>
        {
            _sprite.alpha = 0.2f + RXMath.Saw(Time.time / 0.4f);
        });
    }
示例#6
0
    protected void HandleUpdate()
    {
        _logo.rotation = -5.0f + RXMath.PingPong(_frameCount, 300) * 10.0f;

        _frameCount++;
    }
示例#7
0
    void HandleDeleteModeChange()
    {
        float amount = deleteModeTweenable.amount;

        Cell fullCell = CellManager.GetCellFromGrid(2, 7, 2, 2);

        float qMarkWidth   = QUESTION_MARK_WIDTH; //question mark width
        float skullWidth   = SKULL_WIDTH;         //skull width
        float skullPadding = Config.PADDING_M;    //padding between skull and right side

        float innerWidth = 0;

        innerWidth += skullWidth;
        innerWidth += skullPadding;
        innerWidth += Config.GRID_SPACING;                        //grid spacing
        innerWidth += Config.PADDING_L;                           //left side text padding
        innerWidth += nameBox.nameLabel.textRect.width * nameBox.nameLabel.scale;
        innerWidth += Config.PADDING_L * nameBox.nameLabel.scale; //padding between text and question mark
        innerWidth += qMarkWidth * nameBox.nameLabel.scale;

        Debug.Log("full cell width " + fullCell.width);

        float remainingWidth = fullCell.width - innerWidth;
        float halfRemaining  = remainingWidth / 2;

        float deleteBoxTargetWidth = Mathf.Max(CellManager.GetGridColWidth(), halfRemaining + skullWidth + skullPadding);
        float nameBoxTargetWidth   = fullCell.width - deleteBoxTargetWidth;

        float deleteBoxTargetX = fullCell.x - fullCell.width / 2 + deleteBoxTargetWidth / 2;
        float nameBoxTargetX   = fullCell.x + fullCell.width / 2 - nameBoxTargetWidth / 2;

        //make sure the gap is filled
        deleteBoxTargetWidth += 2;
        deleteBoxTargetX     += 1;

        //make the delete cell fill the gap

        float deletePercent = RXMath.GetSubPercent(amount, 0.0f, 0.8f);
        float namePercent   = RXMath.GetSubPercent(amount, 0.0f, 0.8f);

        deleteBox.x     = deleteBox.anchorCell.x + (deleteBoxTargetX - deleteBox.anchorCell.x) * RXEase.ExpoInOut(deletePercent);
        deleteBox.width = deleteBox.anchorCell.width + (deleteBoxTargetWidth - deleteBox.anchorCell.width) * RXEase.ExpoInOut(deletePercent);

        nameBox.x     = nameBox.anchorCell.x + (nameBoxTargetX - nameBox.anchorCell.x) * RXEase.ExpoInOut(namePercent);
        nameBox.width = nameBox.anchorCell.width + (nameBoxTargetWidth - nameBox.anchorCell.width) * RXEase.ExpoInOut(namePercent);

        Debug.Log("deleteBox x is " + deleteBox.x + " going from " + deleteBox.anchorCell.x + " to " + deleteBoxTargetX + " perc " + deletePercent);

        float skullPercent = RXMath.GetSubPercent(amount, 0.0f, 1.0f);
        float skullTargetX = deleteBoxTargetWidth / 2 - skullPadding - skullWidth / 2;

        deleteSkull.x = 0 + (skullTargetX - 0) * RXEase.ExpoInOut(skullPercent);

        deleteQMark.alpha = RXMath.GetSubPercent(amount, 0.5f, 1.0f);

        //////////
        //ok and cancel buttons
        //////////

        float okPercent = RXMath.GetSubPercent(amount, 0.0f, 0.3f);
        float okX       = Config.HALF_WIDTH + okBox.anchorCell.width;

        okBox.x = okBox.anchorCell.x + (okX - okBox.anchorCell.x) * RXEase.ExpoInOut(okPercent);

        float deleteCancelPercent = RXMath.GetSubPercent(amount, 0.5f, 0.95f);
        float deleteOkPercent     = RXMath.GetSubPercent(amount, 0.65f, 1.0f);

        float bottomY = -Config.HALF_HEIGHT - CellManager.GetGridRowHeight();

        deleteCancelBox.y = bottomY + (deleteCancelBox.anchorCell.y - bottomY) * RXEase.ExpoOut(deleteCancelPercent);
        deleteOkBox.y     = bottomY + (deleteOkBox.anchorCell.y - bottomY) * RXEase.ExpoOut(deleteOkPercent);
    }
    public void UpdateMesh()
    {
        float offsetX = -_anchorX * width;
        float offsetY = -_anchorY * height;

        float ewidth  = _element.sourceSize.x;
        float eheight = _element.sourceSize.y;

        float leftRemaining   = RXMath.Mod(_scrollX, ewidth);
        float bottomRemaining = RXMath.Mod(_scrollY, eheight);

        float leftX  = leftRemaining;
        float rightX = leftX + width;

        int leftCol  = 0;
        int rightCol = Mathf.FloorToInt(rightX / ewidth);

        if (rightX % ewidth == 0)
        {
            rightCol--;                              //if it fits exactly, we don't need the last column
        }
        float bottomY = bottomRemaining;
        float topY    = bottomY + height;

        int bottomRow = 0;
        int topRow    = Mathf.FloorToInt(topY / eheight);

        if (topY % eheight == 0)
        {
            topRow--;                             //if it fits exactly, we don't need the last row
        }
        int numCols = (rightCol - leftCol) + 1;
        int numRows = (topRow - bottomRow) + 1;

        _meshData.SetFacetCount(numCols * numRows);

        List <FMeshFacet> quads = _meshData.facets;

        float rightRemaining = ((rightCol + 1) * ewidth - rightX);
        float topRemaining   = ((topRow + 1) * eheight - topY);

        int q = 0;

        for (int r = 0; r < numRows; r++)
        {
            float quadBottom = offsetY + r * eheight - bottomRemaining;
            float quadTop    = quadBottom + eheight;
            float uvBottom   = 0;
            float uvTop      = 1.0f;

            if (r == 0)           //bottomRow
            {
                quadBottom += bottomRemaining;
                uvBottom   += bottomRemaining / eheight;
            }

            if (r == numRows - 1)         //topRow
            {
                quadTop -= topRemaining;
                uvTop   -= topRemaining / eheight;
            }

            for (int c = 0; c < numCols; c++)
            {
                FMeshQuad quad = (FMeshQuad)quads[q];
                q++;

                float quadLeft  = offsetX + c * ewidth - leftRemaining;
                float quadRight = quadLeft + ewidth;
                float uvLeft    = 0;
                float uvRight   = 1.0f;

                if (c == 0)               //leftCol
                {
                    quadLeft += leftRemaining;
                    uvLeft   += leftRemaining / ewidth;
                }

                if (c == numCols - 1)             //rightCol
                {
                    quadRight -= rightRemaining;
                    uvRight   -= rightRemaining / ewidth;
                }

                quad.SetPosExtents(quadLeft, quadRight, quadBottom, quadTop);
                quad.SetUVExtents(uvLeft, uvRight, uvBottom, uvTop);
            }
        }

        _meshData.MarkChanged();
    }