GPGS 업적

Unity3D 2018. 11. 28. 16:22
반응형

일반 , 단계별 업적 

AppSmilejsu.unitypackage





https://developers.google.com/games/services/common/concepts/achievements


https://github.com/playgameservices/play-games-plugin-for-unity


http://minhyeokism.tistory.com/70?category=700407


http://silisian.tistory.com/104


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
using GooglePlayGames;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class App : MonoBehaviour {
 
    public GPGSManager gpgsManager;
    public Text txtUserName;
 
    public Button btnAch1;
    public Button btnAch2;
    public Button btnStartGame;
    public Text txtAch1;
    public Text txtAch2;
    public GameObject uiTitle;
    public GameObject uiGame;
    public Button btnAchievement;
 
    private int killNormalMonsterCnt;
    private int killEliteMonsterCnt;
    private int achievementKillMonsterStep;
    
 
 
    private void Awake()
    {
        this.uiTitle.SetActive(false);
        this.uiGame.SetActive(false);
 
    }
    // Use this for initialization
    void Start () {
        this.gpgsManager.Init();
        
        this.gpgsManager.SignIn((result) => {
            if (result)
            {
                this.txtUserName.text = Social.localUser.userName;
 
                this.uiTitle.gameObject.SetActive(true);
            }
            else {
                this.txtUserName.text = "로그인 실패";
            }
        });
 
        this.btnAch1.onClick.AddListener(() => {
            //일반몬스터 처치 
 
            this.killNormalMonsterCnt += 1;
            this.txtAch1.text= this.killNormalMonsterCnt.ToString();
 
            this.UpdateAchievement();
        });
 
        this.btnAch2.onClick.AddListener(() => {
            //정예몬스터 처치 
 
            this.killEliteMonsterCnt += 1;
            this.txtAch2.text = this.killEliteMonsterCnt.ToString();
 
            this.UpdateAchievement();
 
        });
 
        this.btnStartGame.onClick.AddListener(() => {
            Social.ReportProgress(GPGSIds.achievement, 100.0f, (success) =>
            {
                Debug.LogFormat("success{0}", success);
            });
 
            this.uiTitle.SetActive(false);
            this.uiGame.SetActive(true);
        });
 
        this.btnAchievement.onClick.AddListener(() => {
            Social.ShowAchievementsUI();
        });
 
    }
 
    private void UpdateAchievement()
    {
        var ach = PlayGamesPlatform.Instance.GetAchievement(GPGSIds.achievement_2);
        Debug.LogFormat("{0}, {1}, {2}, {3}, {4}, {5}, {6}",
            this.achievementKillMonsterStep,
            ach.CurrentSteps,
            ach.TotalSteps,
            ach.IsIncremental,
            ach.IsRevealed,
            ach.IsUnlocked,
            ach.Points);
 
        if (this.killNormalMonsterCnt == 10)
        {
            Debug.LogFormat("killNormalMonsterCnt: {0}", killNormalMonsterCnt);
 
            achievementKillMonsterStep += 1;
 
            Debug.LogFormat("achievementKillMonsterStep: {0}", achievementKillMonsterStep);
 
            Social.ReportProgress(GPGSIds.achievement___10, 100.0f, (success) =>
            {
                Debug.LogFormat("ReportProgress : {0}", success);
            });
 
            if (PlayGamesPlatform.Instance.GetAchievement(GPGSIds.achievement_2).CurrentSteps < 2)
            {
                PlayGamesPlatform.Instance.IncrementAchievement(GPGSIds.achievement_2, this.achievementKillMonsterStep, (success) => {
                    Debug.Log("IncrementAchievement: {0}" + success);
                    Debug.Log(success);
                });
            }
 
        }
        else if (this.killEliteMonsterCnt == 2)
        {
            Debug.LogFormat("killEliteMonsterCnt: {0}", killEliteMonsterCnt);
 
            achievementKillMonsterStep += 1;
 
            Debug.LogFormat("achievementKillMonsterStep: {0}", achievementKillMonsterStep);
 
            Social.ReportProgress(GPGSIds.achievement___10_2, 100.0f, (success) =>
            {
                Debug.LogFormat("ReportProgress: {0}", success);
            });
 
            if (PlayGamesPlatform.Instance.GetAchievement(GPGSIds.achievement_2).CurrentSteps < 2)
            {
                PlayGamesPlatform.Instance.IncrementAchievement(GPGSIds.achievement_2, this.achievementKillMonsterStep, (success) => {
                    Debug.Log("IncrementAchievement: {0}" + success);
                });
            }
 
        }
 
    }
 
    // Update is called once per frame
    void Update () {
        
    }
}
 
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames.BasicApi; //PlayGamesClientConfiguration
using GooglePlayGames;      //PlayGamesPlatform
 
public class GPGSManager : MonoBehaviour {
 
    public void Init()
    {
        //초기화 설정 
        PlayGamesClientConfiguration conf = new PlayGamesClientConfiguration.Builder().Build();
        PlayGamesPlatform.InitializeInstance(conf);
        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.Activate();
    }
 
    public void SignIn(System.Action<bool> onComplete)
    {
        //로그인 
        Social.localUser.Authenticate((result) => {
            
            onComplete(result);
 
        });
    }
}
 
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// <copyright file="GPGSIds.cs" company="Google Inc.">
// Copyright (C) 2015 Google Inc. All Rights Reserved.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//    limitations under the License.
// </copyright>
 
///
/// This file is automatically generated DO NOT EDIT!
///
/// These are the constants defined in the Play Games Console for Game Services
/// Resources.
///
 
 
public static class GPGSIds
{
    //일반 몬스터 10마리 처치 
    public const string achievement___10 = "CgkIkL-Tu-4XEAIQAg"; // <GPGSID>
 
    //정예몬스터 10마리 처치 
    public const string achievement___10_2 = "CgkIkL-Tu-4XEAIQBQ"; // <GPGSID>
 
    //몬스터 사냥꾼 
    public const string achievement_2 = "CgkIkL-Tu-4XEAIQBA"; // <GPGSID>
 
    //게임의 시작 
    public const string achievement = "CgkIkL-Tu-4XEAIQAw"; // <GPGSID>
 
}
 
 
cs


반응형

'Unity3D' 카테고리의 다른 글

GPGS 클라우드 저장/불러오기  (0) 2018.12.03
GPGS 리더보드  (0) 2018.11.29
GPGS 로그인  (0) 2018.11.27
IAP 테스트 (영수증검증)  (0) 2018.10.23
Socket.IO-Client-Unity3D  (0) 2018.10.19
: