Esempio 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);
        }
    }
Esempio n. 2
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);
        }
    }
    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");
        }
    }
Esempio n. 4
0
    IEnumerator CreateCharacter(Character newCharacter)
    {
        Fabio.god.rest.AddCharacter(newCharacter);
        yield return(new WaitForSeconds(0.1f)); //wait a little then reload to show new char

        Fabio.LoadScene("Characters");
    }
Esempio n. 5
0
    IEnumerator DeleteItemRoutine(int id)
    {
        print("deleting" + slots[id].GetComponent <InvSlot>().myItem.item_id);
        Fabio.god.rest.DeleteItem(slots[id].GetComponent <InvSlot>().myItem.item_id);
        yield return(new WaitForSeconds(0.1f));

        Fabio.LoadScene("Inv");
    }
Esempio n. 6
0
    public void EquipWeapon(int id)
    {
        Character character = charactersScreens[id].GetComponent <CharScreen>().myCharacter;

        Fabio.god.Equipchar  = character;
        Fabio.god.equipArmor = false;
        Fabio.LoadScene("EquipItem");
    }
Esempio n. 7
0
    private void Awake()
    {
        if (god == null)
        {
            god = this;
        }

        DontDestroyOnLoad(god);
    }
 public void Trade(int id)
 {
     if (!trading)
     {
         trading            = true;
         Fabio.god.tradeid2 = slots[id].GetComponent <InvSlot>().myItem.item_id;
         Fabio.god.rest.TradeItem(Fabio.god.tradeid1, Fabio.god.tradeid2, Fabio.user.login, Fabio.god.tradeUser.login);
         Fabio.LoadScene("MainMenu");
     }
 }
Esempio n. 9
0
 public void Equip(int id)
 {
     if (!equiping)
     {
         equiping = true;
         int newitemid = slots[id].GetComponent <InvSlot>().myItem.item_id;
         Fabio.god.rest.EquipItem(newitemid, Fabio.god.Equipchar, Fabio.god.equipArmor);
         Fabio.LoadScene("MainMenu");
     }
 }
Esempio n. 10
0
    IEnumerator DeleteCharacterRoutine(Character character)
    {
        if (character.armor != null)
        {
            StartCoroutine(Fabio.god.rest.ChangeItemStatus(character.armor, 0));
        }
        if (character.weapon != null)
        {
            StartCoroutine(Fabio.god.rest.ChangeItemStatus(character.weapon, 0));
        }

        Fabio.god.rest.DeleteCharacter(character.character_id);

        yield return(new WaitForSeconds(0.1f)); //wait a little then reload to show new spot

        Fabio.LoadScene("Characters");
    }
Esempio n. 11
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
            }
        }
    }
Esempio n. 12
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);
        }
    }
Esempio n. 13
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");
        }
    }
Esempio n. 14
0
 public void returnFunc(string scene)
 {
     Fabio.LoadScene(scene);
 }
Esempio n. 15
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;
    }
Esempio n. 16
0
 public void signUp()
 {
     Fabio.LoadScene("Register");
 }
Esempio n. 17
0
 public void Trade(int id)
 {
     Fabio.god.tradeid1 = slots[id].GetComponent <InvSlot>().myItem.item_id;
     Fabio.LoadScene("Trade1");
 }