Example #1
0
    // Update is called once per frame
    void Update()
    {
        targetPos = player.transform.position;

        if (targetPos.y < GameStatics.GetCameraMinimumYAxis(StageLoader.CurrentStage))
        {
            targetPos.y = GetCameraMinimumYAxis(StageLoader.CurrentStage);
        }
        if (camFixedXAxis)
        {
            if (targetPos.x < levelMinXAxis)
            {
                targetPos.x = levelMinXAxis;
            }
            if (targetPos.x > levelMaxXAxis)
            {
                targetPos.x = levelMaxXAxis;
            }
        }

        // Stage3 Last Camera Move
        if (StageLoader.CurrentStage == 3)
        {
            if (player.transform.position.y > 1715 &&
                (player.transform.position.x > -3 && player.transform.position.x < 120))
            {
                // Last Jump
                targetPos.x = 82;
                targetPos.y = 1718;
            }
            else if (player.transform.position.y > 1700 &&
                     player.transform.position.x >= 120)
            {
                // Ending Trigger
                targetPos.x = 145;
                targetPos.y = 1720;

                if (!PlayerManager.Instance().IsTriggerEnding&& player.IsGround())
                {
                    PlayerManager.Instance().IsTriggerEnding = true;
                }
            }
        }

        // Stage 1 Tutorial
        if (GameConfigs.GetWatchedTutorial() == false)
        {
            if (StageLoader.CurrentStage == 1)
            {
                if (player.isFainting == false && player.IsGround() && TopMostControl.Instance().startShowTutorialPopup1 == false)
                {
                    TopMostControl.Instance().startShowTutorialPopup1 = true;
                    TopMostControl.Instance().PopupSingle.ShowPopup(
                        "<color=cyan>JUMP</color>",
                        "<color=yellow>Draw Finger</color> to decide the direction\n\n" +
                        "<color=yellow>Release</color> to Jump");
                }

                if (player.transform.position.x > 30 && TopMostControl.Instance().startShowTutorialPopup2 == false)
                {
                    TopMostControl.Instance().startShowTutorialPopup2 = true;
                    TopMostControl.Instance().PopupSingle.ShowPopup(
                        "<color=cyan>AIR TIME</color>",
                        "<color=yellow>Hold Touch</color> to slow time in the Air", () => {
                        TopMostControl.Instance().PopupSingle.ShowPopup(
                            "<color=cyan>DOUBLE JUMP</color>",
                            "<color=yellow>JUMP</color> in the Air time", () => {
                            GameConfigs.SetWatchedTutorial(true);
                        });
                    });
                }
            }
        }

        // Check Upgrade Status
        if (TopMostControl.Instance().GetGameUIStatus() == TOPUI_STATUS.GAMEOVER)
        {
            targetPos.y = player.transform.position.y + UpgradeUIYOffset;
        }

        if (IsShakingCamera == false)
        {
            cameraTransform.position = Vector2.Lerp(cameraTransform.position, targetPos, 0.2f);
            cameraTransform.position = new Vector3(cameraTransform.position.x, cameraTransform.position.y, -10f);
        }
    }