production 1.4

This commit is contained in:
2023-07-07 17:22:32 +05:30
parent 6b9a2e7b80
commit 7a08f8d247
13 changed files with 143 additions and 402 deletions

View File

@@ -189,6 +189,50 @@ public static class DataManager{
LoadingScreen.LoadLevel("MainMenu");
}
public static async void AddHoleInOne(){
WWWForm form = new WWWForm();
Debug.Log(userData.ToString());
form.AddField("username", userData.username);
form.AddField("password", userData.password);
form.AddField("key", key);
using (UnityWebRequest request = UnityWebRequest.Post(API_ENDPOINT + "add_hole_in_one.php", form))
{
var operation = request.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
Debug.Log("add hole in one response: " +request.downloadHandler.text);
if(request.downloadHandler.text.Contains("{")){
try{
userData = JsonConvert.DeserializeObject<UserData>(request.downloadHandler.text);
if(userData == null){
throw new NullReferenceException();
}
if(userData.username.Length < 3){
throw new IndexOutOfRangeException();
}
Debug.Log("Success parsing userdata");
}catch(Exception e){
Debug.Log("Error parsing userdata");
}
}else{
MessageBox.ShowMessage("Error Updating hole in ones, Server said\n" +request.downloadHandler.text);
}
}
// LoadingScreen.LoadLevel("MainMenu");
}
public static async Task RefreshLeaderboard(bool total = false){
WWWForm form = new WWWForm();
@@ -240,7 +284,7 @@ public static class DataManager{
}
Debug.Log("my position: " +request.downloadHandler.text);
LeaderboardItemData newItem = new LeaderboardItemData(){position=int.Parse(request.downloadHandler.text), name= DataManager.userData.username, topScore = DataManager.userData.TopScore};
LeaderboardItemData newItem = new LeaderboardItemData(){position=int.Parse(request.downloadHandler.text), name= DataManager.userData.username, topScore = DataManager.userData.TopScore, Score = DataManager.userData.score};
Leaderboard.Add(newItem);
}
}

View File

@@ -156,6 +156,7 @@ public class GameManager : MonoBehaviour
if(instance.CurStrokes >= instance.MaxStrokes-1){
instance.HoleInOne.CrossFadeInFixedTime("Play",0.01f);
DataManager.AddHoleInOne();
instance.Score++;
}
instance.CurStrokes = instance.MaxStrokes;

View File

@@ -14,7 +14,7 @@ public class Hole : MonoBehaviour
public void OnTriggerExit2D(Collider2D other){
if(other.tag == "Player"){
Debug.Log(other.name + " Exited hole");
Debug.Log(other.name + " Exited hole ");
GameManager.CancelHole();
}