Advertisement
Guest User

ScoreBoard

a guest
Apr 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class ScoreBoard : MonoBehaviour
  7. {
  8.     bool Nombre = false;
  9.  
  10.     public Text texto;
  11.  
  12.     // Start is called before the first frame update
  13.     void Start()
  14.     {
  15.         StartCoroutine(IEScoreBoard());
  16.     }
  17.  
  18.     IEnumerator IEScoreBoard()
  19.     {
  20.         //Mandamos información
  21.         WWW getData = new WWW("https://arjierdagames.com/games_database/Test/best.php");
  22.         //Esperamos recibir respuesta
  23.         yield return getData;
  24.         print(getData.text); // Avanza hasta que ya recibio algo
  25.  
  26.         if(!string.IsNullOrEmpty(getData.error) && getData.error.Contains("Could not resolve host"))
  27.         {
  28.             //Si hubo error de conexion, nos detenemos y salimos
  29.             StopAllCoroutines();
  30.             yield return null;
  31.         }
  32.  
  33.         for(int i = 0; i < getData.text.Length; i++)
  34.         {
  35.             if(getData.text[i] != '■')
  36.             {
  37.                 texto.text += getData.text[i];
  38.             }
  39.             else if(Nombre)
  40.             {
  41.                 texto.text += '\n';
  42.                 Nombre = false;
  43.             }
  44.             else
  45.             {
  46.                 texto.text += ' ';
  47.                 Nombre = true;
  48.             }
  49.         }
  50.  
  51.         //Si llegamos a este punto, todo va bien :D
  52.         if(getData.text == "0")
  53.         {
  54.             print("Mejora tus puntos inepto");
  55.         }
  56.         else
  57.         {
  58.             print("Nuevo record registrado");
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement