Пример #1
0
        IEnumerator StartMove(MG_MenuFlyTarget _flyTarget, Action <MG_MenuFlyTarget> callback)
        {
            float spreadTime = 0;
            float height     = 50;

            while (spreadTime <= 0.2f)
            {
                yield return(null);

                spreadTime += Time.unscaledDeltaTime;
                float progress = spreadTime * 5;
                for (int i = 0; i < flyNum; i++)
                {
                    list_allFly[i].position  = Vector3.Lerp(StartPos, list_allEndPos[i], progress);
                    list_allFly[i].position += new Vector3(0, -(spreadTime - 0.1f) * (spreadTime - 0.1f) * height * 100 + height, 0);
                }
            }
            yield return(null);

            for (int i = 0; i < flyNum; i++)
            {
                list_allFly[i].position = list_allEndPos[i];
            }
            yield return(null);

            while (spreadTime <= 0.3f)
            {
                yield return(null);

                spreadTime += Time.unscaledDeltaTime;
                for (int i = 0; i < flyNum; i++)
                {
                    list_allFly[i].position = list_allEndPos[i] + new Vector3(0, -(spreadTime - 0.25f) * (spreadTime - 0.25f) * 8000 + 20, 0);
                }
            }
            yield return(new WaitForSeconds(0.5f * Time.timeScale));

            float flyTime    = 0;
            float delay      = 0.3f;
            int   startIndex = 0;

            while (startIndex <= flyNum - 1)
            {
                yield return(null);

                flyTime += Time.unscaledDeltaTime * 5;
                float progress;
                for (int i = startIndex; i < flyNum; i++)
                {
                    if (flyTime - i * delay >= 1)
                    {
                        callback(_flyTarget);
                        startIndex = i + 1;
                        list_allFlyImage[i].color = Color.clear;
                        progress = 1;
                        MG_Manager.Play_FlyOver();
                    }
                    else
                    {
                        progress = flyTime;
                    }
                    float thisProgress = progress - i * delay;
                    list_allFly[i].position = Vector3.Lerp(list_allEndPos[i], TargetPos, thisProgress);
                }
            }
            canvasGroup.alpha          = 0;
            canvasGroup.blocksRaycasts = false;
        }