This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A Timer to deal with exponential backoff problems | |
(inspired from phoenixjs library , much 💓) | |
*/ | |
export class BackoffTimer { | |
private timer: any; // setTimeout Id. | |
private callbackFunction: typeof Function; | |
private currentTries: number = 0; | |
private maxTries: number = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"editor.insertSpaces": false, | |
"editor.tabSize": 2, | |
"workbench.colorCustomizations": { | |
"activityBar.background": "#0f0039", | |
"activityBar.foreground": "#d9ff02", | |
"statusBar.background": "#0f0039", | |
"statusBar.foreground": "#d9ff02", | |
"titleBar.activeBackground": "#0f0039", | |
"titleBar.activeForeground": "#d9ff02", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private loadAssets(){ | |
console.log("loading assets"); | |
this._assetManager=new AssetsManager(this._Scene); | |
let meshTask=this._assetManager.addMeshTask("gemTask","Skull","Assets/","Skull.obj"); | |
meshTask.onSuccess=(task:MeshAssetTask)=>{ | |
console.log("load success"); | |
console.log(task); | |
task.loadedMeshes[0].position=Vector3.Zero(); | |
} | |
meshTask.onError=(task,message,exception)=>{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private loadAssets(){ | |
console.log("loading assets"); | |
this._assetManager=new AssetsManager(this._Scene); | |
let meshTask=this._assetManager.addMeshTask("gemTask","gem","../Assets/","diamond.obj"); | |
meshTask.onSuccess=(task:MeshAssetTask)=>{ | |
console.log("load success"); | |
task.loadedMeshes[0].position=Vector3.Zero(); | |
} | |
meshTask.onError=(task,message,exception)=>{ | |
console.log(message,exception); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function onRequestDice(context,payload) | |
local id,jsonData,isAllowed,diceVal | |
jsonData=RecordsInst.nk.json_decode(payload) | |
id=jsonData.id | |
-- if not checkTurn(id) then | |
-- return RecordsInst.nk.json_encode({["dice"]=0}) | |
-- else | |
diceVal=math.random(6) | |
-- return RecordsInst.nk.json_encode({["dice"]=diceVal}) | |
return manageNextTurn(_diceval) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private restoreSessionAndConnect(){ | |
let sessionString:string=null; | |
if(typeof(Storage)!==undefined){ | |
sessionString=localStorage.getItem('nakamaToken'); | |
} | |
if(!sessionString || sessionString===""){ | |
return; | |
} | |
let session; | |
session=nakamajs.Session.restore(sessionString); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function helper.writePlayerData(_playerID,_color) | |
-- local curCount | |
local curCount=fetchCount() | |
print(curCount.current) | |
print(_playerID .. " : " .. _color) | |
local new_record={ | |
{Bucket=_bucket,Collection="GamePlay",Record="playerData",Value={id=curCount.current,color=_color}} | |
} | |
if curCount.current<1 then | |
nk.storage_write(new_record) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"playerdata":[ | |
{ | |
"id":0, | |
"color":2, | |
"active":true | |
}, | |
{ | |
"id":1, | |
"color":3, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local nk=require("nakama") | |
--writing record of total players | |
function writeTotalPlayers(total_player) | |
local new_record={ | |
{Bucket="LL",Collection="GamePlay",Record="Common",Value={total=total_player}} | |
} | |
nk.storage_write(new_record) | |
end |