Exemplo n.º 1
0
    //Routines
    IEnumerator GetItems()
    {
        //get items
        int asyncId = Fabio.GetAsyncId();

        Fabio.god.rest.GetItemsFromUser(asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        print("fetched");
        items = Fabio.god.rest.userItems;
        print(items.Length);

        //set inv screen
        for (int i = 0; i < items.Length && i < 15; i++)
        {
            asyncId = Fabio.GetAsyncId();
            Fabio.god.rest.GetTemplateById(items[i].template_id, asyncId);
            yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

            print("fetched");
            currentTemplate = Fabio.god.rest.template;

            print(items[i].template_id);
            slots[i].SetActive(true);
            slots[i].GetComponent <InvSlot>().Fill(items[i], currentTemplate);
        }
    }
    IEnumerator SignUpRoutine()
    {
        string username = loginInput.text;
        string password = passInput.text;
        string nick     = nickInput.text;

        //checar se user ja existe
        int asyncId = Fabio.GetAsyncId();

        Fabio.god.rest.GetUserByUsername(username, asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        User user = Fabio.god.rest.user;

        if (user != null)
        {
            print("Username taken");
            //TRATAR
        }
        else
        {
            user               = new User();
            user.login         = username;
            user.user_password = password;
            user.nick          = nick;
            user.join_date     = System.DateTime.Today;
            user.last_login    = System.DateTime.Today;
            user.active        = 1;
            user.banned        = 0;
            user.money_spent   = 0;

            Fabio.god.rest.AddUser(user);
            Fabio.LoadScene("Login");
        }
    }
Exemplo n.º 3
0
    //Routines
    IEnumerator CharHandlerRoutine()
    {
        //Get characters
        int asyncId = Fabio.GetAsyncId();

        Fabio.god.rest.GetCharactersFromUser(asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        characters = Fabio.god.rest.userCharacters;

        //Get items
        asyncId = Fabio.GetAsyncId();
        Fabio.god.rest.GetWeaponsFromUser(asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        weapons = Fabio.god.rest.userWeapons;

        flag_weapons = true;

        //fill screens
        for (int i = 0; i < characters.Length && i < 3; i++)
        {
            charactersScreens[i].SetActive(true);
            charactersScreens[i].GetComponent <CharScreen>().FillElements(characters[i]);
        }

        if (characters.Length < 3)
        {
            buttons[characters.Length].SetActive(true);
        }
    }
Exemplo n.º 4
0
    IEnumerator SignInRoutine()
    {
        string username = userInput.text;
        string password = passInput.text;

        int asyncId = Fabio.GetAsyncId();

        Fabio.god.rest.GetUserByUsername(username, asyncId);
        print("signing " + username);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        print("fetched");

        User user = Fabio.god.rest.user;

        if (user == null)
        {
            print("usuario n existe");
            //Tratar
        }
        else
        {
            if (CheckPassword(user.user_password, password))
            {
                if (user.banned != 0)
                {
                    print("Usuario banido!");
                }
                else
                {
                    Fabio.god.rest.UpdateUserLastLogin(username);
                    print("updating login: "******"fetched");
                    print("LOGIN FOI");
                    Fabio.user = user;
                    Fabio.LoadScene("MainMenu");
                }
            }
            else
            {
                print("Senha invalida");
                //Tratar
            }
        }
    }
Exemplo n.º 5
0
    IEnumerator GenerateShop()
    {
        //Get all templates
        int asyncId = Fabio.GetAsyncId();

        Fabio.god.rest.GetTemplates(asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        print("fetched");
        allTemplates = Fabio.god.rest.templates;

        //assign
        for (int i = 0; i < 15; i++)
        {
            currentTemplate = allTemplates[Random.Range(0, allTemplates.Length)];
            slots[i].GetComponent <ShopCell>().Fill(currentTemplate);
        }
    }
Exemplo n.º 6
0
    IEnumerator ActionRoutine()
    {
        User originalUser = Fabio.god.rest.user;

        int asyncId = Fabio.GetAsyncId();

        Fabio.god.rest.GetUserByUsername(searchBar.text, asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        print("fetched");
        Fabio.god.tradeUser = Fabio.god.rest.user;
        Fabio.god.rest.user = originalUser;

        if (Fabio.god.tradeUser == null)
        {
            print("User not found");
        }
        else
        {
            Fabio.LoadScene("Trade2");
        }
    }
Exemplo n.º 7
0
    IEnumerator main()
    {
        //Get a little delay to avoid async problems
        yield return(new WaitForSeconds(delay));

        //Get armor item
        print("armor" + myCharacter.armor);
        int asyncId = Fabio.GetAsyncId();

        Fabio.god.rest.GetItemsById(myCharacter.armor, asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        print("fetched");
        armor = Fabio.god.rest.item;
        print("armor = " + armor);

        //Get weapon item
        asyncId = Fabio.GetAsyncId();
        Fabio.god.rest.GetItemsById(myCharacter.weapon, asyncId);
        yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

        print("fetched");
        weapon = Fabio.god.rest.item;

        print("!!!");
        //print(armor.item_id);
        //print(weapon.item_id);
        print("!!!");

        //Get armor template
        if (armor != null)
        {
            asyncId = Fabio.GetAsyncId();
            Fabio.god.rest.GetTemplateById(armor.template_id, asyncId);
            yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

            print("fetched");
            armorTemplate = Fabio.god.rest.template;
        }
        else
        {
            armorTemplate = null;
        }

        //Get weapon template
        if (weapon != null)
        {
            asyncId = Fabio.GetAsyncId();
            Fabio.god.rest.GetTemplateById(weapon.template_id, asyncId);
            yield return(new WaitUntil(() => Fabio.CheckAsyncId(asyncId)));

            print("fetched");
            weaponTemplate = Fabio.god.rest.template;
        }
        else
        {
            weaponTemplate = null;
        }

        //Show info
        elements[7].text  = armorTemplate == null ? "0" : armorTemplate.amount_1.ToString();
        elements[8].text  = weaponTemplate == null ? "0" : weaponTemplate.amount_1.ToString();
        elements[9].text  = armorTemplate == null ? "none" : armorTemplate.item_name;
        elements[10].text = weaponTemplate == null ? "none" : weaponTemplate.item_name;
    }