Exemplo n.º 1
0
    IEnumerator Cycle()
    {
        while (true)
        {
            StartCoroutine(anim.AnimationCoroutine());
            yield return(new WaitForSeconds(moveTime + stopTime));

            StartCoroutine(anim.AnimationCoroutine(true));
            yield return(new WaitForSeconds(moveTime + stopTime));
        }
    }
Exemplo n.º 2
0
 void StartStateChanged(bool started)
 {
     if (started)
     {
         StartCoroutine(anim.AnimationCoroutine());
     }
     else
     {
         StopAllCoroutines();
         transform.position = fromPos;
     }
 }
Exemplo n.º 3
0
    IEnumerator Cycle()
    {
        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(spawnMinInterval, spawnMaxInterval)));

            number.SetActive(true);
            number.transform.localRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 359f));
            StartCoroutine(transformAnimation.AnimationCoroutine());
            StartCoroutine(colorAnimation.AnimationCoroutine());
            yield return(new WaitForSeconds(moveTime));

            number.SetActive(false);
        }
    }
Exemplo n.º 4
0
    IEnumerator EndCycle()
    {
        yield return(new WaitForSeconds(AnimationDuration));

        //show heart
        heart.SetActive(true);

        //spawn in love audio
        Instantiate(inLoveAudio, transform.position, Quaternion.identity);

        //make negstone a whole game object
        gameObject.transform.parent = negStone.transform;
        littleNeg.transform.parent  = negStone.transform;

        //title animation & neg stone rising
        titleTransformAnimation = new TransformLerpCoroutine(
            gameTitle,
            gameTitle.transform.position,
            titleToPos,
            TitleScaleAnimationDuration
            );

        titleScalingAnimation = new ScalingLerpCoroutine(
            gameTitle,
            gameTitle.transform.localScale,
            titleToLocalScale,
            TitleScaleAnimationDuration
            );

        negStoneTransformAnimation = new TransformLerpCoroutine(
            negStone,
            negStone.transform.position,
            negStoneToPos,
            TitleScaleAnimationDuration
            );

        StartCoroutine(titleTransformAnimation.AnimationCoroutine());
        StartCoroutine(titleScalingAnimation.AnimationCoroutine());

        yield return(new WaitForSeconds(TitleScaleAnimationDuration));

        StartCoroutine(negStoneTransformAnimation.AnimationCoroutine());

        yield return(new WaitForSeconds(NegStoneRisingDuration));

        //activate win scene canvas
        winSceneCanvas.SetActive(true);
    }
Exemplo n.º 5
0
    IEnumerator GoThroughPath()
    {
        int   currPos = Destinations.Length - 1;
        int   nextPos = 0;
        float duration;
        TransformLerpCoroutine currMovement;

        while (true)
        {
            duration     = Vector3.Distance(Destinations [currPos], Destinations [nextPos]) / speed;
            currMovement = new TransformLerpCoroutine(
                gameObject,
                Destinations[currPos],
                Destinations[nextPos],
                duration
                );
            StartCoroutine(currMovement.AnimationCoroutine());
            yield return(new WaitForSeconds(duration));

            nextPos = (nextPos + 1) % Destinations.Length;
            currPos = (currPos + 1) % Destinations.Length;
        }
    }
Exemplo n.º 6
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Player")
        {
            //save high score
            float previousScore = GameDataLoaderAndSaver.dataControl.GetHighScore(4, 12);
            if (previousScore < 0f || previousScore > GameMoniter.Instance.Score)
            {
                GameDataLoaderAndSaver.dataControl.SetHighScoreAndSave(4, 12, GameMoniter.Instance.Score);
            }

            //make the score text invisible
            gameScoreText.color = new Color(0f, 0f, 0f, 0f);

            //disable restart button
            GameMoniter.Instance.restartButton.SetActive(false);

            littleNeg.GetComponent <Rigidbody2D> ().velocity        = Vector2.zero;
            littleNeg.GetComponent <Rigidbody2D> ().isKinematic     = true;
            littleNeg.GetComponent <Rigidbody2D> ().angularVelocity = 0f;

            //destroy game objects
            foreach (GameObject go in objectsToDestroy)
            {
                Destroy(go);
            }

            //destroy charges
            foreach (ElectricCharge electricCharge in GameMoniter.Instance.charges)
            {
                GameObject go = electricCharge.gameObject;
                if (go != gameObject && go != negStone)
                {
                    Destroy(go);
                }
            }

            //init coroutines
            littleNegRotationAnimation = new RotationLerpCoroutine(
                littleNeg,
                littleNeg.transform.eulerAngles.z,
                Quaternion.identity.eulerAngles.z,
                AnimationDuration
                );

            littleNegTransformAnimation = new TransformLerpCoroutine(
                littleNeg,
                littleNeg.transform.position,
                littleNegToPos,
                AnimationDuration
                );

            littlePosTransformAnimation = new TransformLerpCoroutine(
                gameObject,
                transform.position,
                littlePosToPos,
                AnimationDuration,
                true
                );

            //start coroutines
            StartCoroutine(littleNegRotationAnimation.AnimationCoroutine());
            StartCoroutine(littlePosTransformAnimation.AnimationCoroutine());
            StartCoroutine(littleNegTransformAnimation.AnimationCoroutine());

            //end
            StartCoroutine(EndCycle());
        }
    }