forked from dclxviclangames/Unity-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my.jslib
86 lines (73 loc) · 2.31 KB
/
my.jslib
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
mergeInto(LibraryManager.library, {
GiveMePlayerData: function () {
myGameInstance.SendMessage('Yandex', 'SetName', player.getName());
myGameInstance.SendMessage('Yandex', 'SetPhoto', player.getPhoto("medium"));
},
RateGame: function () {
ysdk.feedback.canReview()
.then(({ value, reason }) => {
if (value) {
ysdk.feedback.requestReview()
.then(({ feedbackSent }) => {
console.log(feedbackSent);
})
} else {
}
})
},
SaveExtern: function(date) {
var dateString = UTF8ToString(date);
var myobj = JSON.parse(dateString);
player.setData(myobj);
},
LoadExtern: function(){
player.getData().then(_date => {
const myJSON = JSON.stringify(_date);
myGameInstance.SendMessage('Progress', 'SetPlayerInfo', myJSON);
});
},
SetToLeaderboard : function(value){
ysdk.getLeaderboards()
.then(lb => {
lb.setLeaderboardScore('bestScore', value);
});
},
GetLang: function () {
var lang = ysdk.environment.i18n.lang;
var bufferSize = lengthBytesUTF8(lang) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(lang, buffer, bufferSize);
return buffer;
},
ShowAdv : function(){
ysdk.adv.showFullscreenAdv({
callbacks: {
onClose: function(wasShown) {
// some action after close
},
onError: function(error) {
// some action on error
}
}
})
},
AddMoneyExtern: function(value){
ysdk.adv.showRewardedVideo({
callbacks: {
onOpen: () => {
console.log('Video ad open.');
},
onRewarded: () => {
console.log('Rewarded!');
unityInstance.SendMessage("Yandex", "AddMoney", value);
},
onClose: () => {
console.log('Video ad closed.');
},
onError: (e) => {
console.log('Error while open video ad:', e);
}
}
})
}
});