如何在 Unity 中处理服务器响应之前保持 Leantween 动画处于活动状态

How to keep Leantween animation alive until server response is handled in Unity

提问人:diyapesen 提问时间:5/28/2023 更新时间:5/28/2023 访问量:13

问:

我正在Unity中开发一款老虎机游戏。对于每次旋转,我都会向服务器发送一个旋转请求,并从服务器获取结果并设置符号在屏幕上的最终位置。我想让车轮滚动,直到服务器响应得到处理。

目前,它在给定的时间段内滚动并滚动指定的回合数。有什么方法可以做到这一点吗?

 LTDescr action = LeanTween.value(gameObject, 0f, 1f, duration).setOnUpdate((float dt) =>
    {
        float curr = h * dt;
        int currTile = (int)(curr / _tileSize.y);

        float delta = curr - prev;
        for (int i = 0; i < count; i++)
        {
            CSSymbol s = _symbols[i];
            Vector3 v = s.transform.localPosition;
            v.y -= delta;

            if (v.y - min.y <= 0.01f)  // Symbols that get down of screen should be moved back to starting point
            {
                v.y = max.y + (v.y - min.y);
                CSSymbolType type = CSSymbolType.SymbolNone;
                if (i < count - 1 && currTile > lastRoll)
                {
                    // Last roll
                    type = _reelRandom.SmartRandomSymbol(); // set resulting symbol list
                }
                else
                {
                    type = _reelRandom.RandomSymbol(); // get random symbol type
                }
                s.SetType(type);
            }

            s.transform.localPosition = v; // set new symbol
        }
        prev = curr;
    }).setEaseInOutSine().setDelay((float)_column * delay);
unity-game-engine keep-alive leantween

评论


答: 暂无答案