Format files
This commit is contained in:
8 files changed
+1534
-1534
No files matched your search
+464
-464
@@ -9,513 +9,513 @@ using UnityEngine.UI;
|
||||
|
||||
public class Account : MonoBehaviour
|
||||
{
|
||||
public GameObject registerPanel;
|
||||
public GameObject registerPanel;
|
||||
|
||||
public Button registerPanelLoginBtn;
|
||||
public Button registerPanelLoginBtn;
|
||||
|
||||
public GameObject loginPanel;
|
||||
public GameObject loginPanel;
|
||||
|
||||
public Button loginPanelRegisterBtn;
|
||||
public Button loginPanelRegisterBtn;
|
||||
|
||||
public GameObject accountPanel;
|
||||
public GameObject accountPanel;
|
||||
|
||||
public Button backButton;
|
||||
public Button backButton;
|
||||
|
||||
public Button accountPanelSyncButton;
|
||||
public Button accountPanelSyncButton;
|
||||
|
||||
public Button accountPanelLogoutButton;
|
||||
public Button accountPanelLogoutButton;
|
||||
|
||||
public TMP_InputField registerPanelUsernameForm;
|
||||
public TMP_InputField registerPanelUsernameForm;
|
||||
|
||||
public TMP_InputField registerPanelEmailForm;
|
||||
public TMP_InputField registerPanelEmailForm;
|
||||
|
||||
public TMP_InputField registerPanelEmailConfirmForm;
|
||||
public TMP_InputField registerPanelEmailConfirmForm;
|
||||
|
||||
public TMP_InputField registerPanelPasswordForm;
|
||||
public TMP_InputField registerPanelPasswordForm;
|
||||
|
||||
public TMP_InputField registerPanelPasswordConfirmForm;
|
||||
public TMP_InputField registerPanelPasswordConfirmForm;
|
||||
|
||||
public TMP_InputField loginPanelUsernameForm;
|
||||
public TMP_InputField loginPanelUsernameForm;
|
||||
|
||||
public TMP_InputField loginPanelPasswordForm;
|
||||
public TMP_InputField loginPanelPasswordForm;
|
||||
|
||||
public TMP_Text registerPanelStatusText;
|
||||
public TMP_Text registerPanelStatusText;
|
||||
|
||||
public TMP_Text loginPanelStatusText;
|
||||
public TMP_Text loginPanelStatusText;
|
||||
|
||||
public TMP_Text accountPanelStatusText;
|
||||
public TMP_Text accountPanelStatusText;
|
||||
|
||||
public GameObject changeUsernamePanel;
|
||||
public GameObject changeUsernamePanel;
|
||||
|
||||
public TMP_Text changeUsernamePanelStatusText;
|
||||
public TMP_Text changeUsernamePanelStatusText;
|
||||
|
||||
public Button submitButton;
|
||||
public Button submitButton;
|
||||
|
||||
public Button changeUsernameButton;
|
||||
public Button changeUsernameButton;
|
||||
|
||||
public Button changePasswordButton;
|
||||
public Button changePasswordButton;
|
||||
|
||||
public GameObject changePasswordPanel;
|
||||
public GameObject changePasswordPanel;
|
||||
|
||||
public TMP_Text changePasswordStatusText;
|
||||
public TMP_Text changePasswordStatusText;
|
||||
|
||||
public TMP_Text changeUsernameStatusText;
|
||||
public TMP_Text changeUsernameStatusText;
|
||||
|
||||
public TMP_InputField changeUsernameCurrentForm;
|
||||
public TMP_InputField changeUsernameCurrentForm;
|
||||
|
||||
public TMP_InputField changeUsernameNewForm;
|
||||
public TMP_InputField changeUsernameNewForm;
|
||||
|
||||
public TMP_InputField changeUsernamePasswordForm;
|
||||
public TMP_InputField changeUsernamePasswordForm;
|
||||
|
||||
public TMP_InputField changePasswordCurrentUsernameForm;
|
||||
public TMP_InputField changePasswordCurrentUsernameForm;
|
||||
|
||||
public TMP_InputField changePasswordCurrentForm;
|
||||
public TMP_InputField changePasswordCurrentForm;
|
||||
|
||||
public TMP_InputField changePasswordNewForm;
|
||||
public TMP_InputField changePasswordNewForm;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (PlayerPrefs.HasKey("gameSession") && PlayerPrefs.HasKey("userID"))
|
||||
{
|
||||
SwitchScene(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchScene(1);
|
||||
}
|
||||
backButton.onClick.AddListener(BackToMenu);
|
||||
registerPanelLoginBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(2);
|
||||
});
|
||||
submitButton.onClick.AddListener(ButtonSubmit);
|
||||
loginPanelRegisterBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(1);
|
||||
});
|
||||
accountPanelSyncButton.onClick.AddListener(StartSyncAccount);
|
||||
accountPanelLogoutButton.onClick.AddListener(LogoutAccount);
|
||||
changeUsernameButton.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(3);
|
||||
});
|
||||
changePasswordButton.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(4);
|
||||
});
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
if (PlayerPrefs.HasKey("gameSession") && PlayerPrefs.HasKey("userID"))
|
||||
{
|
||||
SwitchScene(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchScene(1);
|
||||
}
|
||||
backButton.onClick.AddListener(BackToMenu);
|
||||
registerPanelLoginBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(2);
|
||||
});
|
||||
submitButton.onClick.AddListener(ButtonSubmit);
|
||||
loginPanelRegisterBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(1);
|
||||
});
|
||||
accountPanelSyncButton.onClick.AddListener(StartSyncAccount);
|
||||
accountPanelLogoutButton.onClick.AddListener(LogoutAccount);
|
||||
changeUsernameButton.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(3);
|
||||
});
|
||||
changePasswordButton.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(4);
|
||||
});
|
||||
}
|
||||
|
||||
private void BackToMenu()
|
||||
{
|
||||
if (GetCurrentScene() == 3 || GetCurrentScene() == 4)
|
||||
{
|
||||
SwitchScene(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
}
|
||||
private void BackToMenu()
|
||||
{
|
||||
if (GetCurrentScene() == 3 || GetCurrentScene() == 4)
|
||||
{
|
||||
SwitchScene(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
}
|
||||
|
||||
private int GetCurrentScene()
|
||||
{
|
||||
if (accountPanel.activeSelf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (registerPanel.activeSelf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (loginPanel.activeSelf)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (changeUsernamePanel.activeSelf)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (changePasswordPanel.activeSelf)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
private int GetCurrentScene()
|
||||
{
|
||||
if (accountPanel.activeSelf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (registerPanel.activeSelf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (loginPanel.activeSelf)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (changeUsernamePanel.activeSelf)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (changePasswordPanel.activeSelf)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void ButtonSubmit()
|
||||
{
|
||||
if (GetCurrentScene() == 1)
|
||||
{
|
||||
StartCoroutine(SubmitRegister());
|
||||
}
|
||||
else if (GetCurrentScene() == 2)
|
||||
{
|
||||
StartCoroutine(SubmitLogin());
|
||||
}
|
||||
else if (GetCurrentScene() == 3)
|
||||
{
|
||||
StartCoroutine(ChangeUsername());
|
||||
}
|
||||
else if (GetCurrentScene() == 4)
|
||||
{
|
||||
StartCoroutine(ChangePassword());
|
||||
}
|
||||
}
|
||||
private void ButtonSubmit()
|
||||
{
|
||||
if (GetCurrentScene() == 1)
|
||||
{
|
||||
StartCoroutine(SubmitRegister());
|
||||
}
|
||||
else if (GetCurrentScene() == 2)
|
||||
{
|
||||
StartCoroutine(SubmitLogin());
|
||||
}
|
||||
else if (GetCurrentScene() == 3)
|
||||
{
|
||||
StartCoroutine(ChangeUsername());
|
||||
}
|
||||
else if (GetCurrentScene() == 4)
|
||||
{
|
||||
StartCoroutine(ChangePassword());
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchScene(int scene)
|
||||
{
|
||||
ClearForms();
|
||||
backButton.transform.localPosition = new Vector3(0f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(90f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(110f, -165f, 0f);
|
||||
submitButton.gameObject.SetActive(value: true);
|
||||
accountPanel.SetActive(value: false);
|
||||
registerPanel.SetActive(value: false);
|
||||
loginPanel.SetActive(value: false);
|
||||
changeUsernamePanel.SetActive(value: false);
|
||||
changePasswordPanel.SetActive(value: false);
|
||||
registerPanelStatusText.text = "";
|
||||
loginPanelStatusText.text = "";
|
||||
accountPanelStatusText.text = "";
|
||||
changeUsernamePanelStatusText.text = "";
|
||||
changePasswordStatusText.text = "";
|
||||
changeUsernameStatusText.text = "";
|
||||
registerPanelStatusText.color = Color.white;
|
||||
loginPanelStatusText.color = Color.white;
|
||||
accountPanelStatusText.color = Color.white;
|
||||
changeUsernamePanelStatusText.color = Color.white;
|
||||
changePasswordStatusText.color = Color.white;
|
||||
changeUsernameStatusText.color = Color.white;
|
||||
accountPanelSyncButton.interactable = true;
|
||||
switch (scene)
|
||||
{
|
||||
case 0:
|
||||
accountPanel.SetActive(value: true);
|
||||
submitButton.gameObject.SetActive(value: false);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
break;
|
||||
case 1:
|
||||
registerPanel.SetActive(value: true);
|
||||
break;
|
||||
case 2:
|
||||
loginPanel.SetActive(value: true);
|
||||
break;
|
||||
case 3:
|
||||
changeUsernamePanel.SetActive(value: true);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(60f, -165f, 0f);
|
||||
break;
|
||||
case 4:
|
||||
changePasswordPanel.SetActive(value: true);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(60f, -165f, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void SwitchScene(int scene)
|
||||
{
|
||||
ClearForms();
|
||||
backButton.transform.localPosition = new Vector3(0f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(90f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(110f, -165f, 0f);
|
||||
submitButton.gameObject.SetActive(value: true);
|
||||
accountPanel.SetActive(value: false);
|
||||
registerPanel.SetActive(value: false);
|
||||
loginPanel.SetActive(value: false);
|
||||
changeUsernamePanel.SetActive(value: false);
|
||||
changePasswordPanel.SetActive(value: false);
|
||||
registerPanelStatusText.text = "";
|
||||
loginPanelStatusText.text = "";
|
||||
accountPanelStatusText.text = "";
|
||||
changeUsernamePanelStatusText.text = "";
|
||||
changePasswordStatusText.text = "";
|
||||
changeUsernameStatusText.text = "";
|
||||
registerPanelStatusText.color = Color.white;
|
||||
loginPanelStatusText.color = Color.white;
|
||||
accountPanelStatusText.color = Color.white;
|
||||
changeUsernamePanelStatusText.color = Color.white;
|
||||
changePasswordStatusText.color = Color.white;
|
||||
changeUsernameStatusText.color = Color.white;
|
||||
accountPanelSyncButton.interactable = true;
|
||||
switch (scene)
|
||||
{
|
||||
case 0:
|
||||
accountPanel.SetActive(value: true);
|
||||
submitButton.gameObject.SetActive(value: false);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
break;
|
||||
case 1:
|
||||
registerPanel.SetActive(value: true);
|
||||
break;
|
||||
case 2:
|
||||
loginPanel.SetActive(value: true);
|
||||
break;
|
||||
case 3:
|
||||
changeUsernamePanel.SetActive(value: true);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(60f, -165f, 0f);
|
||||
break;
|
||||
case 4:
|
||||
changePasswordPanel.SetActive(value: true);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(60f, -165f, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SubmitRegister()
|
||||
{
|
||||
if (!registerPanelEmailForm.text.Trim().Equals(registerPanelEmailConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Email doesn't match", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (!registerPanelPasswordForm.text.Trim().Equals(registerPanelPasswordConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Password doesn't match", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (!Regex.IsMatch(registerPanelUsernameForm.text, "^[a-zA-Z0-9]{3,16}$"))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
yield break;
|
||||
}
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", registerPanelUsernameForm.text);
|
||||
wWWForm.AddField("email", registerPanelEmailForm.text);
|
||||
wWWForm.AddField("password", registerPanelPasswordForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/registerAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(registerPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
SwitchScene(2);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(registerPanelStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
UpdateStatusText(registerPanelStatusText, "Incomplete form data", Color.red);
|
||||
break;
|
||||
case "-3":
|
||||
UpdateStatusText(registerPanelStatusText, "Username not valid", Color.red);
|
||||
break;
|
||||
case "-4":
|
||||
UpdateStatusText(registerPanelStatusText, "Email not valid", Color.red);
|
||||
break;
|
||||
case "-5":
|
||||
UpdateStatusText(registerPanelStatusText, "Password must have 8 characters, one number and one letter", Color.red);
|
||||
break;
|
||||
case "-6":
|
||||
UpdateStatusText(registerPanelStatusText, "Username too long or short", Color.red);
|
||||
break;
|
||||
case "-7":
|
||||
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
break;
|
||||
case "-8":
|
||||
UpdateStatusText(registerPanelStatusText, "Username or email already exists", Color.red);
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(registerPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private IEnumerator SubmitRegister()
|
||||
{
|
||||
if (!registerPanelEmailForm.text.Trim().Equals(registerPanelEmailConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Email doesn't match", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (!registerPanelPasswordForm.text.Trim().Equals(registerPanelPasswordConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Password doesn't match", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (!Regex.IsMatch(registerPanelUsernameForm.text, "^[a-zA-Z0-9]{3,16}$"))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
yield break;
|
||||
}
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", registerPanelUsernameForm.text);
|
||||
wWWForm.AddField("email", registerPanelEmailForm.text);
|
||||
wWWForm.AddField("password", registerPanelPasswordForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/registerAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(registerPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
SwitchScene(2);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(registerPanelStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
UpdateStatusText(registerPanelStatusText, "Incomplete form data", Color.red);
|
||||
break;
|
||||
case "-3":
|
||||
UpdateStatusText(registerPanelStatusText, "Username not valid", Color.red);
|
||||
break;
|
||||
case "-4":
|
||||
UpdateStatusText(registerPanelStatusText, "Email not valid", Color.red);
|
||||
break;
|
||||
case "-5":
|
||||
UpdateStatusText(registerPanelStatusText, "Password must have 8 characters, one number and one letter", Color.red);
|
||||
break;
|
||||
case "-6":
|
||||
UpdateStatusText(registerPanelStatusText, "Username too long or short", Color.red);
|
||||
break;
|
||||
case "-7":
|
||||
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
break;
|
||||
case "-8":
|
||||
UpdateStatusText(registerPanelStatusText, "Username or email already exists", Color.red);
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(registerPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SubmitLogin()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", loginPanelUsernameForm.text);
|
||||
wWWForm.AddField("password", loginPanelPasswordForm.text);
|
||||
wWWForm.AddField("currentHighScore", PlayerPrefs.GetInt("HighScore", 0).ToString());
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/loginAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(loginPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
if (!(text == "-1"))
|
||||
{
|
||||
if (text == "-2")
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red);
|
||||
}
|
||||
else if (Regex.IsMatch(text, "^[a-zA-Z0-9]{512}:\\d+:\\d+:\\d+:\\d+$"))
|
||||
{
|
||||
string[] array = text.Split(':');
|
||||
string value = array[0];
|
||||
int value2 = int.Parse(array[1]);
|
||||
int value3 = int.Parse(array[2]);
|
||||
int value4 = int.Parse(array[3]);
|
||||
int value5 = int.Parse(array[4]);
|
||||
PlayerPrefs.SetString("gameSession", value);
|
||||
PlayerPrefs.SetInt("userID", value2);
|
||||
PlayerPrefs.SetInt("HighScore", value3);
|
||||
PlayerPrefs.SetInt("icon", value4);
|
||||
PlayerPrefs.SetInt("overlay", value5);
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(loginPanelStatusText, "", Color.red);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Internal login server error", Color.red);
|
||||
}
|
||||
}
|
||||
private IEnumerator SubmitLogin()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", loginPanelUsernameForm.text);
|
||||
wWWForm.AddField("password", loginPanelPasswordForm.text);
|
||||
wWWForm.AddField("currentHighScore", PlayerPrefs.GetInt("HighScore", 0).ToString());
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/loginAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(loginPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
if (!(text == "-1"))
|
||||
{
|
||||
if (text == "-2")
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red);
|
||||
}
|
||||
else if (Regex.IsMatch(text, "^[a-zA-Z0-9]{512}:\\d+:\\d+:\\d+:\\d+$"))
|
||||
{
|
||||
string[] array = text.Split(':');
|
||||
string value = array[0];
|
||||
int value2 = int.Parse(array[1]);
|
||||
int value3 = int.Parse(array[2]);
|
||||
int value4 = int.Parse(array[3]);
|
||||
int value5 = int.Parse(array[4]);
|
||||
PlayerPrefs.SetString("gameSession", value);
|
||||
PlayerPrefs.SetInt("userID", value2);
|
||||
PlayerPrefs.SetInt("HighScore", value3);
|
||||
PlayerPrefs.SetInt("icon", value4);
|
||||
PlayerPrefs.SetInt("overlay", value5);
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(loginPanelStatusText, "", Color.red);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Internal login server error", Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ChangeUsername()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", changeUsernameCurrentForm.text);
|
||||
wWWForm.AddField("currentPassword", changeUsernamePasswordForm.text);
|
||||
wWWForm.AddField("newUsername", changeUsernameNewForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/changeAccountUsername.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(changeUsernameStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(accountPanelStatusText, "Username changed successfully", Color.green);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(changeUsernameStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username, Password, or old username is empty", Color.red);
|
||||
break;
|
||||
case "-3":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username contains invalid characters", Color.red);
|
||||
break;
|
||||
case "-4":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username is too short or too long", Color.red);
|
||||
break;
|
||||
case "-5":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username does not match the required format", Color.red);
|
||||
break;
|
||||
case "-6":
|
||||
UpdateStatusText(changeUsernameStatusText, "Incorrect current password", Color.red);
|
||||
break;
|
||||
case "-7":
|
||||
UpdateStatusText(changeUsernameStatusText, "Current username is incorrect", Color.red);
|
||||
break;
|
||||
case "-8":
|
||||
UpdateStatusText(changeUsernameStatusText, "New username already exists", Color.red);
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(changeUsernameStatusText, "Unknown server response", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private IEnumerator ChangeUsername()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", changeUsernameCurrentForm.text);
|
||||
wWWForm.AddField("currentPassword", changeUsernamePasswordForm.text);
|
||||
wWWForm.AddField("newUsername", changeUsernameNewForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/changeAccountUsername.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(changeUsernameStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(accountPanelStatusText, "Username changed successfully", Color.green);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(changeUsernameStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username, Password, or old username is empty", Color.red);
|
||||
break;
|
||||
case "-3":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username contains invalid characters", Color.red);
|
||||
break;
|
||||
case "-4":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username is too short or too long", Color.red);
|
||||
break;
|
||||
case "-5":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username does not match the required format", Color.red);
|
||||
break;
|
||||
case "-6":
|
||||
UpdateStatusText(changeUsernameStatusText, "Incorrect current password", Color.red);
|
||||
break;
|
||||
case "-7":
|
||||
UpdateStatusText(changeUsernameStatusText, "Current username is incorrect", Color.red);
|
||||
break;
|
||||
case "-8":
|
||||
UpdateStatusText(changeUsernameStatusText, "New username already exists", Color.red);
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(changeUsernameStatusText, "Unknown server response", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ChangePassword()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", changePasswordCurrentUsernameForm.text);
|
||||
wWWForm.AddField("currentPassword", changePasswordCurrentForm.text);
|
||||
wWWForm.AddField("newPassword", changePasswordNewForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/changeAccountPassword.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(changePasswordStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "-1":
|
||||
UpdateStatusText(changePasswordStatusText, "Internal login server error", Color.red);
|
||||
yield break;
|
||||
case "-2":
|
||||
UpdateStatusText(changePasswordStatusText, "New Password, Password, or username is empty", Color.red);
|
||||
yield break;
|
||||
case "-3":
|
||||
UpdateStatusText(changePasswordStatusText, "New Password is too short or too long", Color.red);
|
||||
yield break;
|
||||
case "-4":
|
||||
UpdateStatusText(changePasswordStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
yield break;
|
||||
case "-5":
|
||||
UpdateStatusText(changePasswordStatusText, "Incorrect current password", Color.red);
|
||||
yield break;
|
||||
case "-6":
|
||||
UpdateStatusText(changePasswordStatusText, "Current username is incorrect", Color.red);
|
||||
yield break;
|
||||
case "-7":
|
||||
UpdateStatusText(changePasswordStatusText, "New password cannot be the same as your old password", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (Regex.IsMatch(text, "^[a-zA-Z0-9]{512}$"))
|
||||
{
|
||||
PlayerPrefs.SetString("gameSession", text);
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(accountPanelStatusText, "Password changed successfully", Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(accountPanelStatusText, "Unknown server response", Color.red);
|
||||
}
|
||||
}
|
||||
private IEnumerator ChangePassword()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", changePasswordCurrentUsernameForm.text);
|
||||
wWWForm.AddField("currentPassword", changePasswordCurrentForm.text);
|
||||
wWWForm.AddField("newPassword", changePasswordNewForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/changeAccountPassword.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(changePasswordStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "-1":
|
||||
UpdateStatusText(changePasswordStatusText, "Internal login server error", Color.red);
|
||||
yield break;
|
||||
case "-2":
|
||||
UpdateStatusText(changePasswordStatusText, "New Password, Password, or username is empty", Color.red);
|
||||
yield break;
|
||||
case "-3":
|
||||
UpdateStatusText(changePasswordStatusText, "New Password is too short or too long", Color.red);
|
||||
yield break;
|
||||
case "-4":
|
||||
UpdateStatusText(changePasswordStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
yield break;
|
||||
case "-5":
|
||||
UpdateStatusText(changePasswordStatusText, "Incorrect current password", Color.red);
|
||||
yield break;
|
||||
case "-6":
|
||||
UpdateStatusText(changePasswordStatusText, "Current username is incorrect", Color.red);
|
||||
yield break;
|
||||
case "-7":
|
||||
UpdateStatusText(changePasswordStatusText, "New password cannot be the same as your old password", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (Regex.IsMatch(text, "^[a-zA-Z0-9]{512}$"))
|
||||
{
|
||||
PlayerPrefs.SetString("gameSession", text);
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(accountPanelStatusText, "Password changed successfully", Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(accountPanelStatusText, "Unknown server response", Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearForms()
|
||||
{
|
||||
registerPanelUsernameForm.text = "";
|
||||
registerPanelEmailForm.text = "";
|
||||
registerPanelEmailConfirmForm.text = "";
|
||||
registerPanelPasswordForm.text = "";
|
||||
registerPanelPasswordConfirmForm.text = "";
|
||||
loginPanelUsernameForm.text = "";
|
||||
loginPanelPasswordForm.text = "";
|
||||
changeUsernameNewForm.text = "";
|
||||
changeUsernamePasswordForm.text = "";
|
||||
changePasswordCurrentForm.text = "";
|
||||
changePasswordNewForm.text = "";
|
||||
changePasswordCurrentUsernameForm.text = "";
|
||||
changeUsernameCurrentForm.text = "";
|
||||
}
|
||||
private void ClearForms()
|
||||
{
|
||||
registerPanelUsernameForm.text = "";
|
||||
registerPanelEmailForm.text = "";
|
||||
registerPanelEmailConfirmForm.text = "";
|
||||
registerPanelPasswordForm.text = "";
|
||||
registerPanelPasswordConfirmForm.text = "";
|
||||
loginPanelUsernameForm.text = "";
|
||||
loginPanelPasswordForm.text = "";
|
||||
changeUsernameNewForm.text = "";
|
||||
changeUsernamePasswordForm.text = "";
|
||||
changePasswordCurrentForm.text = "";
|
||||
changePasswordNewForm.text = "";
|
||||
changePasswordCurrentUsernameForm.text = "";
|
||||
changeUsernameCurrentForm.text = "";
|
||||
}
|
||||
|
||||
private IEnumerator SyncAccount()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("userID", PlayerPrefs.GetInt("userID", 0).ToString());
|
||||
wWWForm.AddField("gameSession", PlayerPrefs.GetString("gameSession", ""));
|
||||
wWWForm.AddField("highScore", PlayerPrefs.GetInt("HighScore", 0).ToString());
|
||||
wWWForm.AddField("icon", PlayerPrefs.GetInt("icon", 1).ToString());
|
||||
wWWForm.AddField("overlay", PlayerPrefs.GetInt("overlay", 0).ToString());
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/syncAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(accountPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
accountPanelSyncButton.interactable = false;
|
||||
UpdateStatusText(accountPanelStatusText, "Synced account", Color.green);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(accountPanelStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
LogoutAccount();
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(accountPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private IEnumerator SyncAccount()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("userID", PlayerPrefs.GetInt("userID", 0).ToString());
|
||||
wWWForm.AddField("gameSession", PlayerPrefs.GetString("gameSession", ""));
|
||||
wWWForm.AddField("highScore", PlayerPrefs.GetInt("HighScore", 0).ToString());
|
||||
wWWForm.AddField("icon", PlayerPrefs.GetInt("icon", 1).ToString());
|
||||
wWWForm.AddField("overlay", PlayerPrefs.GetInt("overlay", 0).ToString());
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/syncAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(accountPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
accountPanelSyncButton.interactable = false;
|
||||
UpdateStatusText(accountPanelStatusText, "Synced account", Color.green);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(accountPanelStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
LogoutAccount();
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(accountPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void StartSyncAccount()
|
||||
{
|
||||
StartCoroutine(SyncAccount());
|
||||
}
|
||||
private void StartSyncAccount()
|
||||
{
|
||||
StartCoroutine(SyncAccount());
|
||||
}
|
||||
|
||||
private void LogoutAccount()
|
||||
{
|
||||
PlayerPrefs.DeleteKey("userID");
|
||||
PlayerPrefs.DeleteKey("gameSession");
|
||||
PlayerPrefs.SetInt("HighScore", 0);
|
||||
PlayerPrefs.SetInt("icon", 1);
|
||||
PlayerPrefs.SetInt("overlay", 0);
|
||||
SwitchScene(1);
|
||||
}
|
||||
private void LogoutAccount()
|
||||
{
|
||||
PlayerPrefs.DeleteKey("userID");
|
||||
PlayerPrefs.DeleteKey("gameSession");
|
||||
PlayerPrefs.SetInt("HighScore", 0);
|
||||
PlayerPrefs.SetInt("icon", 1);
|
||||
PlayerPrefs.SetInt("overlay", 0);
|
||||
SwitchScene(1);
|
||||
}
|
||||
|
||||
private void UpdateStatusText(TMP_Text text, string message, Color color)
|
||||
{
|
||||
text.text = message;
|
||||
text.color = color;
|
||||
}
|
||||
private void UpdateStatusText(TMP_Text text, string message, Color color)
|
||||
{
|
||||
text.text = message;
|
||||
text.color = color;
|
||||
}
|
||||
}
|
||||
+591
-591
File diff suppressed because it is too large.
Load diff
+171
-171
@@ -5,206 +5,206 @@ using UnityEngine.UI;
|
||||
|
||||
public class Iconkit : MonoBehaviour
|
||||
{
|
||||
public GameObject panel;
|
||||
public GameObject panel;
|
||||
|
||||
public GameObject iconSelectionPanel;
|
||||
public GameObject iconSelectionPanel;
|
||||
|
||||
public GameObject overlaySelectionPanel;
|
||||
public GameObject overlaySelectionPanel;
|
||||
|
||||
public Button backButton;
|
||||
public Button backButton;
|
||||
|
||||
public Image defaultIcon;
|
||||
public Image defaultIcon;
|
||||
|
||||
public Button placeholderButton;
|
||||
public Button placeholderButton;
|
||||
|
||||
public TMP_Text selectionText;
|
||||
public TMP_Text selectionText;
|
||||
|
||||
public Image previewBird;
|
||||
public Image previewBird;
|
||||
|
||||
public Image previewOverlay;
|
||||
public Image previewOverlay;
|
||||
|
||||
public Image overlay0;
|
||||
public Image overlay0;
|
||||
|
||||
public Image overlay1;
|
||||
public Image overlay1;
|
||||
|
||||
public Image overlay2;
|
||||
public Image overlay2;
|
||||
|
||||
public Image overlay3;
|
||||
public Image overlay3;
|
||||
|
||||
public Image overlay4;
|
||||
public Image overlay4;
|
||||
|
||||
public Image overlay5;
|
||||
public Image overlay5;
|
||||
|
||||
public Image overlay6;
|
||||
public Image overlay6;
|
||||
|
||||
public Image overlay7;
|
||||
public Image overlay7;
|
||||
|
||||
public Image overlay8;
|
||||
public Image overlay8;
|
||||
|
||||
public Image overlay9;
|
||||
public Image overlay9;
|
||||
|
||||
public Image icon1;
|
||||
public Image icon1;
|
||||
|
||||
public Image icon2;
|
||||
public Image icon2;
|
||||
|
||||
public Image icon3;
|
||||
public Image icon3;
|
||||
|
||||
public Image icon4;
|
||||
public Image icon4;
|
||||
|
||||
public GameObject previewBirdObject;
|
||||
public GameObject previewBirdObject;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SwitchToIcon();
|
||||
SelectOverlay(PlayerPrefs.GetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9)));
|
||||
SelectIcon(PlayerPrefs.GetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4)));
|
||||
if (PlayerPrefs.GetInt("userID", 0) == 1)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 2)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 4)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
placeholderButton.onClick.AddListener(ToggleKit);
|
||||
backButton.onClick.AddListener(delegate
|
||||
{
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene("Menu");
|
||||
});
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
SwitchToIcon();
|
||||
SelectOverlay(PlayerPrefs.GetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9)));
|
||||
SelectIcon(PlayerPrefs.GetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4)));
|
||||
if (PlayerPrefs.GetInt("userID", 0) == 1)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 2)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 4)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
placeholderButton.onClick.AddListener(ToggleKit);
|
||||
backButton.onClick.AddListener(delegate
|
||||
{
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene("Menu");
|
||||
});
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!Input.GetMouseButtonDown(0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector2 screenPoint = Input.mousePosition;
|
||||
Image[] array = new Image[10] { overlay0, overlay1, overlay2, overlay3, overlay4, overlay5, overlay6, overlay7, overlay8, overlay9 };
|
||||
Image[] array2 = new Image[4] { icon1, icon2, icon3, icon4 };
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(array[i].rectTransform, screenPoint) && array[i].IsActive())
|
||||
{
|
||||
SelectOverlay(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < array2.Length; j++)
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(array2[j].rectTransform, screenPoint) && array2[j].IsActive())
|
||||
{
|
||||
SelectIcon(j + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(previewBirdObject.GetComponent<RectTransform>(), screenPoint))
|
||||
{
|
||||
float x = previewBirdObject.transform.localScale.x;
|
||||
previewBirdObject.transform.localScale = new Vector3((x != 1f) ? 1 : (-1), 1f, 1f);
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (!Input.GetMouseButtonDown(0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector2 screenPoint = Input.mousePosition;
|
||||
Image[] array = new Image[10] { overlay0, overlay1, overlay2, overlay3, overlay4, overlay5, overlay6, overlay7, overlay8, overlay9 };
|
||||
Image[] array2 = new Image[4] { icon1, icon2, icon3, icon4 };
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(array[i].rectTransform, screenPoint) && array[i].IsActive())
|
||||
{
|
||||
SelectOverlay(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < array2.Length; j++)
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(array2[j].rectTransform, screenPoint) && array2[j].IsActive())
|
||||
{
|
||||
SelectIcon(j + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(previewBirdObject.GetComponent<RectTransform>(), screenPoint))
|
||||
{
|
||||
float x = previewBirdObject.transform.localScale.x;
|
||||
previewBirdObject.transform.localScale = new Vector3((x != 1f) ? 1 : (-1), 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchToIcon()
|
||||
{
|
||||
iconSelectionPanel.SetActive(value: true);
|
||||
overlaySelectionPanel.SetActive(value: false);
|
||||
selectionText.text = "Icon selection";
|
||||
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Overlays";
|
||||
}
|
||||
private void SwitchToIcon()
|
||||
{
|
||||
iconSelectionPanel.SetActive(value: true);
|
||||
overlaySelectionPanel.SetActive(value: false);
|
||||
selectionText.text = "Icon selection";
|
||||
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Overlays";
|
||||
}
|
||||
|
||||
private void SwitchToOverlay()
|
||||
{
|
||||
iconSelectionPanel.SetActive(value: false);
|
||||
overlaySelectionPanel.SetActive(value: true);
|
||||
selectionText.text = "Overlay selection";
|
||||
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Icons";
|
||||
}
|
||||
private void SwitchToOverlay()
|
||||
{
|
||||
iconSelectionPanel.SetActive(value: false);
|
||||
overlaySelectionPanel.SetActive(value: true);
|
||||
selectionText.text = "Overlay selection";
|
||||
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Icons";
|
||||
}
|
||||
|
||||
private void ToggleKit()
|
||||
{
|
||||
if (GetCurrentKit() == 1)
|
||||
{
|
||||
SwitchToOverlay();
|
||||
}
|
||||
else if (GetCurrentKit() == 2)
|
||||
{
|
||||
SwitchToIcon();
|
||||
}
|
||||
}
|
||||
private void ToggleKit()
|
||||
{
|
||||
if (GetCurrentKit() == 1)
|
||||
{
|
||||
SwitchToOverlay();
|
||||
}
|
||||
else if (GetCurrentKit() == 2)
|
||||
{
|
||||
SwitchToIcon();
|
||||
}
|
||||
}
|
||||
|
||||
private int GetCurrentKit()
|
||||
{
|
||||
if (iconSelectionPanel.activeSelf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (overlaySelectionPanel.activeSelf)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private int GetCurrentKit()
|
||||
{
|
||||
if (iconSelectionPanel.activeSelf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (overlaySelectionPanel.activeSelf)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void SelectIcon(int iconID)
|
||||
{
|
||||
PlayerPrefs.SetInt("icon", iconID);
|
||||
Image[] array = new Image[4] { icon1, icon2, icon3, icon4 };
|
||||
Color32 color = new Color32(70, 70, 70, byte.MaxValue);
|
||||
Color32 color2 = new Color32(100, 100, 100, byte.MaxValue);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i].color = ((iconID == i + 1) ? color : color2);
|
||||
}
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_" + iconID);
|
||||
if (iconID == 1)
|
||||
{
|
||||
if (PlayerPrefs.GetInt("userID", 0) == 1)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 2)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 4)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SelectIcon(int iconID)
|
||||
{
|
||||
PlayerPrefs.SetInt("icon", iconID);
|
||||
Image[] array = new Image[4] { icon1, icon2, icon3, icon4 };
|
||||
Color32 color = new Color32(70, 70, 70, byte.MaxValue);
|
||||
Color32 color2 = new Color32(100, 100, 100, byte.MaxValue);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i].color = ((iconID == i + 1) ? color : color2);
|
||||
}
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_" + iconID);
|
||||
if (iconID == 1)
|
||||
{
|
||||
if (PlayerPrefs.GetInt("userID", 0) == 1)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 2)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 4)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectOverlay(int overlayID)
|
||||
{
|
||||
PlayerPrefs.SetInt("overlay", overlayID);
|
||||
Image[] array = new Image[10] { overlay0, overlay1, overlay2, overlay3, overlay4, overlay5, overlay6, overlay7, overlay8, overlay9 };
|
||||
Color32 color = new Color32(70, 70, 70, byte.MaxValue);
|
||||
Color32 color2 = new Color32(100, 100, 100, byte.MaxValue);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i].color = ((overlayID == i) ? color : color2);
|
||||
}
|
||||
previewOverlay.rectTransform.localPosition = new Vector3(-19f, 28f, 0f);
|
||||
previewOverlay.gameObject.SetActive(value: true);
|
||||
if (overlayID == 8)
|
||||
{
|
||||
previewOverlay.rectTransform.localPosition = new Vector3(-22f, 20f, 0f);
|
||||
}
|
||||
if (overlayID == 0)
|
||||
{
|
||||
previewOverlay.gameObject.SetActive(value: false);
|
||||
previewOverlay.sprite = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
previewOverlay.sprite = Resources.Load<Sprite>("icons/overlays/overlay_" + overlayID);
|
||||
}
|
||||
}
|
||||
private void SelectOverlay(int overlayID)
|
||||
{
|
||||
PlayerPrefs.SetInt("overlay", overlayID);
|
||||
Image[] array = new Image[10] { overlay0, overlay1, overlay2, overlay3, overlay4, overlay5, overlay6, overlay7, overlay8, overlay9 };
|
||||
Color32 color = new Color32(70, 70, 70, byte.MaxValue);
|
||||
Color32 color2 = new Color32(100, 100, 100, byte.MaxValue);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i].color = ((overlayID == i) ? color : color2);
|
||||
}
|
||||
previewOverlay.rectTransform.localPosition = new Vector3(-19f, 28f, 0f);
|
||||
previewOverlay.gameObject.SetActive(value: true);
|
||||
if (overlayID == 8)
|
||||
{
|
||||
previewOverlay.rectTransform.localPosition = new Vector3(-22f, 20f, 0f);
|
||||
}
|
||||
if (overlayID == 0)
|
||||
{
|
||||
previewOverlay.gameObject.SetActive(value: false);
|
||||
previewOverlay.sprite = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
previewOverlay.sprite = Resources.Load<Sprite>("icons/overlays/overlay_" + overlayID);
|
||||
}
|
||||
}
|
||||
}
|
||||
+143
-143
@@ -8,158 +8,158 @@ using UnityEngine.UI;
|
||||
|
||||
public class Leaderboard : MonoBehaviour
|
||||
{
|
||||
public Canvas canvas;
|
||||
public Canvas canvas;
|
||||
|
||||
public ScrollRect scrollRect;
|
||||
public ScrollRect scrollRect;
|
||||
|
||||
public GameObject content;
|
||||
public GameObject content;
|
||||
|
||||
public TMP_Dropdown showAmount;
|
||||
public TMP_Dropdown showAmount;
|
||||
|
||||
public TMP_Text statusText;
|
||||
public TMP_Text statusText;
|
||||
|
||||
public TMP_FontAsset font;
|
||||
public TMP_FontAsset font;
|
||||
|
||||
public Button backButton;
|
||||
public Button backButton;
|
||||
|
||||
public Button refreshButton;
|
||||
public Button refreshButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
scrollRect.normalizedPosition = new Vector2(0f, 1f);
|
||||
UpdateStatus(enabled: true, "Loading...");
|
||||
StartCoroutine(GetTopPlayers(0));
|
||||
showAmount.onValueChanged.AddListener(delegate(int value)
|
||||
{
|
||||
StartCoroutine(RefreshLeaderboard(value));
|
||||
});
|
||||
backButton.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
});
|
||||
refreshButton.onClick.AddListener(delegate
|
||||
{
|
||||
StartCoroutine(RefreshLeaderboard(showAmount.value));
|
||||
});
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
scrollRect.normalizedPosition = new Vector2(0f, 1f);
|
||||
UpdateStatus(enabled: true, "Loading...");
|
||||
StartCoroutine(GetTopPlayers(0));
|
||||
showAmount.onValueChanged.AddListener(delegate (int value)
|
||||
{
|
||||
StartCoroutine(RefreshLeaderboard(value));
|
||||
});
|
||||
backButton.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
});
|
||||
refreshButton.onClick.AddListener(delegate
|
||||
{
|
||||
StartCoroutine(RefreshLeaderboard(showAmount.value));
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerator RefreshLeaderboard(int value)
|
||||
{
|
||||
int childCount = content.transform.childCount;
|
||||
GameObject[] entries = new GameObject[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
entries[i] = content.transform.GetChild(i).gameObject;
|
||||
}
|
||||
yield return StartCoroutine(GetTopPlayers(value));
|
||||
for (int j = 0; j < entries.Length; j++)
|
||||
{
|
||||
UnityEngine.Object.Destroy(entries[j]);
|
||||
}
|
||||
}
|
||||
private IEnumerator RefreshLeaderboard(int value)
|
||||
{
|
||||
int childCount = content.transform.childCount;
|
||||
GameObject[] entries = new GameObject[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
entries[i] = content.transform.GetChild(i).gameObject;
|
||||
}
|
||||
yield return StartCoroutine(GetTopPlayers(value));
|
||||
for (int j = 0; j < entries.Length; j++)
|
||||
{
|
||||
UnityEngine.Object.Destroy(entries[j]);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator GetTopPlayers(int showAmount)
|
||||
{
|
||||
Debug.Log(showAmount);
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("showAmount", showAmount);
|
||||
UnityWebRequest request = UnityWebRequest.Post("https://berrydash.lncvrt.xyz/database/getTopPlayers.php", wWWForm);
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", "1.3-beta2");
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
UpdateStatus();
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
string[] array = text.Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int num = array.Length / 5;
|
||||
float num2 = 40f;
|
||||
float num3 = 10f;
|
||||
float num4 = content.GetComponent<RectTransform>().rect.height / 2f;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
GameObject gameObject = new GameObject("Entry_" + i, typeof(RectTransform), typeof(CanvasRenderer));
|
||||
RectTransform component = gameObject.GetComponent<RectTransform>();
|
||||
component.sizeDelta = new Vector2(600f, num2);
|
||||
component.anchoredPosition = new Vector2(0f, num4 - (float)i * (num2 + num3));
|
||||
component.anchorMin = new Vector2(0.5f, 1f);
|
||||
component.anchorMax = new Vector2(0.5f, 1f);
|
||||
component.pivot = new Vector2(0.5f, 1f);
|
||||
GameObject gameObject2 = new GameObject("PlayerName", typeof(RectTransform), typeof(TextMeshProUGUI));
|
||||
GameObject gameObject3 = new GameObject("PlayerIcon", typeof(RectTransform), typeof(Image));
|
||||
GameObject gameObject4 = new GameObject("PlayerIconOverlay", typeof(RectTransform), typeof(Image));
|
||||
GameObject obj = new GameObject("Score", typeof(RectTransform), typeof(TextMeshProUGUI));
|
||||
gameObject2.transform.SetParent(gameObject.transform, worldPositionStays: false);
|
||||
gameObject3.transform.SetParent(gameObject2.transform, worldPositionStays: false);
|
||||
gameObject4.transform.SetParent(gameObject3.transform, worldPositionStays: false);
|
||||
obj.transform.SetParent(gameObject.transform, worldPositionStays: false);
|
||||
Image component2 = gameObject3.GetComponent<Image>();
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_" + array[i * 5 + 2]);
|
||||
if (array[i * 5 + 2] == "1")
|
||||
{
|
||||
if (array[i * 5 + 4] == "1")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (array[i * 5 + 4] == "2")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (array[i * 5 + 4] == "4")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
}
|
||||
component2.rectTransform.sizeDelta = new Vector2(30f, 30f);
|
||||
component2.rectTransform.localScale = new Vector3(-1f, 1f, 1f);
|
||||
component2.rectTransform.anchoredPosition = new Vector2(-125f, 0f);
|
||||
Image component3 = gameObject4.GetComponent<Image>();
|
||||
if (array[i * 5 + 3] == "0")
|
||||
{
|
||||
gameObject4.SetActive(value: false);
|
||||
}
|
||||
if (array[i * 5 + 3] == "8")
|
||||
{
|
||||
component3.rectTransform.anchoredPosition = new Vector2(-8.25f, 7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
component3.rectTransform.anchoredPosition = new Vector2(-7.125f, 10.5f);
|
||||
}
|
||||
component3.rectTransform.sizeDelta = new Vector2(13.125f, 5.625f);
|
||||
component3.sprite = Resources.Load<Sprite>("icons/overlays/overlay_" + array[i * 5 + 3]);
|
||||
TextMeshProUGUI component4 = gameObject2.GetComponent<TextMeshProUGUI>();
|
||||
component4.text = array[i * 5] + " (#" + (i + 1) + ")";
|
||||
component4.font = font;
|
||||
component4.fontSize = 14f;
|
||||
component4.alignment = TextAlignmentOptions.Left;
|
||||
component4.rectTransform.sizeDelta = new Vector2(200f, 75f);
|
||||
component4.rectTransform.anchoredPosition = new Vector2(-35f, 0f);
|
||||
TextMeshProUGUI component5 = obj.GetComponent<TextMeshProUGUI>();
|
||||
component5.text = "Score: " + array[i * 5 + 1];
|
||||
component5.font = font;
|
||||
component5.fontSize = 14f;
|
||||
component5.alignment = TextAlignmentOptions.Right;
|
||||
component5.rectTransform.sizeDelta = new Vector2(200f, 75f);
|
||||
component5.rectTransform.anchoredPosition = new Vector2(65f, 0f);
|
||||
gameObject.transform.SetParent(content.transform, worldPositionStays: false);
|
||||
}
|
||||
RectTransform component6 = content.GetComponent<RectTransform>();
|
||||
component6.sizeDelta = new Vector2(component6.sizeDelta.x, (float)num * (num2 + num3));
|
||||
yield break;
|
||||
}
|
||||
UpdateStatus(enabled: true, "Failed to fetch leaderboard stats");
|
||||
foreach (Transform item in content.transform)
|
||||
{
|
||||
UnityEngine.Object.Destroy(item.gameObject);
|
||||
}
|
||||
}
|
||||
private IEnumerator GetTopPlayers(int showAmount)
|
||||
{
|
||||
Debug.Log(showAmount);
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("showAmount", showAmount);
|
||||
UnityWebRequest request = UnityWebRequest.Post("https://berrydash.lncvrt.xyz/database/getTopPlayers.php", wWWForm);
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", "1.3-beta2");
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
UpdateStatus();
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
string[] array = text.Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int num = array.Length / 5;
|
||||
float num2 = 40f;
|
||||
float num3 = 10f;
|
||||
float num4 = content.GetComponent<RectTransform>().rect.height / 2f;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
GameObject gameObject = new GameObject("Entry_" + i, typeof(RectTransform), typeof(CanvasRenderer));
|
||||
RectTransform component = gameObject.GetComponent<RectTransform>();
|
||||
component.sizeDelta = new Vector2(600f, num2);
|
||||
component.anchoredPosition = new Vector2(0f, num4 - (float)i * (num2 + num3));
|
||||
component.anchorMin = new Vector2(0.5f, 1f);
|
||||
component.anchorMax = new Vector2(0.5f, 1f);
|
||||
component.pivot = new Vector2(0.5f, 1f);
|
||||
GameObject gameObject2 = new GameObject("PlayerName", typeof(RectTransform), typeof(TextMeshProUGUI));
|
||||
GameObject gameObject3 = new GameObject("PlayerIcon", typeof(RectTransform), typeof(Image));
|
||||
GameObject gameObject4 = new GameObject("PlayerIconOverlay", typeof(RectTransform), typeof(Image));
|
||||
GameObject obj = new GameObject("Score", typeof(RectTransform), typeof(TextMeshProUGUI));
|
||||
gameObject2.transform.SetParent(gameObject.transform, worldPositionStays: false);
|
||||
gameObject3.transform.SetParent(gameObject2.transform, worldPositionStays: false);
|
||||
gameObject4.transform.SetParent(gameObject3.transform, worldPositionStays: false);
|
||||
obj.transform.SetParent(gameObject.transform, worldPositionStays: false);
|
||||
Image component2 = gameObject3.GetComponent<Image>();
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_" + array[i * 5 + 2]);
|
||||
if (array[i * 5 + 2] == "1")
|
||||
{
|
||||
if (array[i * 5 + 4] == "1")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (array[i * 5 + 4] == "2")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (array[i * 5 + 4] == "4")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
}
|
||||
component2.rectTransform.sizeDelta = new Vector2(30f, 30f);
|
||||
component2.rectTransform.localScale = new Vector3(-1f, 1f, 1f);
|
||||
component2.rectTransform.anchoredPosition = new Vector2(-125f, 0f);
|
||||
Image component3 = gameObject4.GetComponent<Image>();
|
||||
if (array[i * 5 + 3] == "0")
|
||||
{
|
||||
gameObject4.SetActive(value: false);
|
||||
}
|
||||
if (array[i * 5 + 3] == "8")
|
||||
{
|
||||
component3.rectTransform.anchoredPosition = new Vector2(-8.25f, 7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
component3.rectTransform.anchoredPosition = new Vector2(-7.125f, 10.5f);
|
||||
}
|
||||
component3.rectTransform.sizeDelta = new Vector2(13.125f, 5.625f);
|
||||
component3.sprite = Resources.Load<Sprite>("icons/overlays/overlay_" + array[i * 5 + 3]);
|
||||
TextMeshProUGUI component4 = gameObject2.GetComponent<TextMeshProUGUI>();
|
||||
component4.text = array[i * 5] + " (#" + (i + 1) + ")";
|
||||
component4.font = font;
|
||||
component4.fontSize = 14f;
|
||||
component4.alignment = TextAlignmentOptions.Left;
|
||||
component4.rectTransform.sizeDelta = new Vector2(200f, 75f);
|
||||
component4.rectTransform.anchoredPosition = new Vector2(-35f, 0f);
|
||||
TextMeshProUGUI component5 = obj.GetComponent<TextMeshProUGUI>();
|
||||
component5.text = "Score: " + array[i * 5 + 1];
|
||||
component5.font = font;
|
||||
component5.fontSize = 14f;
|
||||
component5.alignment = TextAlignmentOptions.Right;
|
||||
component5.rectTransform.sizeDelta = new Vector2(200f, 75f);
|
||||
component5.rectTransform.anchoredPosition = new Vector2(65f, 0f);
|
||||
gameObject.transform.SetParent(content.transform, worldPositionStays: false);
|
||||
}
|
||||
RectTransform component6 = content.GetComponent<RectTransform>();
|
||||
component6.sizeDelta = new Vector2(component6.sizeDelta.x, (float)num * (num2 + num3));
|
||||
yield break;
|
||||
}
|
||||
UpdateStatus(enabled: true, "Failed to fetch leaderboard stats");
|
||||
foreach (Transform item in content.transform)
|
||||
{
|
||||
UnityEngine.Object.Destroy(item.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStatus(bool enabled = false, string message = "")
|
||||
{
|
||||
statusText.gameObject.SetActive(enabled);
|
||||
statusText.text = message;
|
||||
}
|
||||
private void UpdateStatus(bool enabled = false, string message = "")
|
||||
{
|
||||
statusText.gameObject.SetActive(enabled);
|
||||
statusText.text = message;
|
||||
}
|
||||
}
|
||||
+17
-17
@@ -5,24 +5,24 @@ using UnityEngine.UI;
|
||||
|
||||
public class Loading : MonoBehaviour
|
||||
{
|
||||
public float clientVersion;
|
||||
public float clientVersion;
|
||||
|
||||
public TMP_Text statusText;
|
||||
public TMP_Text statusText;
|
||||
|
||||
public Button updateButton;
|
||||
public Button updateButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
QualitySettings.vSyncCount = PlayerPrefs.GetInt("Setting5", 1);
|
||||
Screen.fullScreen = PlayerPrefs.GetInt("Setting1", 1) == 1;
|
||||
PlayerPrefs.SetFloat("latestVersion", clientVersion);
|
||||
if (!PlayerPrefs.HasKey("iconSelected"))
|
||||
{
|
||||
PlayerPrefs.SetInt("iconSelected", 1);
|
||||
}
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
QualitySettings.vSyncCount = PlayerPrefs.GetInt("Setting5", 1);
|
||||
Screen.fullScreen = PlayerPrefs.GetInt("Setting1", 1) == 1;
|
||||
PlayerPrefs.SetFloat("latestVersion", clientVersion);
|
||||
if (!PlayerPrefs.HasKey("iconSelected"))
|
||||
{
|
||||
PlayerPrefs.SetInt("iconSelected", 1);
|
||||
}
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
}
|
||||
+36
-36
@@ -4,46 +4,46 @@ using UnityEngine.UI;
|
||||
|
||||
public class Menu : MonoBehaviour
|
||||
{
|
||||
public Button exitBtn;
|
||||
public Button exitBtn;
|
||||
|
||||
public Button playBtn;
|
||||
public Button playBtn;
|
||||
|
||||
public Button settingsBtn;
|
||||
public Button settingsBtn;
|
||||
|
||||
public Button accountBtn;
|
||||
public Button accountBtn;
|
||||
|
||||
public Button leaderboardBtn;
|
||||
public Button leaderboardBtn;
|
||||
|
||||
public Button iconkitButton;
|
||||
public Button iconkitButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
exitBtn.onClick.AddListener(delegate
|
||||
{
|
||||
Application.Quit();
|
||||
});
|
||||
playBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Game");
|
||||
});
|
||||
settingsBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Settings");
|
||||
});
|
||||
accountBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Account");
|
||||
});
|
||||
leaderboardBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Leaderboard");
|
||||
});
|
||||
iconkitButton.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Iconkit");
|
||||
});
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
exitBtn.onClick.AddListener(delegate
|
||||
{
|
||||
Application.Quit();
|
||||
});
|
||||
playBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Game");
|
||||
});
|
||||
settingsBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Settings");
|
||||
});
|
||||
accountBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Account");
|
||||
});
|
||||
leaderboardBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Leaderboard");
|
||||
});
|
||||
iconkitButton.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Iconkit");
|
||||
});
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
+35
-35
@@ -4,49 +4,49 @@ using UnityEngine.UI;
|
||||
|
||||
public class PauseMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject pausePanel;
|
||||
public GameObject pausePanel;
|
||||
|
||||
public Button menuButton;
|
||||
public Button menuButton;
|
||||
|
||||
public Button playButton;
|
||||
public Button playButton;
|
||||
|
||||
public AudioSource backgroundMusic;
|
||||
public AudioSource backgroundMusic;
|
||||
|
||||
public Slider musicSlider;
|
||||
public Slider musicSlider;
|
||||
|
||||
public Slider sfxSlider;
|
||||
public Slider sfxSlider;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
menuButton.onClick.AddListener(MenuClick);
|
||||
playButton.onClick.AddListener(TogglePause);
|
||||
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
|
||||
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
|
||||
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
menuButton.onClick.AddListener(MenuClick);
|
||||
playButton.onClick.AddListener(TogglePause);
|
||||
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
|
||||
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
|
||||
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
||||
}
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
backgroundMusic.Play();
|
||||
pausePanel.SetActive(value: false);
|
||||
}
|
||||
private void TogglePause()
|
||||
{
|
||||
backgroundMusic.Play();
|
||||
pausePanel.SetActive(value: false);
|
||||
}
|
||||
|
||||
private void MenuClick()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
private void MenuClick()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
|
||||
private void UpdateMusicVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("musicVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
backgroundMusic.volume = volume;
|
||||
}
|
||||
private void UpdateMusicVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("musicVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
backgroundMusic.volume = volume;
|
||||
}
|
||||
|
||||
private void UpdateSFXVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("sfxVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
private void UpdateSFXVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("sfxVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
+77
-77
@@ -4,97 +4,97 @@ using UnityEngine.UI;
|
||||
|
||||
public class Settings : MonoBehaviour
|
||||
{
|
||||
public Toggle setting1toggle;
|
||||
public Toggle setting1toggle;
|
||||
|
||||
public Toggle setting2toggle;
|
||||
public Toggle setting2toggle;
|
||||
|
||||
public Toggle setting3toggle;
|
||||
public Toggle setting3toggle;
|
||||
|
||||
public Toggle setting4toggle;
|
||||
public Toggle setting4toggle;
|
||||
|
||||
public Toggle setting5toggle;
|
||||
public Toggle setting5toggle;
|
||||
|
||||
public Button backbutton;
|
||||
public Button backbutton;
|
||||
|
||||
public Slider musicSlider;
|
||||
public Slider musicSlider;
|
||||
|
||||
public Slider sfxSlider;
|
||||
public Slider sfxSlider;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
||||
setting1toggle.isOn = PlayerPrefs.GetInt("Setting1", 1) == 1;
|
||||
setting2toggle.isOn = PlayerPrefs.GetInt("Setting2", 0) == 1;
|
||||
setting3toggle.isOn = PlayerPrefs.GetInt("Setting3", 0) == 1;
|
||||
setting4toggle.isOn = PlayerPrefs.GetInt("Setting4", 0) == 1;
|
||||
setting5toggle.isOn = PlayerPrefs.GetInt("Setting5", 1) == 1;
|
||||
backbutton.onClick.AddListener(BackButton);
|
||||
setting1toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting1ToggleValueChanged(setting1toggle);
|
||||
});
|
||||
setting2toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting2ToggleValueChanged(setting2toggle);
|
||||
});
|
||||
setting3toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting3ToggleValueChanged(setting3toggle);
|
||||
});
|
||||
setting4toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting4ToggleValueChanged(setting4toggle);
|
||||
});
|
||||
setting5toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting5ToggleValueChanged(setting5toggle);
|
||||
});
|
||||
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
|
||||
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
||||
setting1toggle.isOn = PlayerPrefs.GetInt("Setting1", 1) == 1;
|
||||
setting2toggle.isOn = PlayerPrefs.GetInt("Setting2", 0) == 1;
|
||||
setting3toggle.isOn = PlayerPrefs.GetInt("Setting3", 0) == 1;
|
||||
setting4toggle.isOn = PlayerPrefs.GetInt("Setting4", 0) == 1;
|
||||
setting5toggle.isOn = PlayerPrefs.GetInt("Setting5", 1) == 1;
|
||||
backbutton.onClick.AddListener(BackButton);
|
||||
setting1toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting1ToggleValueChanged(setting1toggle);
|
||||
});
|
||||
setting2toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting2ToggleValueChanged(setting2toggle);
|
||||
});
|
||||
setting3toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting3ToggleValueChanged(setting3toggle);
|
||||
});
|
||||
setting4toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting4ToggleValueChanged(setting4toggle);
|
||||
});
|
||||
setting5toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting5ToggleValueChanged(setting5toggle);
|
||||
});
|
||||
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
|
||||
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
|
||||
}
|
||||
|
||||
private void Setting1ToggleValueChanged(Toggle change)
|
||||
{
|
||||
Screen.fullScreen = change.isOn;
|
||||
PlayerPrefs.SetInt("Setting1", change.isOn ? 1 : 0);
|
||||
}
|
||||
private void Setting1ToggleValueChanged(Toggle change)
|
||||
{
|
||||
Screen.fullScreen = change.isOn;
|
||||
PlayerPrefs.SetInt("Setting1", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting2ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting2", change.isOn ? 1 : 0);
|
||||
}
|
||||
private void Setting2ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting2", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting3ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting3", change.isOn ? 1 : 0);
|
||||
}
|
||||
private void Setting3ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting3", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting4ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting4", change.isOn ? 1 : 0);
|
||||
}
|
||||
private void Setting4ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting4", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting5ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting5", change.isOn ? 1 : 0);
|
||||
QualitySettings.vSyncCount = (change.isOn ? 1 : 0);
|
||||
}
|
||||
private void Setting5ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting5", change.isOn ? 1 : 0);
|
||||
QualitySettings.vSyncCount = (change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void BackButton()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
private void BackButton()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
|
||||
private void UpdateMusicVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("musicVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
private void UpdateMusicVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("musicVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
private void UpdateSFXVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("sfxVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
private void UpdateSFXVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("sfxVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user