Example #1
0
 void Start()
 {
     anim = new RotationLerpCoroutine(
         gameObject,
         fromAngle,
         toAngle,
         moveTime,
         true
         );
     StartCoroutine(Cycle());
 }
Example #2
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());
        }
    }