private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            if (!instruction.isAlreadyTriggered)
            {
                instruction.ifDisplay = true;
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                instruction.isAlreadyTriggered = true;
                instruction.ifDisplay          = false;

                if (!isViewTriggered)
                {
                    playerMove.LockControl();
                    playerMove.Standstill();

                    viewObj = Instantiate(viewPrefab) as GameObject;
                    viewObj.transform.position = new Vector2(camTrans.position.x, camTrans.position.y);

                    isViewTriggered = true;
                }
                else
                {
                    Destroy(viewObj);
                    playerMove.UnlockControl();
                    isViewTriggered = false;
                }
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        UpdateAlertVolume();

        // When cutscene is on,
        if (isCutsceneOn)
        {
            // Lock player control.
            playerMove.LockControl();
            waitTimeBeforeCutscene -= Time.deltaTime;

            if (waitTimeBeforeCutscene <= 0)
            {
                if (!kunAlarmPlayer.isPlaying)
                {
                    kunAlarmPlayer.Play(); // Play alarm sound.
                }

                // Move camera view.
                cameraCustomize.CustomizeView(targetViewSize, targetPos);

                // Alarm appears.
                if (kunAlarmSprite.color.a <= 0.99f)
                {
                    kunAlarmSprite.color += new Color(0, 0, 0, 0.7f * Time.deltaTime);
                }

                cutsceneLastTime -= Time.deltaTime;


                if (cutsceneLastTime <= 0)
                {
                    cameraCustomize.BackToNormal();
                    isEventHappened = true;
                    playerMove.UnlockControl();
                    isCutsceneOn = false;
                }
            }
        }
    }
Пример #3
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();
                }
            }
        }
    }