예제 #1
0
    // Update is called once per frame
    void Update()
    {
        // If broken core is put back,
        // broken core on ground disappears
        // and appears on the wall.
        if (coreState == PUTBACK)
        {
            if (brokenCoreGround.color.a >= 0.01f)
            {
                brokenCoreGround.color -= new Color(0, 0, 0, 0.7f * Time.deltaTime);
            }
            if (brokenCoreLayer.color.a <= 0.99f)
            {
                brokenCoreLayer.color += new Color(0, 0, 0, 0.7f * Time.deltaTime);
            }

            // Raise the glass too when broken core is put back.
            if (glassTrans.position.y < glassTargetHeight)
            {
                glassTrans.position += 0.7f * Time.deltaTime * Vector3.up;
            }
        }
        else if (coreState == REPLACED)
        {
            // If core is replaced with new core,
            // broken core on wall disappears
            // and the new one appears.
            if (brokenCoreLayer.color.a >= 0.01f)
            {
                brokenCoreLayer.color -= new Color(0, 0, 0, 0.7f * Time.deltaTime);
            }
            if (newCoreLayer.color.a <= 0.99f)
            {
                newCoreLayer.color += new Color(0, 0, 0, 0.7f * Time.deltaTime);
            }
        }


        if (freezeTimerStart)
        {
            playerMove.LockControl();

            freezeTimer -= Time.deltaTime;
            if (freezeTimer <= 0)
            {
                playerMove.UnlockControl();
                freezeTimer      = animFreezeTime;
                freezeTimerStart = false;
            }
        }


        // Wait for some time before triggering cutscene.
        if (isWaitingForCutscene)
        {
            waitingForCutsceneTime -= Time.deltaTime;

            if (waitingForCutsceneTime <= 0)
            {
                isCutsceneOn         = true;
                isWaitingForCutscene = false;
            }
        }

        if (isCutsceneOn)
        {
            // Disable rigidbody constraints on player
            // since player will be moving without
            // player control.
            playerMove.LockControl();
            //playerMove.isCutScene = true;
            player.GetComponent <Rigidbody2D>().constraints    = RigidbodyConstraints2D.FreezeRotation;
            player.GetComponent <Player_Constraints>().enabled = false;

            // During the cutscene,
            // player walks out out core room first.
            if (cameraMove.currentScene == General_SceneList.COREROOM)
            {
                playerMove.WalkLeft();
            }
            else if (cameraMove.currentScene == General_SceneList.OUTSIDEKUN)
            {
                // Start screen shake when rising.
                if (!isScreenShaked)
                {
                    cameraObj.GetComponent <Camera_ScreenShake>().StartShake(18f, 0.05f, 0.05f);
                    isScreenShaked = true;
                }

                // Player stands still after went outside.
                playerMove.Standstill();


                // Update cutscene camera pos based on player position.
                cutsceneCameraPos = player.transform.position + new Vector3(-1.2f, -3.2f, 0);
                cutsceneCameraPos = new Vector3(cutsceneCameraPos.x, cutsceneCameraPos.y, -10);


                // After player left core room,
                // KUN starts to rise.
                if ((trans.isTransiting && trans.isRelocateComplete) || (!trans.isTransiting && !trans.isRelocateComplete))
                {
                    cameraObj.GetComponent <Camera_CustomizeView>().CustomizeView(cutsceneCameraViewSize, cutsceneCameraPos);
                    player.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezePositionX;
                    KUNRise();
                }


                // After rising to certian height,
                // KUN transforms into "PENG".
                if (kunTrans.position.y >= 27f)
                {
                    KUNTransform();
                }


                // When KUN reaches the end,
                // stop cutscene.
                if (kunTrans.position.y >= kunTargetHeight)
                {
                    StopCutscene();
                }
            }
        }
    }