개발일지/TIL

[Unity Devcamp] 0207 개발일지

2023. 3. 21. 20:46
목차
  1. 일일 목표점수 연동
  2. 일일 목표점수 매핑
  3. 일일점수 주간점수 월간점수 통산점수 구현
  4. 각 점수 및 플레이 횟수 초기화
  5. 2번째 플레이부터 목표점수 팝업창 구현
  6. 정산완료 진행 중
728x90
반응형

일일 목표점수 연동


  • 팝업 화면 점수와 인게임 점수 연동
  • 일일 목표점수 미달성시 Color.red, 달성시 Color.green

 

일일 목표점수 매핑

// DailyScore.cs
public static Dictionary<string, string> ScoreList = new()
        {
            {"1일",  "124"},
            {"2일",  "351"},
            {"3일",  "674"},
            {"4일",  "595"},
            {"5일",  "803"},
            {"6일",  "616"},
            {"7일",  "845"},
            {"8일",  "937"},
            {"9일",  "290"},
            {"10일", "533"},
            {"11일", "741"},
            {"12일", "588"},
            {"13일", "918"},
            {"14일", "446"},
            {"15일", "576"},
            {"16일", "629"},
            {"17일", "821"},
            {"18일", "887"},
            {"19일", "463"},
            {"20일", "222"},
            {"21일", "746"},
            {"22일", "517"},
            {"23일", "439"},
            {"24일", "908"},
            {"25일", "564"},
            {"26일", "366"},
            {"27일", "953"},
            {"28일", "813"},
            {"29일", "974"},
            {"30일", "432"},
            {"31일", "999"},
        };
  • 1일 ~ 31일 각 도전할 목표점수 매핑

 

일일점수 주간점수 월간점수 통산점수 구현

  • 각 점수 구현과 갱신 및 기간 별 초기화 적용
// boardManager.cs
public string SetHighScore()
        {
            int bestScore = PlayerPrefs.GetInt("bestScore", 0);
            int TodayScore = PlayerPrefs.GetInt("TodayScore", 0);
            int WeeklyScore = PlayerPrefs.GetInt("WeeklyScore", 0);
            int MonthScore = PlayerPrefs.GetInt("MonthScore", 0);

            if (score > bestScore)
            {
                PlayerPrefs.SetInt("bestScore", score);
                PlayerPrefs.SetInt("MonthScore", score);
                PlayerPrefs.SetInt("WeeklyScore", score);
                PlayerPrefs.SetInt("TodayScore", score);
                return "best";
            }

            if (score > MonthScore)
            {
                PlayerPrefs.SetInt("MonthScore", score);
                PlayerPrefs.SetInt("WeeklyScore", score);
                PlayerPrefs.SetInt("TodayScore", score);
                return "Month";
            }

            if (score > WeeklyScore)
            {
                PlayerPrefs.SetInt("WeeklyScore", score);
                PlayerPrefs.SetInt("TodayScore", score);
                return "Weekly";
            }

            if (score > TodayScore)
            {
                PlayerPrefs.SetInt("TodayScore", score);
                return "Today";
            }
            return "GameOver";
        }
// GameHUB.cs
public void ShowGameOverUI(int score, string isNewRecord)
        {
            gameOverGroup.SetActive(true);
            finalScoreText.text = score.ToString();
            scoreText.gameObject.SetActive(false);
            WeeklyScore.gameObject.SetActive(false);
            Daily.SetActive(false);
            BackBtn.SetActive(false);
            ShapesPanel.SetActive(false);

            if (isNewRecord != "GameOver") NewRecordText.gameObject.SetActive(true);

            switch (isNewRecord)
            {
                case "best":
                    NewRecordText.text = "통산 최고 점수 갱신";
                    NewRecordEffect.SetActive(true);
                    break;
                case "Month":
                    NewRecordText.text = "월간 최고 점수 갱신";
                    NewRecordEffect.SetActive(true);
                    break;
                case "Weekly":
                    NewRecordText.text = "주간 최고 점수 갱신";
                    NewRecordEffect.SetActive(true);
                    break;
                case "Today":
                    NewRecordText.text = "일간 최고 점수 갱신";
                    NewRecordEffect.SetActive(true);
                    break;
                default:
                    GameOverText.gameObject.SetActive(true);
                    break;
            }

            Transform Scores = gameOverGroup.transform.Find("Scores").gameObject.transform;

            Text Today = Scores.GetChild(2).GetChild(1).GetComponent<Text>();
            Text Weekly = Scores.GetChild(3).GetChild(1).GetComponent<Text>();
            Text Month = Scores.GetChild(4).GetChild(1).GetComponent<Text>();
            Text Total = Scores.GetChild(5).GetChild(1).GetComponent<Text>();

            Today.text = PlayerPrefs.GetInt("TodayScore", 0).ToString();
            Weekly.text = PlayerPrefs.GetInt("WeeklyScore", 0).ToString();
            Month.text = PlayerPrefs.GetInt("MonthScore", 0).ToString();
            Total.text = PlayerPrefs.GetInt("bestScore", 0).ToString();

            for (int i = 0; i < BoardPanel.childCount; i++)
            {
                BoardPanel.GetChild(i).GetComponent<SpriteRenderer>().sortingOrder = 0;
            }

           /* if (isNewRecord == "best")
            {
                NewRecordText.gameObject.SetActive(true);
                GameOverText.gameObject.SetActive(false);
            }*/
            //gameOverGroup.transform.Find("New Record Text").gameObject.SetActive(isNewRecord);


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

 

각 점수 및 플레이 횟수 초기화

// DatatimeManager.cs
public class DatatimeManager : MonoBehaviour
{
    // 날짜관련 스트립트

    public Text TodayText;

    private readonly string Today = DateTime.Now.ToString("M월 d일");

    private void Awake()
    {
        TodayText.text = Today;
        if (Today != PlayerPrefs.GetString("Today"))
        {
            if (DateTime.Now.DayOfWeek == DayOfWeek.Monday) PlayerPrefs.SetInt("WeeklyScore", 0);
            if (PlayerPrefs.GetString("Today").Substring(0, 2) != DateTime.Now.ToString("M월")) PlayerPrefs.SetInt("MonthScore", 0);
            PlayerPrefs.SetString("Today", Today);
            PlayerPrefs.SetInt("DailyChallenge", 0);
            PlayerPrefs.SetInt("PlayCount", 0);
        }
    }
}

 

2번째 플레이부터 목표점수 팝업창 구현

  • 게임오버시 PlayCount를 올려 일일 목표점수창 표시
  • GameHUB.cs > ShowGameOverUI() 함수 실행시 PlayCount++;
  • 재실행 혹은 게임 플레이시 Awake()에서 PlayCount를 검사하여 일일목표점수 표시

 

정산완료 진행 중

  • 각 기록 갱신시 폭죽 효과구현
  • 각 점수 적용
  • 보드 캡쳐 적용
미구현 사항
  • 기획서에는 완료창 이전 애니메이션 사진이 있음.

 

728x90
반응형

'개발일지 > TIL' 카테고리의 다른 글

[Unity Devcamp] 0210 개발일지  (0) 2023.03.21
[Unity Devcamp] 0208 개발일지  (0) 2023.03.21
[Unity Devcamp] 0206 개발일지  (0) 2023.03.21
[Unity Devcamp] 0201 개발일지  (0) 2023.03.21
[Unity Devcamp] 0131 개발일지  (0) 2023.03.21
  1. 일일 목표점수 연동
  2. 일일 목표점수 매핑
  3. 일일점수 주간점수 월간점수 통산점수 구현
  4. 각 점수 및 플레이 횟수 초기화
  5. 2번째 플레이부터 목표점수 팝업창 구현
  6. 정산완료 진행 중
'개발일지/TIL' 카테고리의 다른 글
  • [Unity Devcamp] 0210 개발일지
  • [Unity Devcamp] 0208 개발일지
  • [Unity Devcamp] 0206 개발일지
  • [Unity Devcamp] 0201 개발일지
JangKroed
JangKroed
JangKroed
JangKroed
JangKroed
전체
오늘
어제
  • FindAllPost() (139)
    • 항해99 (40)
      • TIL (19)
      • WIL (13)
      • 공부 (7)
    • 개발일지 (70)
      • 스파르타 게임개발 종합반 (1)
      • Error (5)
      • TIL (64)
    • Language (16)
      • Javascript (7)
      • Node.js (5)
      • TypeScript (0)
      • Nest.js (0)
      • Unity (4)
    • DataBase (3)
      • MySQL (2)
      • MongoDB (1)
    • DevOps (4)
      • AWS (4)
      • Docker (0)
    • Tools (5)
      • VScode (1)
      • Git (1)
      • libraries (3)
    • 끄적끄적 (1)
      • 메모 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

깃허브

공지사항

인기 글

태그

최근 댓글

최근 글

반응형
250x250
hELLO · Designed By 정상우.
JangKroed
[Unity Devcamp] 0207 개발일지
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.