Ejemplo n.º 1
0
    int width, height;    //resolução da janela

    void Start()
    {
        //o objeto, assim que é criado, assume papel como singleton
        if (me != null)
        {
            Destroy(gameObject);
            return;
        }
        me = this;
        Content.Start();
        loading = true;
        credits = false;

        //marcar as referências
        tr    = transform;
        camTr = tr.Find("cam");
        cam   = camTr.GetComponent <Camera>();

        background = camTr.Find("bg").GetComponent <Animator>();
        fisheye    = camTr.GetComponent <Fisheye>();
        blur       = camTr.GetComponent <MotionBlur>();
        fade       = camTr.Find("fade").GetComponent <SpriteRenderer>();
        blank      = camTr.Find("blank").GetComponent <SpriteRenderer>();
        fading     = camTr.Find("fading").GetComponent <Animator>();

        creditsTr     = camTr.Find("credits");
        creditsScroll = creditsTr.Find("scroll");

        meterTr     = camTr.Find("meter");
        meterHeight = meterTr.Find("height");

        sheepTr   = tr.Find("sheep");
        sheep     = sheepTr.GetComponent <Sheep>();
        badTripTr = tr.Find("badtrip");

        audioBg  = camTr.GetComponent <AudioSource>();
        audioBad = badTripTr.GetComponent <AudioSource>();

        //carregar cenas
        //na vdd isso depende. se o cara tá no _main, ele carrega o jogo normal.
        //senão, ele carrega só as coisas atuais, para testar essa fase específica.
                #if UNITY_EDITOR
        if (Application.loadedLevelName == "_main")
        {
                #endif
        //carregar todas as cenas
        levelCount = sceneNames.Length;
        levels     = new Level[levelCount];
        StartCoroutine(LoadLevels());
                #if UNITY_EDITOR
    }

    else
    {
        //carreegar só a cena atual.
        //isso só funciona no editor pq né
        levels = new Level[] { (Level)GameObject.FindObjectsOfType(typeof(Level))[0] }
        ;
        levels[0].index = 0;
        levels[0].start = 0;
        levels[0].end   = levels[0].width;
        totalWidth      = levels[0].width;
        levelCount      = 1;
        loading         = false;

        //iniciar nível
        levelIndex = 0;
        UpdateLevel();
        UpdateCameraLimits();
        camX = minX;
        camTr.localPosition = new Vector3(camX, camTr.localPosition.y, camTr.localPosition.z);
    }
                #endif

        fisheye.strengthX = fisheye.strengthY = 0;
                #if UNITY_EDITOR
        if (Application.loadedLevelName == "_main" || Application.loadedLevelName == "map1")
        {
            meterTr.localPosition = new Vector3(meterTr.localPosition.x, meterTr.localPosition.y, 500);
        }
        else
        {
            meterTr.localPosition = new Vector3(meterTr.localPosition.x, meterTr.localPosition.y, 0);
            sheep.AddHighness();
        }
                #else
        meterTr.localPosition = new Vector3(meterTr.localPosition.x, meterTr.localPosition.y, 500);
                #endif

        badTripPos = -10;
        badTripTr.localPosition = new Vector3(-10, badTripTr.localPosition.y, badTripTr.localPosition.z);
        fade.color = Color.black;
        creditsTr.localPosition = new Vector3(0, 0, -500);
        blank.color             = new Color(1, 1, 1, 0);

        //verifica se mostra o tempo ou não --- JU
        if (Content.firstRun)
        {
            tr.Find("tutorial").localPosition = Vector3.zero;
            tr.Find("status").localPosition   = new Vector3(0, 0, 500);
        }
        else
        {
            tr.Find("status").localPosition   = Vector3.zero;
            tr.Find("tutorial").localPosition = new Vector3(0, 0, 500);
            float  timeFinal = Content.timeEnd - Content.timeStart;
            string prefix;
            if (Content.gotThrough)
            {
                prefix = "completed in ";
            }
            else
            {
                prefix = "lived for ";
            }
            tr.Find("status/text").GetComponent <TextMesh>().text = prefix + ((int)(timeFinal / 60)).ToString("D2") + ":" + (timeFinal % 60).ToString("00.000") + "\n" + Content.collectablesLast + "/8 flowers colected";
        }

        //atualizar resolução do jogo
        SetCamera();
    }