FH Link
This commit is contained in:
@@ -14,8 +14,8 @@ public class AdsManager : MonoBehaviour
|
||||
instance = this;
|
||||
}
|
||||
|
||||
const string intAdId = "ca-app-pub-3940256099942544/1033173712";
|
||||
const string rewardedAdId = "ca-app-pub-3940256099942544/5224354917";
|
||||
const string intAdId = "ca-app-pub-3966734202864173/1197808629";
|
||||
const string rewardedAdId = "ca-app-pub-3966734202864173/3725853326";
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
@@ -9,7 +9,7 @@ using UnityEngine.Networking;
|
||||
|
||||
public static class DataManager{
|
||||
public const string API_ENDPOINT = "http://vps.playpoolstudios.com/faucet/golf/api/";
|
||||
private const string key = "#2CuV1Bit^S!sW1ZcgRv8BhrO";
|
||||
public const string key = "#2CuV1Bit^S!sW1ZcgRv8BhrO";
|
||||
public static UserData userData{get; private set;}
|
||||
public static List<LeaderboardItemData> Leaderboard{get; private set;}
|
||||
public static bool isLogged{ get{return userData != null;}}
|
||||
@@ -70,6 +70,34 @@ public static class DataManager{
|
||||
|
||||
}
|
||||
|
||||
public static async Task<int> LinkFH(string fhid){
|
||||
WWWForm form = new WWWForm();
|
||||
form.AddField("username", userData.username);
|
||||
form.AddField("fhid", fhid);
|
||||
form.AddField("key", key);
|
||||
|
||||
|
||||
using (UnityWebRequest request = UnityWebRequest.Post(API_ENDPOINT + "link_fh.php", form))
|
||||
{
|
||||
var operation = request.SendWebRequest();
|
||||
while (!operation.isDone)
|
||||
{
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
Debug.Log("fh link response: " +request.downloadHandler.text);
|
||||
|
||||
if(request.downloadHandler.text== "0"){
|
||||
userData.faucetId = int.Parse(fhid);
|
||||
Debug.Log("FH Link success");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static async void GoogleLogin(string username){
|
||||
WWWForm form = new WWWForm();
|
||||
form.AddField("username", username);
|
||||
@@ -211,6 +239,7 @@ public class UserData{
|
||||
public string password;
|
||||
public int score;
|
||||
public int TopScore;
|
||||
public int faucetId;
|
||||
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@@ -10,6 +10,9 @@ public class MainMenu : MonoBehaviour
|
||||
public GameObject MainMenuPanel;
|
||||
public GameObject SettingsPanel;
|
||||
public GameObject LeaderboarPanel;
|
||||
public GameObject LinkAccountPanel;
|
||||
public InputField fhid_input;
|
||||
public Button btnLink;
|
||||
public Transform LeaderboardItemsParent;
|
||||
public float transitionTime;
|
||||
public LeanTweenType transitionEffect;
|
||||
@@ -37,6 +40,8 @@ public class MainMenu : MonoBehaviour
|
||||
copyBtn.onClick.AddListener(CopyId);
|
||||
signoutBtn.onClick.AddListener(SignOut);
|
||||
|
||||
btnLink.onClick.AddListener(OnLinkClicked);
|
||||
|
||||
DataManager.RefreshLeaderboard();
|
||||
}
|
||||
public void Leave(){
|
||||
@@ -75,6 +80,38 @@ public class MainMenu : MonoBehaviour
|
||||
LeanTween.moveX(LeaderboarPanel, 10000, transitionTime).setEase(transitionEffect);
|
||||
}
|
||||
|
||||
public void OpenLinkPanel(){
|
||||
if(DataManager.userData.faucetId > 0){
|
||||
MessageBox.ShowMessage("You've already linked this player account to Faucet Hub.", "Already Linked");
|
||||
return;
|
||||
}
|
||||
|
||||
LinkAccountPanel.transform.localScale = Vector3.zero;
|
||||
LinkAccountPanel.SetActive(true);
|
||||
|
||||
LeanTween.scale(LinkAccountPanel, Vector3.one, transitionTime/2f).setEase(LeanTweenType.easeInCirc);
|
||||
}
|
||||
|
||||
public async void OnLinkClicked(){
|
||||
btnLink.interactable=false;
|
||||
if(fhid_input.text.Length <= 0){
|
||||
Debug.Log("Empty FHID was entered");
|
||||
MessageBox.ShowMessage("Please enter a valid faucet hub ID","Invalid FH ID");
|
||||
return;
|
||||
}
|
||||
|
||||
int result = await DataManager.LinkFH(fhid_input.text);
|
||||
if(result == 0){
|
||||
MessageBox.ShowMessage("Congrats! You've successfully linked this player account with Faucet Hub. Enjoy!", "Success");
|
||||
LinkAccountPanel.SetActive(false);
|
||||
}else{
|
||||
MessageBox.ShowMessage("Something went wrong trying to link this play account to FH ID of " + fhid_input.text, "Link failed");
|
||||
|
||||
}
|
||||
|
||||
btnLink.interactable=true;
|
||||
}
|
||||
|
||||
public void CopyId(){
|
||||
GUIUtility.systemCopyBuffer = txtUserId.text;
|
||||
copyBtn.transform.Find("lbl").GetComponent<Text>().text = "Copied";
|
||||
|
||||
Reference in New Issue
Block a user