Example #1
0
 public void CrearDueloNormal(int winnerId, int loserId, int isTorneo)
 {
     StartCoroutine(apiCalls.CreateDueloNormal(
                        winnerId,
                        loserId,
                        1,
                        0,
                        isTorneo,
                        0,
                        0,
                        0,
                        0,
                        (string res) => {
         if (isTorneo == 1)
         {
             Duelo tmpDuelo = JsonUtility.FromJson <Duelo>(res);
             StartCoroutine(apiCalls.SetPlayedDueloAgendado(
                                tmpDuelo.id,
                                tmpDuelo.ganador.id,
                                tmpDuelo.perdedor.id,
                                (int resCode) => {
                 //GameUI.instance.SuccessOnDueloAgendadoRequest();
             }, (int errCode) => {
                 Debug.Log("Ha ocurrido un error con el duelo agendado :C");
             }));
         }
     }, (int err) => {
         Debug.Log("Ha ocurrido un error al enviar el duelo");
     }
                        ));
 }
Example #2
0
    public void CrearDueloNormal(Player winnerPlayer, Player loserPlayer, int isTorneo)
    {
        int id_w = (int)winnerPlayer.CustomProperties["id"];
        int id_l = (int)loserPlayer.CustomProperties["id"];

        int goles_w = (int)winnerPlayer.CustomProperties["Goals"];
        int goles_l = (int)loserPlayer.CustomProperties["Goals"];

        int goles_atajados_ganador  = (int)winnerPlayer.CustomProperties["SavedGoals"];
        int goles_atajados_perdedor = (int)loserPlayer.CustomProperties["SavedGoals"];

        int goles_recibidos_ganador  = (int)winnerPlayer.CustomProperties["FailedGoals"];
        int goles_recibidos_perdedor = (int)loserPlayer.CustomProperties["FailedGoals"];



        StartCoroutine(apiCalls.CreateDueloNormal(
                           id_w,
                           id_l,
                           goles_w,
                           goles_l,
                           isTorneo,
                           goles_atajados_ganador,
                           goles_atajados_perdedor,
                           goles_recibidos_ganador,
                           goles_recibidos_perdedor,
                           (string res) =>
        {
            Debug.Log("Es torneo?: " + isTorneo);
            if (isTorneo == 1)
            {
                Duelo tmpDuelo = JsonUtility.FromJson <Duelo>(res);
                StartCoroutine(apiCalls.SetPlayedDueloAgendado(
                                   tmpDuelo.id,
                                   tmpDuelo.ganador.id,
                                   tmpDuelo.perdedor.id,
                                   (int resCode) => {
                    //GameUI.instance.SuccessOnDueloAgendadoRequest();
                }, (int errCode) => {
                    Debug.Log("Ha ocurrido un error con el duelo agendado :C");
                }));
            }
            else
            {
                //GameUI.instance.SuccessOnDueloAgendadoRequest();
            }
            //userLogin.AddDuelo(tmpDuelo);
        }, (int err) =>
        {
            Debug.Log("Duelo no se pudo crear!");
        })
                       );
    }
    public void Initialize(Duelo duelo, bool isWin)
    {
        if (isWin)
        {
            background.sprite = winSprite;
            myGoals.text      = duelo.goles_ganador.ToString();
            rivalUser.text    = duelo.perdedor.username;
            rivalGoals.text   = duelo.goles_perdedor.ToString();
        }
        else
        {
            background.sprite = loseSprite;
            myGoals.text      = duelo.goles_perdedor.ToString();
            rivalUser.text    = duelo.ganador.username;
            rivalGoals.text   = duelo.goles_ganador.ToString();
        }
        //fecha.text = duelo.fecha;
        DateTime tmpFecha = DateTime.Parse(duelo.fecha);

        fecha.text = tmpFecha.ToString("yyyy-MM-dd") + "\n" + tmpFecha.ToString("hh:mm tt");
    }
Example #4
0
    public void AddMatchResultToLocal(Player winner, Player loser)
    {
        int id_w = (int)winner.CustomProperties["id"];
        int id_l = (int)loser.CustomProperties["id"];

        string username_w = (string)winner.CustomProperties["username"];
        string username_l = (string)loser.CustomProperties["username"];

        Jugador player_ganador = new Jugador()
        {
            id       = id_w,
            username = username_w
        };

        Jugador player_perdedor = new Jugador()
        {
            id       = id_l,
            username = username_l
        };

        int goles_w = (int)winner.CustomProperties["Goals"];
        int goles_l = (int)loser.CustomProperties["Goals"];

        DateTime localDate = DateTime.Now;
        var      fecha     = localDate.ToString("yyyy-MM-dd");

        Duelo tmpDuelo = new Duelo()
        {
            id             = 999,
            ganador        = player_ganador,
            perdedor       = player_perdedor,
            goles_ganador  = goles_w,
            goles_perdedor = goles_l,
            fecha          = fecha
        };

        userLogin.AddDuelo(tmpDuelo);
    }