Ejemplo n.º 1
0
    public void MostrarDatosPantallaInicio()
    {
        PlayerDAO player = new PlayerDAO();

        labelOro.GetComponent <UILabel> ().text    = "Oro: " + player.GetPlayer().Gold;
        labelNombre.GetComponent <UILabel> ().text = "Nombre: " + player.GetPlayer().Name;
        PokemonOwnedDAO pokemon = new PokemonOwnedDAO();

        labelPokemon.GetComponent <UILabel>().text = "Pokemon: " + pokemon.GetOwnedPokemon().ToList().Count();
    }
 //boton para iniciar juego.
 private void BttnPlay_Click(object sender, EventArgs e)
 {
     try
     {
         //Obtener datos de usuario
         var player = PlayerDAO.GetPlayer(txtNickname.Text);
         //Verificar si el usuario existe
         if (player.nickname.Equals(""))
         {
             throw new UserNotFoundException("El usuario no se encuentra registrado\n Presione agregar.");
         }
         else
         {
             MessageBox.Show($"Todo listo para jugar {player.nickname}!", "Arkanoid",
                             MessageBoxButtons.OK);
             ControlArkanoid cont = new ControlArkanoid(player);
             this.ActiveControl = null;
             ((frmGame)this.Parent).ShowControl(cont);
         }
     }
     //capturar excepción
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message,
                         "Arkanoid", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 3
0
    public bool PagarHospital()
    {
        int       precio  = CalcularPrecioHospital();
        bool      pagado  = true;
        PlayerDAO playerD = new PlayerDAO();

        if (precio > playerD.GetPlayer().Gold)
        {
            pagado = false;
        }
        else
        {
            playerD.UpdateGold(playerD.GetPlayer().Gold - precio);
        }
        return(pagado);
    }
Ejemplo n.º 4
0
 void OnClick()
 {
     if (sePuedeComprar)
     {
         EggOwnedDAO eggOwned   = new EggOwnedDAO();
         EggBasicDAO eggBasic   = new EggBasicDAO();
         PlayerDAO   playerDAO  = new PlayerDAO();
         int         precioItem = eggBasic.GetEggBasic(transform.name).Price;
         if (precioItem > playerDAO.GetPlayer().Gold)
         {
             UIController.instance.MostrarPanelMensaje("No dispones del oro suficiente para comprar eso");
         }
         else
         {
             playerDAO.UpdateGold(playerDAO.GetPlayer().Gold - precioItem);
             eggOwned.CreateEggOwned(transform.name);
             UIController.instance.MostrarTiendaHuevos();
         }
     }
 }
Ejemplo n.º 5
0
    void Update()
    {
        PlayerDAO       player = new PlayerDAO();
        PokemonOwnedDAO pk     = new PokemonOwnedDAO();
        EggOwnedDAO     egg    = new EggOwnedDAO();
        Player          p      = player.GetPlayer();

        labelNombre.GetComponent <UILabel>().text   = "Perfil de " + p.Name;
        labelOro.GetComponent <UILabel>().text      = "Oro: " + p.Gold;
        labelPokemon.GetComponent <UILabel> ().text = "Pokemon: " + pk.GetOwnedPokemon().ToList().Count();
        labelHuevos.GetComponent <UILabel> ().text  = "Huevos: " + egg.GetNotEquippedEggs().ToList().Count();
    }
Ejemplo n.º 6
0
 void Update()
 {
     if (actualizarTienda)
     {
         if (mostrarItems)
         {
             int childs = parentGrid.transform.childCount;
             for (int i = 0; i < childs; i++)
             {
                 Destroy(parentGrid.transform.GetChild(i).gameObject);
             }
             ItemsBasicDAO     itemsBasic = new ItemsBasicDAO();
             List <ItemsBasic> lista      = itemsBasic.GetItemsBasic().ToList();
             for (int i = 0; i < lista.Count(); i++)
             {
                 GameObject item = Instantiate(prefabItem) as GameObject;
                 item.transform.name = lista [i].Name;
                 item.GetComponent <BotonUsarPocion>().sePuedeUsar     = false;
                 item.GetComponent <BotonComprarItem>().sePuedeComprar = true;
                 item.GetComponentInChildren <UILabel> ().text         = lista [i].Name + " Precio: " + lista[i].Price;
                 item.transform.parent     = parentGrid.transform;
                 item.transform.localScale = new Vector3(1, 1, 1);
             }
         }
         else
         {
             int childs = parentGrid.transform.childCount;
             for (int i = 0; i < childs; i++)
             {
                 Destroy(parentGrid.transform.GetChild(i).gameObject);
             }
             EggBasicDAO     eggBasic = new EggBasicDAO();
             List <EggBasic> lista    = eggBasic.GetEggBasicList().ToList();
             for (int i = 0; i < lista.Count(); i++)
             {
                 GameObject egg = Instantiate(prefabEgg) as GameObject;
                 egg.GetComponent <BotonComprarHuevo>().sePuedeComprar = true;
                 egg.GetComponent <BotonEquiparHuevo>().sePuedeEquipar = false;
                 egg.transform.name = lista [i].Category;
                 egg.GetComponentInChildren <UILabel> ().text = "Huevo " + lista [i].Category + " Precio: " + lista[i].Price;
                 egg.transform.parent     = parentGrid.transform;
                 egg.transform.localScale = new Vector3(1, 1, 1);
             }
         }
         PlayerDAO playerDAO = new PlayerDAO();
         labelOroActual.GetComponent <UILabel>().text      = "Oro: " + playerDAO.GetPlayer().Gold;
         parentGrid.GetComponent <UIGrid> ().repositionNow = true;
         actualizarTienda = false;
     }
 }
Ejemplo n.º 7
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;
        }
    }
Ejemplo n.º 8
0
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(instance);
        }

        PlayerDAO player = new PlayerDAO();

        if (player.GetPlayer() == null)
        {
            UIController.instance.MostrarPanelNuevoJugador();
        }
        else
        {
            UIController.instance.MostrarPanelContinuar();
        }
        ImpedirMovimientoJugador();
    }
Ejemplo n.º 9
0
 public Player GetPlayer(int playerid)
 {
     return(playerDAO.GetPlayer(playerid));
 }
Ejemplo n.º 10
0
    public void GenerarBatalla()
    {
        UILabel label = texto.GetComponent <UILabel> ();

        label.text = "";
        PokemonBasicDAO     pkmBasic = new PokemonBasicDAO();
        PokemonOwnedDAO     pkmOwned = new PokemonOwnedDAO();
        PlayerDAO           player   = new PlayerDAO();
        List <PokemonOwned> lista    = pkmOwned.GetEquippedPokemon().ToList();
        PokemonOwned        owned    = lista [0];
        PokemonOwned        enemy    = pkmOwned.GenerarAleatorio();

        while (enemy.Level != owned.Level)
        {
            enemy.LevelUp();
        }
        if (enemy.Speed >= owned.Speed)
        {
            miTurno = false;

            sprite1.GetComponent <UISprite> ().spriteName = owned.IdBasic + "";
            sprite2.GetComponent <UISprite> ().spriteName = enemy.IdBasic + "";

            datosPrimero.GetComponent <UILabel> ().text = pkmBasic.GetPokemon(owned.IdBasic).Name;
            datosSegundo.GetComponent <UILabel> ().text = pkmBasic.GetPokemon(enemy.IdBasic).Name;

            while (enemy.Hp > 0 && owned.Hp > 0)
            {
                if (miTurno)
                {
                    int dano = owned.Attack - enemy.Defense / 2;
                    if (dano < 0)
                    {
                        dano = 0;
                    }
                    enemy.Hp  -= dano;
                    miTurno    = false;
                    label.text = label.text + "\nMi turno. Aliado infringe " + dano + " puntos de daño. Hp actual del enemigo: " + enemy.Hp;
                }
                else
                {
                    int dano = enemy.Attack - owned.Defense / 2;
                    if (dano < 0)
                    {
                        dano = 0;
                    }
                    owned.Hp  -= dano;
                    miTurno    = true;
                    label.text = label.text + "\nTurno del enemigo. Enemigo infringe " + dano + " puntos de daño. Hp actual del aliado: " + owned.Hp;
                }
            }


            if (owned.Hp < 1)
            {
                pkmOwned.UpdatePokemonHealth(owned.Id, owned.Hp);
                label.text = label.text + "\n\nBatalla perdida, pierdes " + enemy.Hp + " de oro";
                player.UpdateGold(player.GetPlayer().Gold - enemy.Hp);
            }
            else
            {
                pkmOwned.UpdatePokemonHealth(owned.Id, owned.Hp);
                label.text = label.text + "\n\nBatalla ganada, ganas " + owned.Hp + " de oro";
                player.UpdateGold(player.GetPlayer().Gold + owned.Hp);
            }
        }
    }