Example #1
0
    public void UsarItem(int id)
    {
        PokemonOwnedDAO pkmOwned     = new PokemonOwnedDAO();
        ItemsOwnedDAO   itemsOwned   = new ItemsOwnedDAO();
        PokemonOwned    seleccionado = pkmOwned.GetPokemon(id);
        ItemsOwned      itemSelected = itemsOwned.GetItemOwned(UIController.instance.itemSeleccionado);
        int             happynessFinal;

        switch (itemSelected.NameBasic)
        {
        case "Pocion Aguante 20":
            happynessFinal = seleccionado.CurrentHappyness + 20;
            if (happynessFinal > seleccionado.Happyness)
            {
                seleccionado.CurrentHappyness = seleccionado.Happyness;
            }
            else
            {
                seleccionado.CurrentHappyness += 20;
            }
            pkmOwned.UpdatePokemon(seleccionado);
            itemsOwned.DeleteItemOwned(itemSelected.Id);
            break;

        case "Pocion Aguante 40":
            happynessFinal = seleccionado.CurrentHappyness + 40;
            if (happynessFinal > seleccionado.Happyness)
            {
                seleccionado.CurrentHappyness = seleccionado.Happyness;
            }
            else
            {
                seleccionado.CurrentHappyness += 40;
            }
            pkmOwned.UpdatePokemon(seleccionado);
            itemsOwned.DeleteItemOwned(itemSelected.Id);
            break;
        }
    }
Example #2
0
    void FixedUpdate()
    {
        curAcc = Mathf.Lerp(curAcc, Input.acceleration.magnitude, fHigh);
        avgAcc = Mathf.Lerp(avgAcc, Input.acceleration.magnitude, fLow);
        float delta = curAcc - avgAcc;

        if (delta > hiLim)
        {
            steps++;
        }

        if (steps > 10)
        {
            stepsEgg++;
            actualizarDatos = true;
            PokemonOwnedDAO     pkmOwned    = new PokemonOwnedDAO();
            List <PokemonOwned> listPokemon = pkmOwned.GetEquippedPokemon().ToList();
            PlayerDAO           playerDAO   = new PlayerDAO();
            EggOwnedDAO         eggOwned    = new EggOwnedDAO();
            for (int i = 0; i < listPokemon.Count(); i++)
            {
                if (listPokemon[i].CurrentHappyness > 1)
                {
                    listPokemon[i].CurrentHappyness  -= 1;
                    listPokemon[i].CurrentExperience += 2;
                    if (listPokemon[i].CurrentExperience > listPokemon[i].ExperienceNeeded)
                    {
                        listPokemon[i].LevelUp();
                        playerDAO.UpdateGold(playerDAO.GetPlayer().Gold + (listPokemon[i].Level * 5));
                    }
                    pkmOwned.UpdatePokemon(listPokemon[i].Id, listPokemon[i]);
                }
            }
            if (stepsEgg == 3)
            {
                if (eggOwned.GetEquippedEgg() != null)
                {
                    eggOwned.AumentarCiclo();
                }
                stepsEgg = 0;
            }
            steps = 0;
        }
    }