개발일지/TIL

[Unity Devcamp] 0306 개발일지

JangKroed 2023. 3. 21. 21:44
728x90
반응형

block drag시 shadow 실행 함수가 update가 아닌 fixed update로 실행되게 개선

  • 이미 update를 쓰는 로직 분리하여 사라짐.
  • 현재남아있는건 OnMouseDrag 함수인데 이 로직에 shadow 실행함수에 포함되어 있어 분리하기 굉장히 애매
  • OnDrag, OnMouseDrag 함수의 차이?

2023.03.21 - [Language/Unity] - OnDrag와 OnMouseDrag의 차이

게임 저장되는 시점이 늦어 줄완성 후 게임 재접속시 줄완성 되기 전 상태로 저장되는 현상 개선

  • 기존 줄 완성 확인하는 로직 → 게임오버 조건 확인하는 로직으로 저장하는 시점 변경

 

[기획추가] - 게임오버 연출 추가

  • GameHUD.cs - ShowGameOverUI 함수 로직 추가
public void ShowGameOverUI(int score, bool isNewRecord)
    {
        LocalCache.DeleteData(LocalCache.GetMode()); // 저장된 데이터 삭제
				
				// layer 순서에 따른 비활성화
        ShapesPanel.SetActive(false); 
        Daily.SetActive(false);
        scoreText.gameObject.SetActive(false);
        BsetScoreObj.SetActive(false);
        SaveShowSocres();
				
				// 배너 비활성화
        AppLovinMaxManager.HideBanner();
        // 게임오버 소리 재생 코드 삽입예정

				// 화면 점점 어두워지는 함수 실행 + 전면광고
        FadeScript.I.FadeIn();
        gameOverGroup.SetActive(true);
        finalScoreText.text = string.Format("{0:#,###}", score);
        NewSocreText.text = string.Format("{0:#,###}", score);

        int PlayCount = PlayerPrefs.GetInt("PlayCount", 0);
        PlayerPrefs.SetInt("PlayCount", ++PlayCount);


        // 신기록 미달성시
        if (!isNewRecord)
        {
            if (PlayerPrefs.GetInt(currentGameMode) == 1 && score > int.Parse(DailyScoreTxt.text)) SetNewRecordEffect("도전 성공");
            else GameOverText.text = "게임 결과";
            PopupBoard(3);
        }
        // 신기록 달성 시
        else// if (isNewRecord != "GameOver")
        {
            if (currentGameMode == "Standard") SetNewRecordEffect("신기록");
            else if (score > int.Parse(DailyScoreTxt.text)) SetNewRecordEffect("도전 성공");
            StartCoroutine(ShowNewBestScorePopup());
        }
    }
  • FadeScript.cs 추가
public void FadeIn()
    {
        StartCoroutine(FadeInFlow());
    }

    IEnumerator FadeInFlow()
    {
        Panel.gameObject.SetActive(true);
        time = 0f;
        Color alpha = Panel.color;

				// F_time 동안 alpha값 점점 증가
        while (alpha.a < 1f)
        {
            time += Time.deltaTime / F_time;
            alpha.a = Mathf.Lerp(0, 1, time);
            Panel.color = alpha;
            yield return null;
        }

				// WaitTime 만큼 대기
        yield return YieldCache.WaitForSeconds(WaitTime);
        time = 0f;
        Panel.gameObject.SetActive(false);

				// 전면광고 실행
        AppLovinMaxManager.ShowInterstitial();

        yield return null;
    }

 

[기획추가] - 일일도전목표 팝업창 임시 삭제

  • GameHUD.cs → PlayValidation()함수에서 일일도전목표 팝업로직 주석처리
private void PlayValidation(string gameMode)
    {
        // 플레이가 두번째라면
        /*if (PlayerPrefs.GetInt("PlayCount") > 0)
        {
            // 일반모드이면서 일일목표점수 미달성시
            if (PlayerPrefs.GetInt("DailyChallenge", 0) != 1 && gameMode == "Standard")
            {
                //DailyClearState.color = Color.red;
                DailyScoreTxt.text = DailyScore.ScoreList[DateTime.Now.ToString("d일")];
                PopupDailyScoreTxt.text = DailyScoreTxt.text + "점 받기";
                AttainmentRateText.text = "오직 " + Percent(int.Parse(DailyScoreTxt.text)) + "%의 플레이어만 할 수 있어요.\n더 받아보세요!";

                DailyPopup.SetActive(true);
                Daily.SetActive(true);
                ShapesPanel.SetActive(false);
            }

            // 일일 목표점수 달성시
            if (LocalCache.GetDailyState() == 1 && currentGameMode == "Standard")
            {
                //DailyClearState.color = Color.green;
                DailyScoreTxt.text = DailyScore.ScoreList[DateTime.Now.ToString("d일")];
            }
        }*/

        // 게임모드가 일반모드가 아니라면 상단 해당 월 / 일 표기 및 목표점수 표기
        if (gameMode != "Standard")
        {
            Text ChallengeDateText = ChallengeDate.transform.GetChild(1).GetComponent<Text>();
            ChallengeDateText.text = LocalCache.GetChallengeDay();
            ChallengeDate.SetActive(true);

            //DailyClearState.sprite = Coin;
            DailyScoreTxt.text = BoardManager.I.boardData[PlayerPrefs.GetInt("SelectDay") - 1].TargetScore;
            PopupDailyScoreTxt.text = "" + Percent(int.Parse(DailyScore.ScoreList[DateTime.Now.ToString("d일")])) + "%";
            AttainmentRateText.text = "오직 이 비율의 선택된 플레이어만 이 레벨을\n해결할 수 있었어요!";

            DailyPopup.SetActive(true);
            Daily.SetActive(true);
            ScoresPopup.SetActive(false);
            ShapesPanel.SetActive(false);
        }
    }

 

[기획추가] - 점수 공식 수정

  • 줄을 완성했을 경우
    • {18 * (1 + 완성한 줄 수)} * 콤보 수 → 18 * 완성한 줄 수 * 콤보 수 으로 계산로직 수정
728x90
반응형