public static MJ GetMJ(Account acc) { MJ mj = null; compensations.TryGetValue(acc, out mj); return(mj); }
public CompensationGump(MJ mj) : base(50, 50) { this.mj = mj; this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; AddPage(0); AddBackground(31, 48, 416, 246, 9250); AddBackground(39, 56, 400, 231, 3500); AddLabel(206, 75, 1301, @"Compensations MJ"); AddLabel(81, 110, 1301, @"Maitre du Jeu :"); AddLabel(210, 110, 1301, mj.Nom); //AddButton(383, 109, 4005, 4006, (int)Buttons.ChangerNom, GumpButtonType.Reply, 0); AddLabel(81, 140, 1301, @"Account Joueur :"); AddLabel(210, 140, 1301, mj.AccountJoueur.Username); AddLabel(81, 170, 1301, @"Personnage :"); AddLabel(210, 170, 1301, mj.AccountJoueur[mj.IndexPersonnage].Name); AddButton(383, 169, 4005, 4006, (int)Buttons.ChangerPersonnage, GumpButtonType.Reply, 0); AddLabel(81, 200, 1301, @"Prochaine Compensation :"); AddLabel(210, 200, 1301, mj.NextCompensation.ToString()); AddLabel(196, 241, 1301, @"Supprimer"); AddButton(275, 240, 4005, 4006, (int)Buttons.SupprimerMJ, GumpButtonType.Reply, 0); }
private static void Load() { compensations = new Dictionary <Account, MJ>(); compensationsIndexed = new List <MJ>(); if (!File.Exists(SavePath)) { return; } XmlDocument doc = new XmlDocument(); doc.Load(SavePath); XmlElement root = doc["compensations"]; foreach (XmlElement mj in root.GetElementsByTagName("mj")) { MJ m = new MJ(mj); compensationsIndexed.Add(m); } XP.LastReset = Utility.GetXMLDateTime(Utility.GetText(root["lastreset"], null), DateTime.Now); }
public static void SaveToJson(MJ mjb, string path) { JsonSerializer serializer = new JsonSerializer(); serializer.Converters.Add(new JavaScriptDateTimeConverter()); serializer.NullValueHandling = NullValueHandling.Ignore; using (StreamWriter sw = new StreamWriter(path)) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, mjb); // {"ExpiryDate":new Date(1230375600000),"Price":0} } }
public static MJ ReadJson(string path) { var setting = new JsonSerializerSettings(); setting.Formatting = Newtonsoft.Json.Formatting.Indented; setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; setting.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include; var fileContent = File.ReadAllText(path); MJ mj = JsonConvert.DeserializeObject <MJ>(fileContent); return(mj); }
private void UpdateValues() { IMJCurPlaylistAutomation currentPlaylist = MJ.GetCurPlaylist(); IMJFileAutomation currentTrack = currentPlaylist.GetFile(currentPlaylist.Position); IMJPlaybackAutomation currentPlaybackTrack = MJ.GetPlayback(); // Update values if (currentPlaylist.Position == 0 && !currentPlaylist.Continuous) { m_PreviousTrackTextControl.Text = "-"; } else { m_PreviousTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetPreviousFile()).Name; } m_CurrentTrackTextControl.Text = currentTrack.Name; if (!currentPlaylist.GetCanPlayNext() || (currentPlaylist.Position >= (currentPlaylist.GetNumberFiles() - 1) && !currentPlaylist.Continuous)) { m_NextTrackTextControl.Text = "-"; } else { m_NextTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetNextFile()).Name; } m_CurrentTrackProgressControl.Min = 0; m_CurrentTrackProgressControl.Max = currentTrack.Duration; m_CurrentTrackProgressControl.Current = currentPlaybackTrack.Position; m_CurrentTrackPositionTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentPlaybackTrack.Position)).ToString("g"); m_CurrentTrackDurationTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentTrack.Duration)).ToString("g"); if (m_RaisePriorityUntil > DateTime.Now) { if (!QvgaDevice.ForegroundApplet) { QvgaDevice.ForegroundApplet = true; } m_UpdatePriority = UpdatePriorities.Alert; } else { if (QvgaDevice.ForegroundApplet) { QvgaDevice.ForegroundApplet = false; } m_UpdatePriority = UpdatePriorities.Normal; } }
public override void OnResponse(Mobile from, string text) { if (this.mj == null) { try { int index = Convert.ToInt32(text); if (index < 0 || index >= accPJ.Length || accPJ[index] == null) { from.SendMessage("L'index que vous avez entré est invalide. Veuillez réessayer."); from.Prompt = new IndexPJPrompt(nomMJ, accPJ); } else { from.SendMessage("L'entrée est créée."); MJ mj = new MJ(nomMJ, accPJ, index); compensations.Add(accPJ, mj); compensationsIndexed.Add(mj); } } catch { from.SendMessage("L'index que vous avez entré est invalide. Veuillez réessayer."); from.Prompt = new IndexPJPrompt(nomMJ, accPJ); } } else { try { int index = Convert.ToInt32(text); if (index < 0 || index >= mj.AccountJoueur.Count) { from.SendMessage("L'index que vous avez entré est invalide. Veuillez réessayer."); from.Prompt = new IndexPJPrompt(mj); } else { from.SendMessage("Le personnage a été changé."); mj.IndexPersonnage = index; } } catch { from.SendMessage("L'index que vous avez entré est invalide. Veuillez réessayer."); from.Prompt = new IndexPJPrompt(mj); } } }
private static void Compensation_OnCommand(CommandEventArgs e) { Mobile from = e.Mobile; if (from.AccessLevel < AccessLevel.Coordinateur) { MJ mj = GetMJ((Account)from.Account); if (mj == null) { from.SendMessage("Cette commande n'est pas accessible."); } else { Account acc = mj.AccountJoueur; if (mj.IndexPersonnage >= acc.Length) { from.SendMessage("Il n'y a aucun personnage qui reçoit l'expérience en ce moment"); } else { if (acc[mj.IndexPersonnage] != null) { from.SendMessage("Le personnage qui reçoit l'expérience est : " + acc[mj.IndexPersonnage].Name); } else { from.SendMessage("Aucun personnage ne reçoit l'expérience."); } } from.SendMessage("Veuillez indiquer l'index du personnage qui recevra l'expérience."); for (int i = 0; i < acc.Length; i++) { if (acc[i] != null) { from.SendMessage("#" + i + ". " + acc[i].Name); } } from.Prompt = new IndexPJPrompt(mj); } } else { from.SendGump(new CompensationGump(0)); } }
public void ClearDataInTheServer() { uploadinJSON = true; MJ mjb = ReadJson(jsonPath); mjb.Players.Clear(); mjb.PlayersHard.Clear(); mjb.EasyLevel = ""; mjb.HardLevel = ""; mjb.CurrentlyPlaying = false; SaveToJson(mjb, jsonPath); UploadInServer(); print("Done?"); uploadinJSON = false; }
public CompensationGump(int page) : base(50, 50) { this.page = page; this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; AddPage(0); AddBackground(31, 48, 416, 432, 9250); AddBackground(39, 56, 400, 417, 3500); AddLabel(174, 78, 1301, @"Compensations MJ"); AddButton(285, 430, 4005, 4006, (int)Buttons.AjouterMJ, GumpButtonType.Reply, 0); AddLabel(185, 431, 1301, @"Ajouter un MJ"); int basey = 110; for (int i = 0; i < compensationsIndexed.Count; i++) { if (i >= (page + 1) * 10) { break; } if (i < page * 10) { continue; } MJ m = compensationsIndexed[i]; AddLabel(80, basey + (i % 10) * 30, 1301, m.Nom); AddLabel(270, basey + (i % 10) * 30, 1301, m.AccountJoueur.Username); AddButton(383, basey + (i % 10) * 30 - 1, 4005, 4006, i + 10, GumpButtonType.Reply, 0); } AddButton(402, 411, 5601, 5605, (int)Buttons.NextPage, GumpButtonType.Reply, 0); AddButton(61, 410, 5603, 5607, (int)Buttons.PreviousPage, GumpButtonType.Reply, 0); }
public SupprimerMJPrompt(MJ mj) { this.mj = mj; }
public IndexPJPrompt(MJ mj) { this.mj = mj; }
public NomMJPrompt(MJ mj) { this.mj = mj; }
// Procedure to sign the user that he wished to play multiplayer public void SignInForMultiplayer() { // trigger to stop the repeating downloading of the JSON file from the FTP server and work with the latest one uploadinJSON = true; // Unsigning if the user doesn;t want to play multiplayer anymore if (signedIn) { signedIn = false; secs = 0; MJ Mjb = ReadJson(jsonPath); List <PlayerProfile> allPlayers = new List <PlayerProfile>(); switch (PlayerPrefs.GetString("diff")) { case "easy": // Deleting the query of this user, so the server knows that this user doesn't want to play multiplayer anymore foreach (var item in Mjb.Players) { if (item.Nickname != username) { allPlayers.Add(item); } } Mjb.Players = allPlayers; break; case "hard": // Deleting the query of this user, so the server knows that this user doesn't want to play multiplayer anymore foreach (var item in Mjb.PlayersHard) { if (item.Nickname != username) { allPlayers.Add(item); } } Mjb.PlayersHard = allPlayers; break; default: // Deleting the query of this user, so the server knows that this user doesn't want to play multiplayer anymore foreach (var item in Mjb.Players) { if (item.Nickname != username) { allPlayers.Add(item); } } Mjb.Players = allPlayers; break; } // Saving the signed JSON SaveToJson(Mjb, jsonPath); // Uploading the JSON to the FTP server //ftpClient.upload(@"Test.json", jsonPath); UploadInServer(); // Triggering again the auto updation of the JSON file from the FTP server uploadinJSON = false; StartCoroutine(KeepJSONUpdated()); matchmakingPanel.gameObject.SetActive(false); print("succesfully signed off"); return; } // Reading the JSON file MJ mjb = ReadJson(jsonPath); if (PlayerPrefs.GetString("diff") == "easy") { if (mjb.Players.Count >= 2) { sorryBusyServer.gameObject.SetActive(true); return; } } else { if (mjb.PlayersHard.Count >= 2) { sorryBusyServer.gameObject.SetActive(true); return; } } // Reading the JSON file mjb = ReadJson(jsonPath); // Making active the matchamkiing meny, where the user can see for how long he is waiting and how many players there are at the queue matchmakingPanel.gameObject.SetActive(true); switch (PlayerPrefs.GetString("diff")) { case "easy": // IF this is the first user to sign in for multiplayer, we are creating new user in the queue for multiplayer if (mjb.Players.Count == 0) { mjb.Players.Add(new PlayerProfile()); mjb.Players[0].Nickname = username; mjb.Players[0].avatar = (byte)PlayerPrefs.GetInt("avatar"); if (mjb.EasyLevel == "" || mjb.EasyLevel == null) { mjb.EasyLevel = SelectRandomEasyLevel(); } } else // If not, we are checking if there is an empty record in the queue { // trigger to mark if an empty record was found in the queue bool saved = false; for (int i = 0; i < mjb.Players.Count; i++) { // if there is an empty record, we are filling it and signing this user at that record if (mjb.Players[i].Nickname == null) { mjb.Players[i].Nickname = username; mjb.Players[i].avatar = (byte)PlayerPrefs.GetInt("avatar"); saved = true; break; } } // If there wasn't an empty record to fill, we are creating a brand new one if (!saved) { print("Player added"); mjb.Players.Add(new PlayerProfile()); mjb.Players[mjb.Players.Count - 1].Nickname = username; mjb.Players[mjb.Players.Count - 1].avatar = (byte)PlayerPrefs.GetInt("avatar"); } } break; case "hard": // IF this is the first user to sign in for multiplayer, we are creating new user in the queue for multiplayer if (mjb.PlayersHard.Count == 0) { mjb.PlayersHard.Add(new PlayerProfile()); mjb.PlayersHard[0].Nickname = username; mjb.PlayersHard[0].avatar = (byte)PlayerPrefs.GetInt("avatar"); if (mjb.HardLevel == "" || mjb.HardLevel == null) { mjb.HardLevel = SelectRandomHardLevel(); } } else // If not, we are checking if there is an empty record in the queue { // trigger to mark if an empty record was found in the queue bool saved = false; for (int i = 0; i < mjb.PlayersHard.Count; i++) { // if there is an empty record, we are filling it and signing this user at that record if (mjb.PlayersHard[i].Nickname == null) { mjb.PlayersHard[i].Nickname = username; mjb.PlayersHard[i].avatar = (byte)PlayerPrefs.GetInt("avatar"); saved = true; break; } } // If there wasn't an empty record to fill, we are creating a brand new one if (!saved) { print("Player added"); mjb.PlayersHard.Add(new PlayerProfile()); mjb.PlayersHard[mjb.PlayersHard.Count - 1].Nickname = username; mjb.PlayersHard[mjb.PlayersHard.Count - 1].avatar = (byte)PlayerPrefs.GetInt("avatar"); } } break; default: break; } // Marks that the user is already signed for the multiplayer Queue signedIn = true; // Starts a coroutine that seeks how many people are searching for partners and matching them up StartCoroutine(SeekForOtherPlayers()); // Saving the signed JSON SaveToJson(mjb, jsonPath); // Uploading the JSON to the FTP server //ftpClient.upload(@"Test.json", jsonPath); UploadInServer(); // Triggering again the auto updation of the JSON file from the FTP server uploadinJSON = false; StartCoroutine(KeepJSONUpdated()); }
// Checking the FTP if there are enough signed in players to play and if there are, it notifies the users and starts the game private IEnumerator SeekForOtherPlayers() { StartCoroutine(Timer()); while (signedIn) { // Check the ftp file for data every 1/4 sec yield return(new WaitForSeconds(1f)); MJ mjb = ReadJson(jsonPath); string gameMode = PlayerPrefs.GetString("diff"); switch (gameMode) { case "easy": // if there are enough players do that: if (mjb.Players.Count == 2 || TestMultiplayer) { // Instead of this make text says taht is has found enoguh players to play FoundGame.text = "Game found for " + DisplaySeconds(secs); StopCoroutine(SeekForOtherPlayers()); StopCoroutine(Timer()); signedIn = false; mjb.CurrentlyPlaying = true; SaveToJson(mjb, jsonPath); UploadInServer(); SceneManager.LoadScene(mjb.EasyLevel); } break; case "hard": // if there are enough players do that: if (mjb.PlayersHard.Count == 2 || TestMultiplayer) { // Instead of this make text says taht is has found enoguh players to play FoundGame.text = "Game found for " + DisplaySeconds(secs); StopCoroutine(SeekForOtherPlayers()); StopCoroutine(Timer()); signedIn = false; mjb.CurrentlyPlaying = true; SaveToJson(mjb, jsonPath); UploadInServer(); SceneManager.LoadScene(mjb.HardLevel); } break; default: if (mjb.Players.Count == 2 || TestMultiplayer) { // Instead of this make text says taht is has found enoguh players to play FoundGame.text = "Game found for " + DisplaySeconds(secs); StopCoroutine(SeekForOtherPlayers()); StopCoroutine(Timer()); signedIn = false; mjb.CurrentlyPlaying = true; SaveToJson(mjb, jsonPath); UploadInServer(); SceneManager.LoadScene("Level 4"); } break; } } }
public void Ok() { resultPanel.gameObject.SetActive(false); MJ mjb = ReadJson(jsonPath); switch (PlayerPrefs.GetString("diff")) { case "easy": /* * foreach (var item in mjb.Players) * { * if (item.Nickname == username) * { * mjb.Players.Remove(item); * } * } */ bool deleteData = true; foreach (var item in mjb.Players) { if (item.showed == false) { deleteData = false; break; } } if (deleteData) { mjb.Players.Clear(); mjb.EasyLevel = ""; } break; case "hard": /* * foreach (var item in mjb.PlayersHard) * { * if (item.Nickname == username) * { * mjb.PlayersHard.Remove(item); * } * } */ deleteData = true; foreach (var item in mjb.PlayersHard) { if (item.showed == false) { deleteData = false; break; } } if (deleteData) { mjb.PlayersHard.Clear(); mjb.HardLevel = ""; } break; default: mjb.Players.Clear(); break; } SaveToJson(mjb, jsonPath); UploadInServer(); }
public void ShowWinner() { var allMM = FindObjectsOfType <MultiplayerManager>(); print(allMM.Length); StartCoroutine(DownloadDataFromTheSerer()); foreach (var item in allMM) { if (item.resultPanel != null) { resultPanel = item.resultPanel; } } resultPanel.SetActive(true); SpriteManager sm = FindObjectOfType <SpriteManager>(); MJ mjb = ReadJson(jsonPath); string winner = ""; int max = 0; switch (PlayerPrefs.GetString("diff")) { case "easy": foreach (var item in mjb.Players) { if (item.AmountOfBlueTilesEnlightened >= max) { max = item.AmountOfBlueTilesEnlightened; winner = item.Nickname; } } foreach (var item in mjb.Players) { if (item.Nickname == username) { item.showed = true; break; } } break; case "hard": foreach (var item in mjb.PlayersHard) { if (item.AmountOfBlueTilesEnlightened >= max) { max = item.AmountOfBlueTilesEnlightened; winner = item.Nickname; } } foreach (var item in mjb.PlayersHard) { if (item.Nickname == username) { item.showed = true; break; } } break; default: break; } SaveToJson(mjb, jsonPath); PlayerProfile winnerProfile = new PlayerProfile(); PlayerProfile secondPlaceProfile = new PlayerProfile(); switch (PlayerPrefs.GetString("diff")) { case "easy": if (mjb.Players.Count == 2) { if (mjb.Players[0].Nickname == winner) { if (mjb.Players[0].AmountOfBlueTilesEnlightened == mjb.Players[1].AmountOfBlueTilesEnlightened) { if (mjb.Players[0].AmountOfOrders > mjb.Players[1].AmountOfOrders) { winnerProfile = mjb.Players[1]; secondPlaceProfile = mjb.Players[0]; } else if (mjb.Players[0].AmountOfOrders == mjb.Players[1].AmountOfOrders) { if (mjb.Players[0].timeInSeconds > mjb.Players[1].timeInSeconds) { winnerProfile = mjb.Players[1]; secondPlaceProfile = mjb.Players[0]; } else { winnerProfile = mjb.Players[0]; secondPlaceProfile = mjb.Players[1]; } } else { winnerProfile = mjb.Players[0]; secondPlaceProfile = mjb.Players[1]; } } else { winnerProfile = mjb.Players[0]; secondPlaceProfile = mjb.Players[1]; } } else if (mjb.Players[1].Nickname == winner) { if (mjb.Players[1].AmountOfBlueTilesEnlightened == mjb.Players[0].AmountOfBlueTilesEnlightened) { if (mjb.Players[1].AmountOfOrders > mjb.Players[0].AmountOfOrders) { winnerProfile = mjb.Players[0]; secondPlaceProfile = mjb.Players[1]; } else if (mjb.Players[1].AmountOfOrders == mjb.Players[0].AmountOfOrders) { if (mjb.Players[1].timeInSeconds > mjb.Players[0].timeInSeconds) { winnerProfile = mjb.Players[0]; secondPlaceProfile = mjb.Players[1]; } else { winnerProfile = mjb.Players[1]; secondPlaceProfile = mjb.Players[0]; } } else { winnerProfile = mjb.Players[1]; secondPlaceProfile = mjb.Players[0]; } } else { winnerProfile = mjb.Players[1]; secondPlaceProfile = mjb.Players[0]; } } } break; case "hard": if (mjb.PlayersHard[0].Nickname == winner) { if (mjb.PlayersHard[0].Nickname == winner) { if (mjb.PlayersHard[0].AmountOfBlueTilesEnlightened == mjb.PlayersHard[1].AmountOfBlueTilesEnlightened) { if (mjb.PlayersHard[0].AmountOfOrders > mjb.PlayersHard[1].AmountOfOrders) { winnerProfile = mjb.PlayersHard[1]; secondPlaceProfile = mjb.PlayersHard[0]; } else if (mjb.PlayersHard[0].AmountOfOrders == mjb.PlayersHard[1].AmountOfOrders) { if (mjb.PlayersHard[0].timeInSeconds > mjb.PlayersHard[1].timeInSeconds) { winnerProfile = mjb.PlayersHard[1]; secondPlaceProfile = mjb.PlayersHard[0]; } else { winnerProfile = mjb.PlayersHard[0]; secondPlaceProfile = mjb.PlayersHard[1]; } } else { winnerProfile = mjb.PlayersHard[0]; secondPlaceProfile = mjb.PlayersHard[1]; } } else { winnerProfile = mjb.PlayersHard[0]; secondPlaceProfile = mjb.PlayersHard[1]; } } } else if (mjb.PlayersHard[1].Nickname == winner) { if (mjb.PlayersHard[1].AmountOfBlueTilesEnlightened == mjb.PlayersHard[0].AmountOfBlueTilesEnlightened) { if (mjb.PlayersHard[1].AmountOfOrders > mjb.PlayersHard[0].AmountOfOrders) { winnerProfile = mjb.PlayersHard[0]; secondPlaceProfile = mjb.PlayersHard[1]; } else if (mjb.PlayersHard[1].AmountOfOrders == mjb.PlayersHard[0].AmountOfOrders) { if (mjb.PlayersHard[1].timeInSeconds > mjb.PlayersHard[0].timeInSeconds) { winnerProfile = mjb.PlayersHard[0]; secondPlaceProfile = mjb.PlayersHard[1]; } else { winnerProfile = mjb.PlayersHard[1]; secondPlaceProfile = mjb.PlayersHard[0]; } } else { winnerProfile = mjb.PlayersHard[1]; secondPlaceProfile = mjb.PlayersHard[0]; } } else { winnerProfile = mjb.PlayersHard[1]; secondPlaceProfile = mjb.PlayersHard[0]; } } break; } if (PlayerPrefs.GetString("English") == "true") { resultsLabel.text = "Results"; resultsOk.text = "Ok"; sm.winnerNameLabel.text = "Winner:\n" + winnerProfile.Nickname; sm.winnerData.text = string.Format("Amount of blue tiles enlighted: {0}\nAmount of orders used: {1}\nNeeded time to solve: {2} seconds", winnerProfile.AmountOfBlueTilesEnlightened, winnerProfile.AmountOfOrders, winnerProfile.timeInSeconds); sm.secondPlaceNameLabel.text = "Second place:\n" + secondPlaceProfile.Nickname; sm.secondPlaceData.text = string.Format("Amount of blue tiles enlighted: {0}\nAmount of orders used: {1}\nNeeded time to solve: {2} seconds", secondPlaceProfile.AmountOfBlueTilesEnlightened, secondPlaceProfile.AmountOfOrders, secondPlaceProfile.timeInSeconds); } else { resultsLabel.text = "Резултати"; resultsOk.text = "Окей"; sm.winnerNameLabel.text = "Победител:\n" + winnerProfile.Nickname; sm.winnerData.text = string.Format("Осветени полета: {0}\nБрой използвани команди: {1}\nНужно време за решаване: {2} секунди", winnerProfile.AmountOfBlueTilesEnlightened, winnerProfile.AmountOfOrders, winnerProfile.timeInSeconds); sm.secondPlaceNameLabel.text = "Губещ:\n" + secondPlaceProfile.Nickname; sm.secondPlaceData.text = string.Format("Осветени полета: {0}\nБрой използвани команди: {1}\nНужно време за решаване: {2} секунди", secondPlaceProfile.AmountOfBlueTilesEnlightened, secondPlaceProfile.AmountOfOrders, secondPlaceProfile.timeInSeconds); } // Gathering the data for the local Database string localDB = Path.Combine(Application.streamingAssetsPath, "LocalDB.json"); StatObject so = ReadLocalDBJson(localDB); so.totalGames++; // Adding data for the statistics if (winnerProfile.Nickname == username) { so.wonGames++; so.totalSeconds = winnerProfile.timeInSeconds; so.totalOrders = winnerProfile.AmountOfOrders; } // Saving the data in the local db json file SaveToJson(so, localDB); print(winnerProfile.Nickname + " is the fuckign winner with " + winnerProfile.AmountOfBlueTilesEnlightened); sm.place1.sprite = sm.ReturnAvatar(winnerProfile); sm.place2.sprite = sm.ReturnAvatar(secondPlaceProfile); showWinner = false; UploadInServer(); }
public IEnumerator BattleTimer(Text timerText) { while (bSecs != 0) { bSecs--; timerText.text = DisplaySeconds(bSecs); yield return(new WaitForSeconds(1f)); } MJ mjb = ReadJson(jsonPath); mjb.CurrentlyPlaying = false; switch (PlayerPrefs.GetString("diff")) { case "easy": foreach (var item in mjb.Players) { if (item.Nickname == username) { item.showed = true; break; } } break; case "hard": foreach (var item in mjb.PlayersHard) { if (item.Nickname == username) { item.showed = true; break; } } break; default: break; } SaveToJson(mjb, jsonPath); showWinner = true; UploadInServer(); bool waitingForOpponed = true; while (waitingForOpponed) { waitingForOpponed = false; mjb = ReadJson(jsonPath); // Checking if all players are ready for the results to be shown switch (PlayerPrefs.GetString("diff")) { case "easy": foreach (var item in mjb.Players) { if (!item.showed) { waitingForOpponed = true; break; } } break; case "hard": foreach (var item in mjb.PlayersHard) { if (!item.showed) { waitingForOpponed = true; break; } } break; default: break; } // Hitting the database that this user is ready to see the data switch (PlayerPrefs.GetString("diff")) { case "easy": foreach (var item in mjb.Players) { if (item.Nickname == username) { item.showed = true; break; } } break; case "hard": foreach (var item in mjb.PlayersHard) { if (item.Nickname == username) { item.showed = true; break; } } break; default: break; } print("This user should be shown."); SaveToJson(mjb, jsonPath); // Setting up the battle timer GameObject mmTimer = GameObject.Find("MMTimer"); GameObject playButton = GameObject.Find("Start"); playButton.GetComponent <Button>().enabled = false; print("Play button should be disabled"); if (PlayerPrefs.GetString("English") == "true") { mmTimer.GetComponentInChildren <Text>().text = "Waiting..."; } else { mmTimer.GetComponentInChildren <Text>().text = "Изчакване..."; } UploadInServer(); yield return(new WaitForSeconds(1f)); } SceneManager.LoadScene("MultiplayerMenu"); }