Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (!isAlive)
        {
            //Time.timeScale=0;

            SetScore(leaderboardID, Score.curentScore);
            Achievement(firstRunAchievementID, 100);
            Time.timeScale = 0;
            StopButton.TrigerDie();
            //StartCoroutine(PopCountDown(2));
        }


        if (totalAffectTime > 0 && startCount)
        {
            totalAffectTime -= Time.deltaTime;
        }
        else
        {
            transform.Find("powerup").gameObject.SetActive(false);
            startCount = false;
        }

        if (transform.position.y < -0.5f)
        {
            isAlive = false;
        }

        if (doResetPosition)
        {
            transform.position = RevivePosition;
            doResetPosition    = false;
            isAlive            = true;
            transform.FindChild("fly").gameObject.SetActive(true);
            Physics.gravity = new Vector3(0, 0, 0);
            OnFly           = true;
        }

        if (OnFly && Time.timeScale != 0)
        {
            //swing
            GetComponent <Rigidbody>().velocity = Vector3.zero;
            float DelteY = Mathf.Sin(Time.time * swingSpeed) * swingDistance;
            float x      = transform.position.x;
            transform.position = new Vector3(x, transform.position.y + DelteY, transform.position.z);
        }
        else
        {
            Physics.gravity = Ogravity;
            transform.FindChild("fly").gameObject.SetActive(false);
        }
    }