reset() 공개 정적인 메소드

public static reset ( ) : void
리턴 void
예제 #1
0
    void ResetAfterPreview()
    {
        LeanTween.reset();
        var tgt = (UIAnimSequence)target;

        tgt.ResetToPreActionState();
    }
예제 #2
0
    public void DoThingsExitStage()
    {
        LeanTween.reset();

        float currentCameraZoom = stageCamera.zoomedInOnVeranda;

        GameObject.FindObjectOfType <PlayerUIHandler>().SetPlayerUIVisible(false);

        LeanTween.value(gameObject, currentCameraZoom, 0f, currentCameraZoom)
        .setEase(LeanTweenType.easeOutBack)
        .setOnUpdate((Action <float>)(f =>
        {
            stageCamera.setZoomedInOnVeranda(f);
        })).setOnComplete(() =>
        {
            LeanTween.moveLocalY(curtainTransform.gameObject, -1.6f, 1f)
            .setEase(LeanTweenType.easeInBack)
            .setOnComplete(() =>
            {
                LeanTween.moveLocalX(LogoGameObject, initialLogoLocalPosition.x, 3f)
                .setEase(LeanTweenType.easeInBack)
                .setOnComplete(() =>
                {
                });
            });
        });
    }
예제 #3
0
    private IEnumerator ELoadScene(SceneName scene)
    {
        isLoading = true;
        // Reset all tweens to avoid updates on destroyed objects
        LeanTween.reset();

        // Load scene asynchronously
        loadingOperation = SceneManager.LoadSceneAsync((int)scene);
        loadingText.text = "Loading...";
        loadingIcon.StartLoading();
        float loadProgress = 0;
        float elapsedTime  = 0;
        bool  first        = true;

        if (levelScene.Contains(scene))
        {
            loadingOperation.allowSceneActivation = false;
        }

        SoundController.Instance.DimMusic(true, minLoadingTime, 10);

        while (!loadingOperation.isDone)
        {
            loadProgress          = Mathf.Min(elapsedTime / minLoadingTime, loadingOperation.progress);
            loadingBar.fillAmount = loadProgress + 0.1f;
            if (loadProgress >= 0.9f && !loadingOperation.allowSceneActivation)
            {
                if (first)
                {
                    first = false;
                    SoundController.Instance.PlaySound(SoundName.UIButton1);
                    loadingIcon.StopLoading();
                    loadingText.text = "Press Enter to start";
                    LeanTween.scale(loadingText.rectTransform, 1.05f * Vector3.one, 0.5f).setLoopPingPong().setEaseOutCubic();
                }

                if (Input.GetKeyDown(KeyCode.Return))
                {
                    loadingOperation.allowSceneActivation = true;
                }
            }
            elapsedTime += Time.deltaTime;
            yield return(null);
        }

        LeanTween.cancel(loadingText.rectTransform);
        LeanTween.scale(loadingText.rectTransform, Vector3.one, 0);

        if (levelScene.Contains(scene))
        {
            if (storedItems.Count > 0)
            {
                GameManager.instance.GetPlayer().items.SetItem(storedItems[0], 0);
                GameManager.instance.GetPlayer().items.SetItem(storedItems[1], 1);
            }
        }
        loadingIcon.StopLoading();
        StartCoroutine(EShowLoadingScreen(false));
        isLoading = false;
    }
예제 #4
0
 /// <summary>
 /// Reset leantween when exiting the play mode
 /// This way Leantween does not require to reload the domain or scene when entering the playmode (available since 2019.3)
 /// </summary>
 /// <param name="state"></param>
 private static void OnPlayModeStateChanged(PlayModeStateChange state)
 {
     if (state == PlayModeStateChange.EnteredEditMode)
     {
         LeanTween.reset();
     }
 }
예제 #5
0
    void OnCompleteTheWholeThing()
    {
        Animating = false;

        if (!Application.isPlaying)
        {
            LeanTween.reset();
        }
    }
예제 #6
0
 private void HideEnabledSGAnim()
 {
     LeanTween.reset();
     foreach (ScreenGroup sg in allScreenGroups)
     {
         if (sg.gameObject.activeSelf)
         {
             sg.GetComponent <ScreenGroup>().AnimateMyChildrenOut();
         }
     }
 }
예제 #7
0
 private void resetSize()
 {
     LeanTween.reset();
     Destroy(blackHoleanimation);
     transform.localRotation             = startRotation;
     transform.localScale                = startSize;
     slimeportal.transform.localRotation = slimeStartRotation;
     slimeportal.transform.localScale    = slimeStartSize;
     skinnedMeshRenderer.enabled         = true;
     mustIncrement = false;
     rubyGateMaterial.SetFloat("CrystalIntensity", startIntensity);
     rubyGateMaterial.SetFloat("CrystalHue", startHue);
 }
예제 #8
0
    void Start()
    {
        LeanTest.timeout  = 7f;
        LeanTest.expected = 24;

        LeanTween.init(3 + 1200);
        // add a listener
        LeanTween.addListener(cube1, 0, eventGameObjectCalled);

        LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

        LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

        // dispatch event that is received
        LeanTween.dispatchEvent(0);
        LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

        // do not remove listener
        LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
        // remove listener
        LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

        // add a listener
        LeanTween.addListener(1, eventGeneralCalled);

        // dispatch event that is received
        LeanTween.dispatchEvent(1);
        LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

        // remove listener
        LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

        lt1 = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f);
        LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

        LeanTween.reset();

        // ping pong

        // rotateAround, Repeat, DestroyOnComplete
        rotateRepeat = rotateRepeatAngle = 0;
        LeanTween.rotateAround(cube3, Vector3.forward, 360f, 0.1f).setRepeat(3).setOnComplete(rotateRepeatFinished).setOnCompleteOnRepeat(true).setDestroyOnComplete(true);
        LeanTween.delayedCall(0.1f * 8f, rotateRepeatAllFinished);

        // test all onUpdates and onCompletes are removed when tween is initialized

        StartCoroutine(timeBasedTesting());
    }
예제 #9
0
    private IEnumerator LoadSceneWithProgressBar(string sceneName)
    {
        // Reset all tweens to avoid updates on destroyed objects
        LeanTween.reset();

        // Load scene asynchronously
        loadingOperation = SceneManager.LoadSceneAsync(sceneName);
        while (!loadingOperation.isDone)
        {
            loadingBar.manualValue = loadingOperation.progress;
            yield return(null);
        }

        GameManager.instance.GetPlayer().items.SetItem(storedItems[0], 0);
        GameManager.instance.GetPlayer().items.SetItem(storedItems[1], 1);

        Destroy(gameObject);
    }
예제 #10
0
    public void RestartSetting()
    {
        _instance = this;
        startPos  = candle.position;
        if (!firstTIme)
        {
            LeanTween.moveY(candle.gameObject, candle.position.y + lowestPoint, 1f);
        }
        firstTIme = false;
        LeanTween.reset();
        anim.enabled       = true;
        sr.enabled         = true;
        lightTorch.enabled = true;
        StopAllCoroutines();

        // StartCoroutine(DeathPanel(false));
        StartCoroutine(Melting());
    }
예제 #11
0
    private void Start()
    {
        LeanTween.reset();

        RevivedGameSession = false;

        StartMenuSession();

        if (DebugManager.Instance != null && DebugManager.Instance.enabled && DebugManager.Instance.EnterGameInstantOnPlay)
        {
            StartGameSession(false);
        }

#if UNITY_EDITOR
        Debug.unityLogger.logEnabled = true;
#else
        Debug.unityLogger.logEnabled = false;
#endif
    }
예제 #12
0
 void StopRun()
 {
     this.StopAllCoroutines();
     state = State.Menu;
     // Clear tweens
     if (engine == Engine.DOTween)
     {
         DOTween.Clear();
     }
     else if (engine == Engine.HOTween)
     {
         HOTween.Kill();
     }
     else if (engine == Engine.LeanTween)
     {
         LeanTween.reset();
     }
     else if (engine == Engine.GoKit)
     {
         KillAllGoTweens();
     }
     else if (engine == Engine.iTween)
     {
         iTween.Stop();
     }
     // Clean
     if (testObjsGos != null)
     {
         foreach (GameObject go in testObjsGos)
         {
             Destroy(go);
         }
     }
     testObjsGos   = null;
     testObjsTrans = null;
     testObjsData  = null;
     rndPositions  = null;
     rndRotations  = null;
 }
예제 #13
0
 void Reset(bool complete = true)
 {
     if (complete)
     {
         if (engine == Engine.DOTween)
         {
             DOTween.Clear();
         }
         else if (engine == Engine.HOTween)
         {
             HOTween.Kill();
         }
         else if (engine == Engine.LeanTween)
         {
             LeanTween.reset();
         }
         else if (engine == Engine.GoKit)
         {
             KillAllGoTweens();
         }
         else if (engine == Engine.iTween)
         {
             iTween.Stop();
         }
     }
     if (testObjsTrans != null)
     {
         for (int i = 0; i < testObjsTrans.Length; ++i)
         {
             Transform t = testObjsTrans[i];
             t.position   = rndStartupPos[i];
             t.localScale = Vector3.one;
             t.rotation   = Quaternion.identity;
         }
     }
 }
    public void Awake()
    {
        LeanTween.reset();
        LeanTween.init(800);
        startfading.FadeOut();
        Destroy(startfading.gameObject, 0.6f);
        GameObject levelLoader = Instantiate(LevelLoader);

        _levelLoader = levelLoader.GetComponent <LevelLoader>();
        if (levelsContainer && horizontalContainer && levelBubble)
        {
            string          loadedJsonFile = Resources.Load <TextAsset>("levels").text;
            LevelsContainer levelsInJson   = JsonUtility.FromJson <LevelsContainer>(loadedJsonFile);

            //We instanciate the matrix that will contain all the buttons
            uibuttons = new UIButton[(Mathf.Min(levelsInJson.levels.Length, ActualSave.actualSave.NextLevel() + 1) / 4) + 1][];
            for (int i = 0; i < uibuttons.Length; i++)
            {
                uibuttons[i] = new UIButton[4];
            }

            //FIRST LOOP
            GameObject actualContainer = Instantiate(horizontalContainer, levelsContainer.transform);
            firstBubble = Instantiate(levelBubble, actualContainer.transform);
            firstBubble.GetComponent <levelBubbleHandlerScript>().setData(levelsInJson.levels[0], 1);
            int modifier = ((Mathf.Min(ActualSave.actualSave.NextLevel() + 1, levelsInJson.levels.Length) % 4 > 0) ? 1 : 0);

            //Debug.Log("Resultat du calcul : " + Mathf.Min(ActualSave.actualSave.NextLevel() + 1, levelsInJson.levels.Length) % 4);
            levelsContainer.GetComponent <RectTransform>().sizeDelta = new Vector2(700f, ((Mathf.Min(ActualSave.actualSave.NextLevel() + 1, levelsInJson.levels.Length) / 4f + modifier) * 133f + 20f));
            levelsContainer.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ((Mathf.Min(ActualSave.actualSave.NextLevel() + 1, levelsInJson.levels.Length) / 4f + modifier) * 133f + 20f));

            //We enter the first element in the matrix
            uibuttons[0][0] = firstBubble.GetComponent <levelBubbleHandlerScript>().getButton();



            //THEN ITERATION



            //This will be the row number
            int j = 0;
            for (int i = 1; i < Mathf.Min(levelsInJson.levels.Length, ActualSave.actualSave.NextLevel() + 1); i++)
            {
                if (i % 4 == 0)
                {
                    j++;
                    actualContainer = Instantiate(horizontalContainer, levelsContainer.transform);
                }

                if (i == levelsInJson.levels.Length - 1)
                {
                    //The only thing that changes is that we store it in a global variable
                    lastBubble = Instantiate(levelBubble, actualContainer.transform);
                    lastBubble.GetComponent <levelBubbleHandlerScript>().setData(levelsInJson.levels[i], i + 1);
                    uibuttons[j][i % 4] = lastBubble.GetComponent <levelBubbleHandlerScript>().getButton();
                }
                else
                {
                    GameObject created = Instantiate(levelBubble, actualContainer.transform);
                    created.GetComponent <levelBubbleHandlerScript>().setData(levelsInJson.levels[i], i + 1);
                    uibuttons[j][i % 4] = created.GetComponent <levelBubbleHandlerScript>().getButton();
                }
            }

            //We will now define the navigation of all buttons

            for (j = 0; j < uibuttons.Length; j++)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (uibuttons[j][i])
                    {
                        //Horizontal movement
                        if (i == 0) //Left
                        {
                            if (uibuttons[j][i + 1])
                            {
                                uibuttons[j][i].rightButton = uibuttons[j][i + 1];
                            }
                        }
                        else if (i == 3) //Right
                        {
                            if (uibuttons[j][i - 1])
                            {
                                uibuttons[j][i].leftButton = uibuttons[j][i - 1];
                            }
                            if (ActualSave.actualSave.NextLevel() >= 12)
                            {
                                uibuttons[j][i].rightButton = bar;
                            }
                            else
                            {
                                uibuttons[j][i].rightButton = bar.rightButton;
                            }
                        }
                        else //Center
                        {
                            if (uibuttons[j][i - 1])
                            {
                                uibuttons[j][i].leftButton = uibuttons[j][i - 1];
                            }
                            if (uibuttons[j][i + 1])
                            {
                                uibuttons[j][i].rightButton = uibuttons[j][i + 1];
                            }
                        }

                        //We handle the case of the last button
                        if (j * 4 + i == ActualSave.actualSave.NextLevel() || j * 4 + i == ActualSave.actualSave.NextLevel() - 1)
                        {
                            if (ActualSave.actualSave.NextLevel() >= 12)
                            {
                                uibuttons[j][i].rightButton = bar;
                            }
                            else
                            {
                                uibuttons[j][i].rightButton = bar.rightButton;
                            }
                        }

                        //Vertical movement
                        if (j == 0) //Top
                        {
                            if (j + 1 <= uibuttons.Length - 1)
                            {
                                uibuttons[j][i].downButton = uibuttons[j + 1][i];
                            }
                        }
                        else if (j == uibuttons.Length - 1)//Bottom
                        {
                            if (j - 1 >= 0)
                            {
                                uibuttons[j][i].upButton = uibuttons[j - 1][i];
                            }
                        }
                        else //Center
                        {
                            if (j + 1 <= uibuttons.Length - 1)
                            {
                                uibuttons[j][i].downButton = uibuttons[j + 1][i];
                            }
                            if (j - 1 >= 0)
                            {
                                uibuttons[j][i].upButton = uibuttons[j - 1][i];
                            }
                        }
                    }
                }
            }

            stateMachine.firstSelected = firstBubble.GetComponent <levelBubbleHandlerScript>().getButton();
            stateMachine.firstSelected.changeState(UIButton.SELECTED);
            //events.firstSelectedGameObject = firstBubble.GetComponent<levelBubbleHandlerScript>().getButton();
            size = ActualSave.actualSave.NextLevel() / 4 - 1; /// A REVOIR -----------------------------------------

            initialAnchor = levelsContainer.GetComponent <RectTransform>().anchoredPosition.y;
            if (ActualSave.actualSave.NextLevel() < 12)
            {
                bar.rightButton.leftButton = uibuttons[0][(uibuttons[0][3]) ? 3 : (uibuttons[0][2]) ? 2 : (uibuttons[0][1]) ? 1 : 0];
                bar.isActive = false;
                Destroy(bar.gameObject);
                scrollRect.anchoredPosition = new Vector2(scrollRect.anchoredPosition.x, -scrollRect.sizeDelta.y / 2);
                backButton.leftButton       = (uibuttons[0][3]) ? uibuttons[0][2]: (uibuttons[0][2]) ? uibuttons[0][1] : uibuttons[0][0];
            }
            else
            {
                bar.nbSteps = size + 1;
                bar.size    = (1f / size) * 4f;
                bar.value   = 0;
                bar.Refresh();
            }
        }
    }
예제 #15
0
파일: Popup.cs 프로젝트: tim64/Galaxy
 /// <summary>
 /// Перезапустить игру
 /// </summary>
 public void RestartGame()
 {
     LeanTween.reset();
     SceneManager.LoadScene(SCENE_GAME, LoadSceneMode.Single);
 }
예제 #16
0
 public static void Conclude()
 {
     LeanTween.reset();
     UnityEngine.Object.Destroy(GameObject.Find("~LeanTween"));
 }
예제 #17
0
    void Start()
    {
        LeanTest.timeout  = 46f;
        LeanTest.expected = 35;

        LeanTween.init(14 + 1200);
        // add a listener
        LeanTween.addListener(cube1, 0, eventGameObjectCalled);

        LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

        LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

        LeanTween.scaleX(cube4, 2f, 0f).setOnComplete(() => {
            LeanTest.expect(cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME");
        });

        // dispatch event that is received
        LeanTween.dispatchEvent(0);
        LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

        // do not remove listener
        LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
        // remove listener
        LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

        // add a listener
        LeanTween.addListener(1, eventGeneralCalled);

        // dispatch event that is received
        LeanTween.dispatchEvent(1);
        LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

        // remove listener
        LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

        lt1Id = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f).id;
        LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

        LeanTween.reset();


        LTSpline cr = new LTSpline(new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector3(30f, 0f, 0f) });

        cr.place(cube4.transform, 0.5f);
        LeanTest.expect((Vector3.Distance(cube4.transform.position, new Vector3(10f, 0f, 0f)) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:" + cube4.transform.position + " but should be:(10f,0f,0f)");
        LeanTween.color(cube4, Color.green, 0.01f);

        // OnStart Speed Test for ignoreTimeScale vs normal timeScale
        GameObject cube = Instantiate(boxNoCollider) as GameObject;

        cube.name = "normalTimeScale";
        // float timeElapsedNormal = Time.time;
        LeanTween.moveX(cube, 12f, 1f).setIgnoreTimeScale(false).setOnComplete(() => {
            timeElapsedNormalTimeScale = Time.time;
        });

        LTDescr[] descr = LeanTween.descriptions(cube);
        LeanTest.expect(descr.Length >= 0 && descr[0].to.x == 12f, "WE CAN RETRIEVE A DESCRIPTION");

        cube      = Instantiate(boxNoCollider) as GameObject;
        cube.name = "ignoreTimeScale";
        LeanTween.moveX(cube, 5f, 1f).setIgnoreTimeScale(true).setOnComplete(() => {
            timeElapsedIgnoreTimeScale = Time.time;
        });

        GameObject cubeDest = Instantiate(boxNoCollider) as GameObject;

        cubeDest.name = "cubeDest";
        Vector3 cubeDestEnd = new Vector3(100f, 20f, 0f);

        LeanTween.move(cubeDest, cubeDestEnd, 0.7f);
        GameObject cubeToTrans = Instantiate(boxNoCollider) as GameObject;

        cubeToTrans.name = "cubeToTrans";

        LeanTween.move(cubeToTrans, cubeDest.transform, 1.2f).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => {
            LeanTest.expect(cubeToTrans.transform.position == cubeDestEnd, "MOVE TO TRANSFORM WORKS");
        });

        GameObject cubeDestroy = Instantiate(boxNoCollider) as GameObject;

        cubeDestroy.name = "cubeDestroy";
        LeanTween.moveX(cubeDestroy, 200f, 0.05f).setDelay(0.02f).setDestroyOnComplete(true);
        LeanTween.moveX(cubeDestroy, 200f, 0.1f).setDestroyOnComplete(true).setOnComplete(() => {
            LeanTest.expect(true, "TWO DESTROY ON COMPLETE'S SUCCEED");
        });

        GameObject cubeSpline = Instantiate(boxNoCollider) as GameObject;

        cubeSpline.name = "cubeSpline";
        LeanTween.moveSpline(cubeSpline, new Vector3[] { new Vector3(0.5f, 0f, 0.5f), new Vector3(0.75f, 0f, 0.75f), new Vector3(1f, 0f, 1f), new Vector3(1f, 0f, 1f) }, 0.1f).setOnComplete(() => {
            LeanTest.expect(Vector3.Distance(new Vector3(1f, 0f, 1f), cubeSpline.transform.position) < 0.01f, "SPLINE WITH TWO POINTS SUCCEEDS");
        });

        // This test works when it is positioned last in the test queue (probably worth fixing when you have time)
        GameObject jumpCube = Instantiate(boxNoCollider) as GameObject;

        jumpCube.name = "jumpTime";
        int jumpTimeId = LeanTween.moveX(jumpCube, 1f, 1f).id;

        LeanTween.delayedCall(jumpCube, 0.2f, () => {
            LTDescr d     = LeanTween.descr(jumpTimeId);
            float beforeX = jumpCube.transform.position.x;
            d.setTime(0.5f);
            LeanTween.delayedCall(0.01f, () => { }).setOnStart(() => {
                LeanTest.expect(Mathf.Abs(jumpCube.transform.position.x - beforeX) < 0.01f, "CHANGING TIME DOESN'T JUMP AHEAD", "Difference:" + Mathf.Abs(jumpCube.transform.position.x - beforeX));
            });
        });


        StartCoroutine(timeBasedTesting());
    }
예제 #18
0
    void Start()
    {
        LeanTest.timeout  = 45f;
        LeanTest.expected = 31;

        LeanTween.init(10 + 1200);
        // add a listener
        LeanTween.addListener(cube1, 0, eventGameObjectCalled);

        LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

        LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

        LeanTween.scaleX(cube4, 2f, 0f).setOnComplete(() => {
            LeanTest.expect(cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME");
        });

        // dispatch event that is received
        LeanTween.dispatchEvent(0);
        LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

        // do not remove listener
        LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
        // remove listener
        LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

        // add a listener
        LeanTween.addListener(1, eventGeneralCalled);

        // dispatch event that is received
        LeanTween.dispatchEvent(1);
        LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

        // remove listener
        LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

        lt1Id = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f).id;
        LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

        LeanTween.reset();


        LTSpline cr = new LTSpline(new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector3(30f, 0f, 0f) });

        cr.place(cube4.transform, 0.5f);
        LeanTest.expect((Vector3.Distance(cube4.transform.position, new Vector3(10f, 0f, 0f)) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:" + cube4.transform.position + " but should be:(10f,0f,0f)");
        LeanTween.color(cube4, Color.green, 0.01f);

        // OnStart Speed Test for ignoreTimeScale vs normal timeScale
        GameObject cube = Instantiate(boxNoCollider) as GameObject;

        cube.name = "normalTimeScale";
        // float timeElapsedNormal = Time.time;
        LeanTween.moveX(cube, 12f, 1f).setIgnoreTimeScale(false).setOnComplete(() => {
            timeElapsedNormalTimeScale = Time.time;
        });

        LTDescr[] descr = LeanTween.descriptions(cube);
        LeanTest.expect(descr.Length >= 0 && descr[0].to.x == 12f, "WE CAN RETRIEVE A DESCRIPTION");

        cube      = Instantiate(boxNoCollider) as GameObject;
        cube.name = "ignoreTimeScale";
        LeanTween.moveX(cube, 5f, 1f).setIgnoreTimeScale(true).setOnComplete(() => {
            timeElapsedIgnoreTimeScale = Time.time;
        });

        StartCoroutine(timeBasedTesting());
    }
예제 #19
0
        void Start()
        {
//			Time.timeScale = 0.25f;

            LeanTest.timeout  = 46f;
            LeanTest.expected = 50;

            LeanTween.init(15 + 1200);
            // add a listener
            LeanTween.addListener(cube1, 0, eventGameObjectCalled);

            LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

            LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

            LeanTween.scaleX(cube4, 2f, 0f).setOnComplete(() => {
                LeanTest.expect(cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME");
            });

            // dispatch event that is received
            LeanTween.dispatchEvent(0);
            LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

            // do not remove listener
            LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
            // remove listener
            LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

            // add a listener
            LeanTween.addListener(1, eventGeneralCalled);

            // dispatch event that is received
            LeanTween.dispatchEvent(1);
            LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

            // remove listener
            LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

            lt1Id = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f).id;
            LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

            LeanTween.reset();

            Vector3[] splineArr = new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector3(30f, 0f, 0f) };
            LTSpline  cr        = new LTSpline(splineArr);

            cr.place(cube4.transform, 0.5f);
            LeanTest.expect((Vector3.Distance(cube4.transform.position, new Vector3(10f, 0f, 0f)) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:" + cube4.transform.position + " but should be:(10f,0f,0f)");
            LeanTween.color(cube4, Color.green, 0.01f);

//			Debug.Log("Point 2:"+cr.ratioAtPoint(splineArr[2]));

            // OnStart Speed Test for ignoreTimeScale vs normal timeScale

            GameObject cubeDest    = cubeNamed("cubeDest");
            Vector3    cubeDestEnd = new Vector3(100f, 20f, 0f);

            LeanTween.move(cubeDest, cubeDestEnd, 0.7f);

            GameObject cubeToTrans = cubeNamed("cubeToTrans");

            LeanTween.move(cubeToTrans, cubeDest.transform, 1.2f).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => {
                LeanTest.expect(cubeToTrans.transform.position == cubeDestEnd, "MOVE TO TRANSFORM WORKS");
            });

            GameObject cubeDestroy = cubeNamed("cubeDestroy");

            LeanTween.moveX(cubeDestroy, 200f, 0.05f).setDelay(0.02f).setDestroyOnComplete(true);
            LeanTween.moveX(cubeDestroy, 200f, 0.1f).setDestroyOnComplete(true).setOnComplete(() => {
                LeanTest.expect(true, "TWO DESTROY ON COMPLETE'S SUCCEED");
            });

            GameObject cubeSpline = cubeNamed("cubeSpline");

            LeanTween.moveSpline(cubeSpline, new Vector3[] { new Vector3(0.5f, 0f, 0.5f), new Vector3(0.75f, 0f, 0.75f), new Vector3(1f, 0f, 1f), new Vector3(1f, 0f, 1f) }, 0.1f).setOnComplete(() => {
                LeanTest.expect(Vector3.Distance(new Vector3(1f, 0f, 1f), cubeSpline.transform.position) < 0.01f, "SPLINE WITH TWO POINTS SUCCEEDS");
            });

            // This test works when it is positioned last in the test queue (probably worth fixing when you have time)
            GameObject jumpCube = cubeNamed("jumpTime");

            jumpCube.transform.position    = new Vector3(100f, 0f, 0f);
            jumpCube.transform.localScale *= 100f;
            int jumpTimeId = LeanTween.moveX(jumpCube, 200f, 1f).id;

            LeanTween.delayedCall(gameObject, 0.2f, () => {
                LTDescr d     = LeanTween.descr(jumpTimeId);
                float beforeX = jumpCube.transform.position.x;
                d.setTime(0.5f);
                LeanTween.delayedCall(0.0f, () => { }).setOnStart(() => {
                    float diffAmt = 1f;                    // This variable is dependent on a good frame-rate because it evalutes at the next Update
                    beforeX      += Time.deltaTime * 100f * 2f;
                    LeanTest.expect(Mathf.Abs(jumpCube.transform.position.x - beforeX) < diffAmt, "CHANGING TIME DOESN'T JUMP AHEAD", "Difference:" + Mathf.Abs(jumpCube.transform.position.x - beforeX) + " beforeX:" + beforeX + " now:" + jumpCube.transform.position.x + " dt:" + Time.deltaTime);
                });
            });

            // Tween with time of zero is needs to be set to it's final value
            GameObject zeroCube = cubeNamed("zeroCube");

            LeanTween.moveX(zeroCube, 10f, 0f).setOnComplete(() => {
                LeanTest.expect(zeroCube.transform.position.x == 10f, "ZERO TIME FINSHES CORRECTLY", "final x:" + zeroCube.transform.position.x);
            });

            // Scale, and OnStart
            GameObject cubeScale = cubeNamed("cubeScale");

            LeanTween.scale(cubeScale, new Vector3(5f, 5f, 5f), 0.01f).setOnStart(() => {
                LeanTest.expect(true, "ON START WAS CALLED");
            }).setOnComplete(() => {
                LeanTest.expect(cubeScale.transform.localScale.z == 5f, "SCALE", "expected scale z:" + 5f + " returned:" + cubeScale.transform.localScale.z);
            });

            // Rotate
            GameObject cubeRotate = cubeNamed("cubeRotate");

            LeanTween.rotate(cubeRotate, new Vector3(0f, 180f, 0f), 0.02f).setOnComplete(() => {
                LeanTest.expect(cubeRotate.transform.eulerAngles.y == 180f, "ROTATE", "expected rotate y:" + 180f + " returned:" + cubeRotate.transform.eulerAngles.y);
            });

            // RotateAround
            GameObject cubeRotateA = cubeNamed("cubeRotateA");

            LeanTween.rotateAround(cubeRotateA, Vector3.forward, 90f, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeRotateA.transform.eulerAngles.z == 90f, "ROTATE AROUND", "expected rotate z:" + 90f + " returned:" + cubeRotateA.transform.eulerAngles.z);
            });
            // Alpha, onUpdate with passing value, onComplete value
            LeanTween.alpha(cubeAlpha1, 0.5f, 0.1f).setOnUpdate((float val) => {
                LeanTest.expect(val != 0f, "ON UPDATE VAL");
            }).setOnCompleteParam("Hi!").setOnComplete((object completeObj) => {
                LeanTest.expect(((string)completeObj) == "Hi!", "ONCOMPLETE OBJECT");
                LeanTest.expect(cubeAlpha1.GetComponent <Renderer>().material.color.a == 0.5f, "ALPHA");
            });
            // Color
            float onStartTime = -1f;

            LeanTween.color(cubeAlpha2, Color.cyan, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.GetComponent <Renderer>().material.color == Color.cyan, "COLOR");
                LeanTest.expect(onStartTime >= 0f && onStartTime < Time.time, "ON START", "onStartTime:" + onStartTime + " time:" + Time.time);
            }).setOnStart(() => {
                onStartTime = Time.time;
            });
            // moveLocalY (make sure uses y values)
            Vector3 beforePos = cubeAlpha1.transform.position;

            LeanTween.moveY(cubeAlpha1, 3f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha1.transform.position.x == beforePos.x && cubeAlpha1.transform.position.z == beforePos.z, "MOVE Y");
            });

            Vector3 beforePos2 = cubeAlpha2.transform.localPosition;

            LeanTween.moveLocalZ(cubeAlpha2, 12f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.transform.localPosition.x == beforePos2.x && cubeAlpha2.transform.localPosition.y == beforePos2.y, "MOVE LOCAL Z", "ax:" + cubeAlpha2.transform.localPosition.x + " bx:" + beforePos.x + " ay:" + cubeAlpha2.transform.localPosition.y + " by:" + beforePos2.y);
            });

            AudioClip audioClip = LeanAudio.createAudio(new AnimationCurve(new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f)), new AnimationCurve(new Keyframe(0f, 0.001f, 0f, 0f), new Keyframe(1f, 0.001f, 0f, 0f)), LeanAudio.options());

            LeanTween.delayedSound(gameObject, audioClip, new Vector3(0f, 0f, 0f), 0.1f).setDelay(0.2f).setOnComplete(() => {
                LeanTest.expect(Time.time > 0, "DELAYED SOUND");
            });

            StartCoroutine(timeBasedTesting());
        }
예제 #20
0
파일: Popup.cs 프로젝트: tim64/Galaxy
 /// <summary>
 /// Выйти в меню
 /// </summary>
 public void GoToMenu()
 {
     LeanTween.reset();
     SceneManager.LoadScene(SCENE_MENU, LoadSceneMode.Single);
 }
예제 #21
0
파일: Popup.cs 프로젝트: tim64/Galaxy
 /// <summary>
 /// Перейти на след. уровень
 /// </summary>
 public void GoToNextLevel()
 {
     LeanTween.reset();
     SceneManager.LoadScene(SCENE_GAME, LoadSceneMode.Single);
     LevelController.GoToNextLevel();
 }
 public void ToggleAnimationIn()
 {
     LeanTween.reset();
     moveInId = LeanTween.moveLocal(gameObject, toPosition, 0.25f).setEase(LeanTweenType.easeInQuad).id;
 }
예제 #23
0
 public void Destroy()
 {
     LeanTween.reset();
     Destroy(gameObject);
 }
예제 #24
0
 public void Reset()
 {
     LeanTween.reset();
 }
 public void ToggleAnimationOut()
 {
     LeanTween.reset();
     moveOutId = LeanTween.moveLocal(gameObject, startPosition, 1f).setEase(LeanTweenType.easeInQuad).id;
 }
예제 #26
0
        void Start()
        {
//			Time.timeScale = 0.25f;

            LeanTest.timeout  = 46f;
            LeanTest.expected = 56;

            LeanTween.init(15 + 1200);

            // add a listener
            LeanTween.addListener(cube1, 0, eventGameObjectCalled);

            LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

            LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

            LeanTween.scaleX(cube4, 2f, 0f).setOnComplete(() => {
                LeanTest.expect(cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME");
            });

            // dispatch event that is received
            LeanTween.dispatchEvent(0);
            LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

            // do not remove listener
            LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
            // remove listener
            LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

            // add a listener
            LeanTween.addListener(1, eventGeneralCalled);

            // dispatch event that is received
            LeanTween.dispatchEvent(1);
            LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

            // remove listener
            LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

            lt1Id = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f).id;
            LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

            LeanTween.reset();

            // Queue up a bunch of tweens, cancel some of them but expect the remainder to finish
            GameObject[] cubes    = new GameObject[99];
            int[]        tweenIds = new int[cubes.Length];
            for (int i = 0; i < cubes.Length; i++)
            {
                GameObject c = cubeNamed("cancel" + i);
                tweenIds[i] = LeanTween.moveX(c, 100f, 1f).id;
                cubes [i]   = c;
            }
            int onCompleteCount = 0;

            LeanTween.delayedCall(cubes[0], 0.2f, () => {
                for (int i = 0; i < cubes.Length; i++)
                {
                    if (i % 3 == 0)
                    {
                        LeanTween.cancel(cubes [i]);
                    }
                    else if (i % 3 == 1)
                    {
                        LeanTween.cancel(tweenIds[i]);
                    }
                    else if (i % 3 == 2)
                    {
                        LTDescr descr = LeanTween.descr(tweenIds[i]);
//						Debug.Log("descr:"+descr);
                        descr.setOnComplete(() => {
                            onCompleteCount++;
//							Debug.Log("onCompleteCount:"+onCompleteCount);
                            if (onCompleteCount >= 33)
                            {
                                LeanTest.expect(true, "CANCELS DO NOT EFFECT FINISHING");
                            }
                        });
                    }
                }
            });

            Vector3[] splineArr = new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector3(30f, 0f, 0f) };
            LTSpline  cr        = new LTSpline(splineArr);

            cr.place(cube4.transform, 0.5f);
            LeanTest.expect((Vector3.Distance(cube4.transform.position, new Vector3(10f, 0f, 0f)) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:" + cube4.transform.position + " but should be:(10f,0f,0f)");
            LeanTween.color(cube4, Color.green, 0.01f);

//			Debug.Log("Point 2:"+cr.ratioAtPoint(splineArr[2]));

            // OnStart Speed Test for ignoreTimeScale vs normal timeScale

            GameObject cubeDest    = cubeNamed("cubeDest");
            Vector3    cubeDestEnd = new Vector3(100f, 20f, 0f);

            LeanTween.move(cubeDest, cubeDestEnd, 0.7f);

            GameObject cubeToTrans = cubeNamed("cubeToTrans");

            LeanTween.move(cubeToTrans, cubeDest.transform, 1.2f).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => {
                LeanTest.expect(cubeToTrans.transform.position == cubeDestEnd, "MOVE TO TRANSFORM WORKS");
            });

            GameObject cubeDestroy = cubeNamed("cubeDestroy");

            LeanTween.moveX(cubeDestroy, 200f, 0.05f).setDelay(0.02f).setDestroyOnComplete(true);
            LeanTween.moveX(cubeDestroy, 200f, 0.1f).setDestroyOnComplete(true).setOnComplete(() => {
                LeanTest.expect(true, "TWO DESTROY ON COMPLETE'S SUCCEED");
            });

            GameObject cubeSpline = cubeNamed("cubeSpline");

            LeanTween.moveSpline(cubeSpline, new Vector3[] { new Vector3(0.5f, 0f, 0.5f), new Vector3(0.75f, 0f, 0.75f), new Vector3(1f, 0f, 1f), new Vector3(1f, 0f, 1f) }, 0.1f).setOnComplete(() => {
                LeanTest.expect(Vector3.Distance(new Vector3(1f, 0f, 1f), cubeSpline.transform.position) < 0.01f, "SPLINE WITH TWO POINTS SUCCEEDS");
            });

            // This test works when it is positioned last in the test queue (probably worth fixing when you have time)
            GameObject jumpCube = cubeNamed("jumpTime");

            jumpCube.transform.position    = new Vector3(100f, 0f, 0f);
            jumpCube.transform.localScale *= 100f;
            int jumpTimeId = LeanTween.moveX(jumpCube, 200f, 1f).id;

            LeanTween.delayedCall(gameObject, 0.2f, () => {
                LTDescr d     = LeanTween.descr(jumpTimeId);
                float beforeX = jumpCube.transform.position.x;
                d.setTime(0.5f);
                LeanTween.delayedCall(0.0f, () => { }).setOnStart(() => {
                    float diffAmt = 1f;                    // This variable is dependent on a good frame-rate because it evalutes at the next Update
                    beforeX      += Time.deltaTime * 100f * 2f;
                    LeanTest.expect(Mathf.Abs(jumpCube.transform.position.x - beforeX) < diffAmt, "CHANGING TIME DOESN'T JUMP AHEAD", "Difference:" + Mathf.Abs(jumpCube.transform.position.x - beforeX) + " beforeX:" + beforeX + " now:" + jumpCube.transform.position.x + " dt:" + Time.deltaTime);
                });
            });

            // Tween with time of zero is needs to be set to it's final value
            GameObject zeroCube = cubeNamed("zeroCube");

            LeanTween.moveX(zeroCube, 10f, 0f).setOnComplete(() => {
                LeanTest.expect(zeroCube.transform.position.x == 10f, "ZERO TIME FINSHES CORRECTLY", "final x:" + zeroCube.transform.position.x);
            });

            // Scale, and OnStart
            GameObject cubeScale = cubeNamed("cubeScale");

            LeanTween.scale(cubeScale, new Vector3(5f, 5f, 5f), 0.01f).setOnStart(() => {
                LeanTest.expect(true, "ON START WAS CALLED");
            }).setOnComplete(() => {
                LeanTest.expect(cubeScale.transform.localScale.z == 5f, "SCALE", "expected scale z:" + 5f + " returned:" + cubeScale.transform.localScale.z);
            });

            // Rotate
            GameObject cubeRotate = cubeNamed("cubeRotate");

            LeanTween.rotate(cubeRotate, new Vector3(0f, 180f, 0f), 0.02f).setOnComplete(() => {
                LeanTest.expect(cubeRotate.transform.eulerAngles.y == 180f, "ROTATE", "expected rotate y:" + 180f + " returned:" + cubeRotate.transform.eulerAngles.y);
            });

            // RotateAround
            GameObject cubeRotateA = cubeNamed("cubeRotateA");

            LeanTween.rotateAround(cubeRotateA, Vector3.forward, 90f, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeRotateA.transform.eulerAngles.z == 90f, "ROTATE AROUND", "expected rotate z:" + 90f + " returned:" + cubeRotateA.transform.eulerAngles.z);
            });

            // RotateAround 360
            GameObject cubeRotateB = cubeNamed("cubeRotateB");

            cubeRotateB.transform.position = new Vector3(200f, 10f, 8f);
            LeanTween.rotateAround(cubeRotateB, Vector3.forward, 360f, 0.3f).setPoint(new Vector3(5f, 3f, 2f)).setOnComplete(() => {
                LeanTest.expect(cubeRotateB.transform.position.ToString() == (new Vector3(200f, 10f, 8f)).ToString(), "ROTATE AROUND 360", "expected rotate pos:" + (new Vector3(200f, 10f, 8f)) + " returned:" + cubeRotateB.transform.position);
            });

            // Alpha, onUpdate with passing value, onComplete value
            LeanTween.alpha(cubeAlpha1, 0.5f, 0.1f).setOnUpdate((float val) => {
                LeanTest.expect(val != 0f, "ON UPDATE VAL");
            }).setOnCompleteParam("Hi!").setOnComplete((object completeObj) => {
                LeanTest.expect(((string)completeObj) == "Hi!", "ONCOMPLETE OBJECT");
                LeanTest.expect(cubeAlpha1.GetComponent <Renderer>().material.color.a == 0.5f, "ALPHA");
            });
            // Color
            float onStartTime = -1f;

            LeanTween.color(cubeAlpha2, Color.cyan, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.GetComponent <Renderer>().material.color == Color.cyan, "COLOR");
                LeanTest.expect(onStartTime >= 0f && onStartTime < Time.time, "ON START", "onStartTime:" + onStartTime + " time:" + Time.time);
            }).setOnStart(() => {
                onStartTime = Time.time;
            });
            // moveLocalY (make sure uses y values)
            Vector3 beforePos = cubeAlpha1.transform.position;

            LeanTween.moveY(cubeAlpha1, 3f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha1.transform.position.x == beforePos.x && cubeAlpha1.transform.position.z == beforePos.z, "MOVE Y");
            });

            Vector3 beforePos2 = cubeAlpha2.transform.localPosition;

            LeanTween.moveLocalZ(cubeAlpha2, 12f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.transform.localPosition.x == beforePos2.x && cubeAlpha2.transform.localPosition.y == beforePos2.y, "MOVE LOCAL Z", "ax:" + cubeAlpha2.transform.localPosition.x + " bx:" + beforePos.x + " ay:" + cubeAlpha2.transform.localPosition.y + " by:" + beforePos2.y);
            });

            AudioClip audioClip = LeanAudio.createAudio(new AnimationCurve(new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f)), new AnimationCurve(new Keyframe(0f, 0.001f, 0f, 0f), new Keyframe(1f, 0.001f, 0f, 0f)), LeanAudio.options());

            LeanTween.delayedSound(gameObject, audioClip, new Vector3(0f, 0f, 0f), 0.1f).setDelay(0.2f).setOnComplete(() => {
                LeanTest.expect(Time.time > 0, "DELAYED SOUND");
            });

            // Easing Methods
            int totalEasingCheck        = 0;
            int totalEasingCheckSuccess = 0;

            for (int j = 0; j < 2; j++)
            {
                bool isCheckingFrom       = j == 1;
                int  totalTweenTypeLength = (int)LeanTweenType.easeShake;
                for (int i = (int)LeanTweenType.notUsed; i < totalTweenTypeLength; i++)
                {
                    LeanTweenType easeType = (LeanTweenType)i;
                    GameObject    cube     = cubeNamed("cube" + easeType);
                    LTDescr       descr    = LeanTween.moveLocalX(cube, 5, 0.1f).setOnComplete((object obj) => {
                        GameObject cubeIn = obj as GameObject;
                        totalEasingCheck++;
                        if (cubeIn.transform.position.x == 5f)
                        {
                            totalEasingCheckSuccess++;
                        }
                        if (totalEasingCheck == (2 * totalTweenTypeLength))
                        {
                            LeanTest.expect(totalEasingCheck == totalEasingCheckSuccess, "EASING TYPES");
                        }
                    }).setOnCompleteParam(cube);

                    if (isCheckingFrom)
                    {
                        descr.setFrom(-5f);
                    }
                }
            }

            // value2
            bool value2UpdateCalled = false;

            LeanTween.value(gameObject, new Vector2(0, 0), new Vector2(256, 96), 0.1f).setOnUpdate((Vector2 value) => {
                value2UpdateCalled = true;
            });
            LeanTween.delayedCall(0.2f, () => {
                LeanTest.expect(value2UpdateCalled, "VALUE2 UPDATE");
            });

            // check descr
//			LTDescr descr2 = LeanTween.descr( descrId );
//			LeanTest.expect(descr2 == null,"DESCRIPTION STARTS AS NULL");

            StartCoroutine(timeBasedTesting());
        }
예제 #27
0
    public void LoadNextLevel(int levelToLoad, bool mustPassIntro = false)
    {
        //If the current level is negative (level was chosen in level Loader), so we force the loading to reload the current level until the player quits it himself.
        //In level selection, we make sur that the players has enough lives
        //We also check if the leveltoLoad wanted is really a level and not the menu, to allow quitting
        if (currentLevel.value < 0 && levelToLoad >= 0)
        {
            if (!mustPassIntro)
            {
                livesLeft.value = 99; //That way we keep the current difficulty setting chosen by the player
            }


            levelToLoad = -currentLevel.value - 1;

            updateMusic(levelToLoad);

            string          loadedJsonFile = Resources.Load <TextAsset>("levels").text;
            LevelsContainer levelsInJson   = JsonUtility.FromJson <LevelsContainer>(loadedJsonFile);
            CrossLevelInfo.LevelName     = levelsInJson.levels[levelToLoad].name;
            CrossLevelInfo.mustPassIntro = mustPassIntro;
            CrossLevelInfo.time          = levelsInJson.levels[levelToLoad].time[0];//We set speed to minimum
            CrossLevelInfo.maxSlimes     = levelsInJson.levels[levelToLoad].bonusCount;

            StartCoroutine(loadAsynchronously(levelsInJson.levels[levelToLoad].sceneName));
        }
        else
        {
            //If level to load is bigger than zero, and the currentlevel value isnt negative, then it means that we are loading a level
            if (levelToLoad >= 0)
            {
                Debug.Log("Level number : " + levelToLoad);

                updateMusic(levelToLoad);
                string          loadedJsonFile = Resources.Load <TextAsset>("levels").text;
                LevelsContainer levelsInJson   = JsonUtility.FromJson <LevelsContainer>(loadedJsonFile);
                CrossLevelInfo.LevelName     = levelsInJson.levels[levelToLoad].name;
                CrossLevelInfo.mustPassIntro = mustPassIntro;
                CrossLevelInfo.time          = levelsInJson.levels[levelToLoad].time[difficultyChrono.value];
                CrossLevelInfo.maxSlimes     = levelsInJson.levels[levelToLoad].bonusCount;

                if (difficultyLife.value == 1)
                {
                    //We avoid any glitch where someone gets more that 5 lives
                    if (livesLeft.value > 5)
                    {
                        livesLeft.value = 5;
                    }
                    if (!mustPassIntro)
                    {
                        livesLeft.value = 5;
                    }
                    else
                    {
                        livesLeft.value = livesLeft.value - 1;
                        if (livesLeft.value < 0)
                        {
                            currentLevel.value--;
                            cancelLevelProgress(levelToLoad);
                            livesLeft.value = 5;
                            LoadNextLevel(Mathf.Max(0, levelToLoad - 1), false);
                            return;
                        }
                    }
                }
                else if (difficultyLife.value == 2)
                {
                    //We avoid any glitch where someone gets more that 5 lives
                    if (livesLeft.value > 5)
                    {
                        livesLeft.value = 5;
                    }
                    if (mustPassIntro)
                    {
                        livesLeft.value = livesLeft.value - 1;

                        if (livesLeft.value < 0)
                        {
                            cancelAllProgress();
                            livesLeft.value    = 5;
                            currentLevel.value = 0;
                            LoadNextLevel(0);
                            return;
                        }
                    }
                }
                StartCoroutine(loadAsynchronously(levelsInJson.levels[levelToLoad].sceneName));
            }
            else if (levelToLoad == -1)
            {
                updateMusic(0);

                StartCoroutine(loadAsynchronously("LevelSelection"));
            }
            else
            {
                updateMusic(0);

                StartCoroutine(loadAsynchronously("MainMenu"));
            }
        }


        LeanTween.reset();
        LeanTween.init(800);

        /*Debug.Log(levelsInJson.levels[levelToLoad].objName);
         * Debug.Log(levelsInJson.levels[levelToLoad].previewScale[0]);
         * Debug.Log(levelsInJson.levels[levelToLoad].previewRotation[0]);
         * Debug.Log(levelsInJson.levels[levelToLoad].bonusCount);*/
    }