Wortal SDK
설치하기
- git URL을 통해 Wortal SDK Unity 패키지를 설치합니다:
https://github.com/Digital-Will-Inc/wortal-sdk-unity.git
- 툴바에서 Wortal WebGL 템플릿을 설치합니다:
Wortal/Install WebGL Template
- 툴바에서 필요한 프로젝트 설정을 한다:
Wortal/Set Project Settings
사용방법
광고
인터스티셜 광고는 레벨을 달성하거나 전환하는 사이사이에 표시할 수 있습니다.
// 플레이어가 레벨을 달성.
Wortal.Ads.ShowInterstitial(Placement.Next, "NextLevel", PauseGame, ResumeGame);
// 플레이어가 게임을 일시 중지했습니다.
Wortal.Ads.ShowInterstitial(Placement.Pause, "PausedGame", PauseGame, ResumeGame);
// 플레이어가 인앱 결제 페이지에 접속합니다.
Wortal.Ads.ShowInterstitial(Placement.Browse, "BrowseShop", PauseGame, ResumeGame);
리워드 광고는 플레이어가 동영상 광고를 끝까지 시청하는 등의 조건을 충족할 경우 보상을 제공하는 광고 유형입니다. 반드시 플레이어에게 알리고 허락을 받은 후 표시해야 합니다.
// 이 예시에서는 광고 조건 달성 여부와 상관없이 게임이 진행됩니다.
// 예: 플레이어는 광고를 시청하여 보너스 코인을 획득할 수 있지만, 그 결과와 상관없이 게임은 계속 진행됩니다.
Wortal.Ads.ShowRewarded("BonusCoins", PauseGame, ResumeGame, DontReward, RewardPlayer);
// 이 예시에서는 광고 조건 달성 여부와 관련하여 게임이 진행됩니다.
// 예: 게임오버 시 플레이어는 광고를 시청하여 부활할 수 있지만, 광고를 건너뛰면 해당 레벨을 잃게 됩니다.
Wortal.Ads.ShowRewarded("ReviveAndContinue", PauseGame, ResumeAudio, EndGame, RevivePlayerAndContinue);
참고: 플레이어는 adViewed 콜백을 통해서만 보상을 받을 수 있습니다.
애널리틱스
Wortal의 애널리틱스 API를 활용하여 게임 이벤트를 추적하고 플레이어의 게임 내 활동을 파악할 수 있습니다. 이 데이터는 Wortal의 대시보드에서 확인할 수 있습니다.
// 레벨 시작을 기록합니다.
Wortal.Analytics.LogLevelStart("Level 3");
// 레벨의 끝을 기록합니다. 이름이 일치하면 게임 시간을 기록한다.
// logLevelStart()의 마지막 호출명
Wortal.Analytics.LogLevelEnd("Level 3", "100", true);
// 플레이어의 게임 내 선택 행동을 기록합니다. 게임의 밸런스를 맞추는 데 도움이 됩니다.
// 그리고 플레이어가 많이 이용하는 콘텐츠를 파악할 수 있습니다.
Wortal.Analytics.LogGameChoice("Character", "Blue");
업적
Achievements API는 플레이어의 게임 내 진행 상황을 추적하는 데 사용됩니다. 특정 작업을 완료한 플레이어에게 보상을 제공하고, 플레이어의 진행 상황을 추적할 수 있습니다.
// 업적 잠금 해제하기.
Wortal.Achievements.UnlockAchievement("achievementID",
success => Debug.Log("Achievement Unlocked: " + success),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 플레이어의 업적 진행상황을 조회할 수 있습니다.
Wortal.Achievements.GetAchievements(achievements =>
{
foreach (Achievement achievement in achievements)
{
Debug.Log(achievement.Name);
}
},
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
컨텍스트
컨텍스트 API는 플레이어끼리 연결하여 게임 섹션 참여, 콘텐츠 공유, 메시지 교환 등에 활용할 수 있습니다.
// 친구를 게임에 초대합니다. 플레이어의 현재 컨텍스트를 전환하지 않는다.
Wortal.Context.Invite(payload,
() => Debug.Log("Invite sent"),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 이 게임의 활동을 친구들과 공유하세요.
Wortal.Context.Share(payload,
shareResult => Debug.Log("Number of shares: " + shareResult),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
컨텍스트 페이로드 템플릿
Context API에서 사용할 페이로드를 쉽게 생성하고 관리하기 위해 Wortal/Context Payload Template 메뉴에서 ContextPayloadTemplates를 생성할 수 있다.
인앱결제
인앱 결제(IAP)는 플랫폼에서 게임 내 거래를 할 때 사용됩니다. 이 프로세스는 플레이하는 플랫폼에 따라 다르지만, IP는 동일합니다.
// 플레이어가 구매할 수 있는 아이템 목록 확인.
Wortal.IAP.GetCatalog(
catalog => Debug.Log(catalog[0].Title),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 아이템 구매하기.
Wortal.IAP.MakePurchase(new WortalIAP.PurchaseConfig
{
ProductID = "id.code.for.product",
},
purchase => Debug.Log(purchase.PurchaseToken), // Use this token to consume purchase
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
리더보드
리더보드 API를 활용하면 플랫폼의 리더보드 기능에 접근할 수 있습니다. 플레이어들의 점수를 추적하고 순위를 매길 수 있습니다.
// 상위 10위 안에 든 리더보드를 획득할 수 있다.
Wortal.Leaderboard.GetEntries("global", 10,
entries => Debug.Log("Score: " + entries[0].Score),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 플레이어의 점수를 리더보드에 추가합니다.
Wortal.Leaderboard.SendEntry("global", 100,
entry => Debug.Log("Score: " + entry.Score),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
알림
Notifications API는 플레이어에게 알림을 보내는 데 사용됩니다. 이를 통해 플레이어에게 게임 내 이벤트를 알리거나 다시 플레이하도록 유도하는 데 사용할 수 있습니다.
// 플레이어에게 보낼 알림을 예약합니다.
Wortal.Notifications.Schedule(payload,
result => Debug.Log(result),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 예약된 알림을 취소합니다.
Wortal.Notifications.Cancel("notification-id-123",
() => Debug.Log("Notification cancelled"),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
알림 페이로드 템플릿
Notifications API에서 사용할 페이로드를 쉽게 생성하고 관리할 수 있도록 Wortal 메뉴에서 템플릿을 생성할 수 있습니다. 이 템플릿은 ScriptableObjects로, 코드를 작성하지 않고도 Unity Editor에서 쉽게 디자인하고 수정할 수 있습니다. 템플릿에 대한 자세한 내용과 제한 사항은 이 토론을 참고하세요.
플레이어
현재 플레이어에 대한 자세한 내용은 Player API에서 확인할 수 있습니다.
// 플레이어의 친구 중 게임을 해본 적이 있는 사람들의 목록을 가져옵니다.
Wortal.Player.GetConnectedPlayers(payload,
players => Debug.Log(players[0].GetName()),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 플레이어의 데이터를 플랫폼에 저장하기
Dictionary<string, object> data = new()
{
{ "items", new Dictionary<string, int>
{
{ "coins", 100 },
{ "boosters", 2 },
}
},
{ "lives", 3 },
};
Wortal.Player.SetData(data,
() => Debug.Log("Data set"),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 플랫폼에서 플레이어의 세이브 데이터 가져오기
Wortal.Player.GetData(new[] { "items", "lives" },
data =>
{
// 캐스팅이나 조작을 하기 전에 반환값의 타입을 확인해야 한다.
foreach (KeyValuePair<string, object> kvp in data)
{
Debug.Log("Key name: " + kvp.Key);
Debug.Log("Value type: " + kvp.Value.GetType());
}
// 중첩된 객체는 다음과 같이 역직렬화됩니다.<string, object>
var items = (Dictionary<string, object>)data["items"];
Debug.Log("Coins: " + items["coins"]);
},
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
세션
현재 세션 상태에 대한 자세한 내용은 Session API에서 확인할 수 있습니다.
// 게임이 시작된 진입점을 얻는다.
Wortal.Session.GetEntryPoint(
entryPoint => Debug.Log(entryPoint),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 초대 및 공유를 통해 진입점 데이터를 가져옵니다.
// 이 기능은 플레이어가 어디에서 왔는지 추적하는 데 도움이 됩니다.
// 초대받은 플레이어에게 보상을 제공합니다.
var entryPointData = Wortal.Session.GetEntryPointData();
foreach (KeyValuePair<string, object> kvp in data)
{
// 데이터를 사용하여 처리합니다.
}
통계
Stats API는 게임 내 플레이어의 통계를 추적하는 데 사용됩니다. 플레이어의 진행 상황을 추적하고 게임 밸런스를 조정하는 데 활용할 수 있습니다. 밸런스를 조정하는 데 유용할 수 있습니다.
// 플레이어의 통계 정보를 가져옵니다.
Wortal.Stats.GetStats(
"Level 1",
new GetStatsPayload { Period = StatPeriod.ALLTIME },
stats =>
{
foreach (Stats stat in stats)
{
Debug.Log(stat.Name);
}
},
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 플레이어의 통계를 업데이트합니다.
Wortal.Stats.PostStats(
"Level 1",
100,
new PostStatsPayload { Period = StatPeriod.DAILY },
allback => Debug.Log("Stats posted!"),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
};
토너먼트
Tournament API는 게임의 토너먼트를 생성하고 관리하는 데 사용됩니다.
// 토너먼트 생성하기.
Wortal.Tournament.Create(createPayload,
tournament => Debug.Log("Tournament ID: " + tournament.ID),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));
// 토너먼트에서 점수를 기록한다.
Wortal.Tournament.PostScore(200,
() => Debug.Log("Score posted!"),
error => Debug.Log("Error Code: " + error.Code + "\nError: " + error.Message));