Exemple #1
0
    // Update is called once per frame
    private void Update()
    {
        //return key pressed?
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            p_nextScene    = true;
            p_returnScreen = true;
        }

        //turtle animation
        float sinUpDown    = Mathf.Sin(Time.time * 3);
        float sinLeftRight = Mathf.Sin(Time.time * 1);

        m_turtle.transform.position = p_turtleOriginalPosition;
        m_turtle.transform.Translate(new Vector3(sinLeftRight, sinUpDown, 0));
        m_turtle.transform.Rotate(new Vector3(0, 1, 0), Time.deltaTime * m_rotationSpeed, Space.World);
        m_turtle.transform.Rotate(new Vector3(1, 0, 0), sinUpDown * 0.5f, Space.World);

        //button animation
        float sinButtonScale = Mathf.Sin(Time.time * 3.1f);

        m_continueButton.transform.localScale = new Vector3(1, 1, 1) * (sinButtonScale * sinButtonScale * 0.05f + 0.4475f);

        //camera animation
        if (p_nextScene)
        {
            m_camera.transform.position = Vector3.SmoothDamp(m_camera.transform.position, p_cameraEnd, ref p_cameraVelocity, m_turtleSmoothTime);

            //animate buttons fly out
            m_contButtonImage.transform.localPosition      = Vector3.SmoothDamp(m_contButtonImage.transform.localPosition, p_contButtonOutside, ref p_contButtonVelocity, m_buttonSmoothTime);
            m_lvlselectButtonImage.transform.localPosition = Vector3.SmoothDamp(m_lvlselectButtonImage.transform.localPosition, p_lvlselectButtonOutside, ref p_lvlselectButtonVelocity, m_buttonSmoothTime);

            if (m_camera.transform.position.y < -15)
            {
                //choose wich scene to load
                if (p_returnScreen)
                {
                    MemoryCard.LoadSplash();
                }
                else if (p_selectLevel)
                {
                    MemoryCard.LoadLevelSelection();
                }
                else
                {
                    MemoryCard.LoadSelectedLevel();
                }
            }
        }
        else
        {
            //animate camera
            m_camera.transform.position = Vector3.SmoothDamp(m_camera.transform.position, new Vector3(0, 0, -10), ref p_cameraVelocity, m_turtleSmoothTime);

            //animate buttons to fly in
            m_contButtonImage.transform.localPosition      = Vector3.SmoothDamp(m_contButtonImage.transform.localPosition, p_contButtonInside, ref p_contButtonVelocity, m_buttonSmoothTime);
            m_lvlselectButtonImage.transform.localPosition = Vector3.SmoothDamp(m_lvlselectButtonImage.transform.localPosition, p_lvlselectButtonInside, ref p_lvlselectButtonVelocity, m_buttonSmoothTime);

            //animate buttons to wobble
            ScaleAnimateObject(0.6f, 0.6f, m_contButtonImage);
            ScaleAnimateObject(0.8f, 0.8f, m_lvlselectButtonImage);
        }
    }