232 lines
6.1 KiB
C#
232 lines
6.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json;
|
|
using ASMhQ45fSDK;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Random = UnityEngine.Random;
|
|
|
|
public class ASMhQ45fSDKDemo : MonoBehaviour
|
|
{
|
|
public void ShowReward()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.ShowRewardVideo("TAG", b =>
|
|
{
|
|
Debug.LogError($"reward result = {b}");
|
|
},(() =>
|
|
{
|
|
Debug.LogError($"reward close!!!");
|
|
}));
|
|
}
|
|
|
|
public void ShowInter()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.ShowInter("TAG", () =>
|
|
{
|
|
Debug.LogError("inter hide");
|
|
});
|
|
}
|
|
|
|
public void ShowAdmobInter()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.ShowAdmobInter("TAG", () =>
|
|
{
|
|
Debug.LogError("inter hide");
|
|
});
|
|
}
|
|
|
|
public void ShowSplash()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.ShowSplash();
|
|
}
|
|
|
|
public void CheckReward(Image btnImg)
|
|
{
|
|
var isReady = ASMhQ45fSDKUTILITY.Instance.IsVideoReady();
|
|
btnImg.color = isReady ? Color.green : Color.white;
|
|
Debug.Log($"Reward : {isReady}");
|
|
}
|
|
|
|
public void CheckInter(Image btnImg)
|
|
{
|
|
var isReady = ASMhQ45fSDKUTILITY.Instance.IsInterReady();
|
|
btnImg.color = isReady ? Color.green : Color.white;
|
|
Debug.Log($"Inter : {isReady}");
|
|
}
|
|
|
|
public void CheckSplash(Image btnImg)
|
|
{
|
|
var isReady = ASMhQ45fSDKUTILITY.Instance.IsSplashReady();
|
|
btnImg.color = isReady ? Color.green : Color.white;
|
|
Debug.Log($"Splash : {isReady}");
|
|
}
|
|
|
|
public void Track()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.Track("test", new Dictionary<string, string>()
|
|
{
|
|
{"evt1", "1"},
|
|
{"evt2", "2"},
|
|
{"evt3", "3"},
|
|
{"evt4", "4"},
|
|
{"evt5", "5"},
|
|
{"evt6", "6"},
|
|
{"evt7", "7"},
|
|
{"evt8", "8"},
|
|
{"evt9", "9"},
|
|
});
|
|
|
|
|
|
}
|
|
|
|
public void GetCountryCode()
|
|
{
|
|
|
|
var code = ASMhQ45fSDKUTILITY.Instance.GetCountryCode();
|
|
Debug.Log($"country : {code}");
|
|
}
|
|
|
|
public void ShowH5()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.H5.ShowH5((() =>
|
|
{
|
|
Debug.Log("H5 close");
|
|
}), () =>
|
|
{
|
|
Debug.Log($"H5 show failed!");
|
|
});
|
|
}
|
|
|
|
public void ShowH5(RectTransform rectTransform)
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.H5.ShowH5(rectTransform);
|
|
}
|
|
|
|
public void HideH5()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.H5.HideH5();
|
|
}
|
|
|
|
public void CheckShowH5(Image btnImg)
|
|
{
|
|
var show = ASMhQ45fSDKUTILITY.Instance.H5.IsShowH5();
|
|
btnImg.color = show ? Color.green : Color.red;
|
|
Debug.Log($"CheckShowH5 : {show}");
|
|
}
|
|
|
|
private int _level = 1;
|
|
public void TrackLevel()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.TrackLevelUp(_level);
|
|
if (Random.Range(0, 100) < 50)
|
|
{
|
|
_level++;
|
|
}
|
|
}
|
|
|
|
private string withDrawSceneId = "";
|
|
public void GetWithDrawConfigs()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.GetWithDrawConfigs(((b, s) =>
|
|
{
|
|
Debug.Log($"GetWithDrawConfigs result : {b}, data : {s}");
|
|
if (b)
|
|
{
|
|
var cfgs = JsonConvert.DeserializeObject<List<WithDrawConfig>>(s);
|
|
int idx = 0;
|
|
foreach (WithDrawConfig config in cfgs)
|
|
{
|
|
Debug.Log($"index = {idx}, {config.ToString()}");
|
|
if (idx == 0)
|
|
withDrawSceneId = config.SecneId;
|
|
idx++;
|
|
}
|
|
}
|
|
|
|
}));
|
|
}
|
|
|
|
private int payIndex = 0;
|
|
public void CreateWithDrawOrder()
|
|
{
|
|
string taxNo = "";
|
|
string payAccount = "tom@gmail.com";
|
|
string accountType = "E";
|
|
PaymentTypeCode payCode = PaymentTypeCode.GOPAY;
|
|
//GOPAY DANA 收款账号需要为电话号码
|
|
if (payIndex == 1 || payIndex == 0)
|
|
{
|
|
payCode = payIndex == 1 ? PaymentTypeCode.DANA : payCode;
|
|
payAccount = "0881234567890";
|
|
accountType = "P";
|
|
}
|
|
if (payIndex == 2)
|
|
{
|
|
// PIX 需要填写税号
|
|
payCode = PaymentTypeCode.PIX;
|
|
taxNo = "99999999999";
|
|
}
|
|
if (payIndex == 3) payCode = PaymentTypeCode.MERCADOPAGO;
|
|
ASMhQ45fSDKUTILITY.Instance.CreateWithDrawOrder(withDrawSceneId, payCode, payAccount, accountType, "testName", taxNo, b =>
|
|
{
|
|
Debug.Log($"CreateWithDrawOrder result : {b}");
|
|
});
|
|
|
|
payIndex++;
|
|
payIndex = payIndex > 3 ? 0 : payIndex;
|
|
}
|
|
|
|
public void GetWithDrawOrders()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.GetWithDrawOrders(((b, s) =>
|
|
{
|
|
Debug.Log($"GetWithDrawOrders result : {b}, data : {s}");
|
|
if (b)
|
|
{
|
|
var cfgs = JsonConvert.DeserializeObject<List<WithDrawOrder>>(s);
|
|
int idx = 0;
|
|
foreach (WithDrawOrder config in cfgs)
|
|
{
|
|
Debug.Log($"index = {idx}, {config.ToString()}");
|
|
idx++;
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Init();
|
|
|
|
Invoke("ShowSplash", 5);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
ASMhQ45fSDKUTILITY.Instance.RegistIosParam((i =>
|
|
{
|
|
Debug.Log($"ios ab param : {i}");
|
|
}));
|
|
|
|
void GameConfig(bool result, string config)
|
|
{
|
|
Debug.Log($"************* game config result : {result}, config : {config}");
|
|
}
|
|
|
|
ASMhQ45fSDKUTILITY.Instance.Init(null, "app_config", GameConfig);
|
|
}
|
|
|
|
public static string GetSdkVersion()
|
|
{
|
|
return ASMhQ45fSDKUTILITY.SdkVersion;
|
|
}
|
|
}
|