public void LevelUp() { PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); PokemonOwnedDAO pkmOwned = new PokemonOwnedDAO(); PokemonBasic basico = pkmBasic.GetPokemon(IdBasic); Level++; if (Level == basico.EvolvesAt) { pkmOwned.Evolucionar(Id); } else { HpTotal += Mathf.FloorToInt(Random.Range(2, 5)); Attack += Mathf.FloorToInt(Random.Range(2, 5)); Defense += Mathf.FloorToInt(Random.Range(2, 5)); SpecialAttack += Mathf.FloorToInt(Random.Range(2, 5)); SpecialDefense += Mathf.FloorToInt(Random.Range(2, 5)); Speed += Mathf.FloorToInt(Random.Range(2, 5)); Happyness += Mathf.FloorToInt(Random.Range(10, 50)); CurrentHappyness = Happyness; CurrentExperience = 0; ExperienceNeeded = GameController.instance.CalcularExperienciaNecesaria(this); } }
void Update() { if (actualizarLista) { int childs = parentGrid.transform.childCount; for (int i = 0; i < childs; i++) { Destroy(parentGrid.transform.GetChild(i).gameObject); } PokemonOwnedDAO pkmOwned = new PokemonOwnedDAO(); PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); List <PokemonOwned> lista = pkmOwned.GetNotEquippedPokemon().ToList(); for (int i = 0; i < lista.Count(); i++) { GameObject pokemon = Instantiate(prefabSacarPokemon) as GameObject; pokemon.transform.name = "" + lista[i].Id; pokemon.GetComponentInChildren <UISprite>().spriteName = lista[i].IdBasic + ""; PokemonBasic basic = pkmBasic.GetPokemon(lista[i].IdBasic); pokemon.GetComponentInChildren <UILabel>().text = basic.Name + " Nivel " + lista[i].Level; pokemon.transform.parent = parentGrid.transform; pokemon.transform.localScale = new Vector3(1, 1, 1); } parentGrid.GetComponent <UIGrid>().repositionNow = true; actualizarLista = false; } }
public void Evolucionar(int id) { PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); PokemonOwned pokemonOwned = GetPokemon(id); PokemonBasic pokemonBasic = pkmBasic.GetPokemon(pokemonOwned.IdBasic); PokemonBasic evolution = pkmBasic.GetPokemon(pokemonBasic.EvolvesTo); pokemonOwned.IdBasic = evolution.Id; pokemonOwned.Hp = pokemonBasic.BasicHp; pokemonOwned.HpTotal = pokemonBasic.BasicHp; pokemonOwned.Attack = pokemonBasic.BasicAttack; pokemonOwned.Defense = pokemonBasic.BasicDefense; pokemonOwned.SpecialAttack = pokemonBasic.BasicSpecialAttack; pokemonOwned.SpecialDefense = pokemonBasic.BasicSpecialDefense; pokemonOwned.Speed = pokemonBasic.BasicSpeed; pokemonOwned.CurrentExperience = 0; pokemonOwned.ExperienceNeeded = GameController.instance.CalcularExperienciaNecesaria(pokemonOwned); UpdatePokemon(pokemonOwned.Id, pokemonOwned); }
void Update() { PokemonOwnedDAO pkmOwned = new PokemonOwnedDAO(); PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); List <PokemonOwned> lista = pkmOwned.GetEquippedPokemon().ToList(); nombre.GetComponent <UILabel>().text = pkmBasic.GetPokemon(lista[2].IdBasic).Name; descripcion.GetComponent <UILabel>().text = pkmBasic.GetPokemon(lista[2].IdBasic).Description; UILabel datos = stats.GetComponent <UILabel>(); datos.text = ""; datos.text += "Nvl: " + lista[2].Level; datos.text += "\nHp: " + lista[2].Hp + "/" + lista[2].HpTotal; datos.text += "\nAtaque: " + lista[2].Attack; datos.text += "\nDefensa: " + lista[2].Defense; datos.text += "\nAtaque especial: " + lista[2].SpecialAttack; datos.text += "\nDefensa especial: " + lista[2].SpecialDefense; datos.text += "\nVelocidad: " + lista[2].Speed; datos.text += "\nAguante: " + lista[2].CurrentHappyness + "/" + lista[2].Happyness; datos.text += "\nExperiencia: " + lista[2].CurrentExperience + "/" + lista[2].ExperienceNeeded; sprite.GetComponent <UISprite> ().spriteName = lista[2].IdBasic + ""; }
void Start() { PokemonOwnedDAO pkmOwned = new PokemonOwnedDAO(); PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); EggOwnedDAO eggOwned = new EggOwnedDAO(); List <PokemonOwned> listPokemon = pkmOwned.GetEquippedPokemon().ToList(); if (listPokemon.Count() == 1) { pokemon1.GetComponent <UISprite> ().spriteName = (listPokemon [0].IdBasic) + ""; PokemonBasic basico = pkmBasic.GetPokemon(listPokemon [0].Id); Debug.Log(basico); primerNombre.GetComponent <UILabel> ().text = basico.Name + " Nvl " + listPokemon [0].Level; } else if (listPokemon.Count() == 2) { pokemon1.GetComponent <UISprite> ().spriteName = (listPokemon [0].IdBasic) + ""; PokemonBasic basico = pkmBasic.GetPokemon(listPokemon [0].IdBasic); primerNombre.GetComponent <UILabel> ().text = basico.Name + " Nvl: " + listPokemon [0].Level; pokemon2.GetComponent <UISprite> ().spriteName = (listPokemon [1].IdBasic) + ""; PokemonBasic segundoBasico = pkmBasic.GetPokemon(listPokemon [1].IdBasic); segundoNombre.GetComponent <UILabel> ().text = segundoBasico.Name + " Nvl: " + listPokemon [1].Level; } else if (listPokemon.Count() == 3) { pokemon1.GetComponent <UISprite> ().spriteName = (listPokemon [0].IdBasic) + ""; PokemonBasic basico = pkmBasic.GetPokemon(listPokemon [0].IdBasic); primerNombre.GetComponent <UILabel> ().text = basico.Name + " Nvl: " + listPokemon [0].Level; pokemon2.GetComponent <UISprite> ().spriteName = (listPokemon [1].IdBasic) + ""; PokemonBasic segundoBasico = pkmBasic.GetPokemon(listPokemon [1].IdBasic); segundoNombre.GetComponent <UILabel> ().text = segundoBasico.Name + " Nvl: " + listPokemon [1].Level; pokemon3.GetComponent <UISprite> ().spriteName = (listPokemon [2].IdBasic) + ""; PokemonBasic tercerBasico = pkmBasic.GetPokemon(listPokemon [2].IdBasic); tercerNombre.GetComponent <UILabel> ().text = tercerBasico.Name + " Nvl: " + listPokemon [2].Level; } if (eggOwned.GetEquippedEgg() != null) { huevo.GetComponent <UILabel> ().text = "Huevo " + eggOwned.GetEquippedEgg().Category; huevoSprite.GetComponent <UISprite>().spriteName = "Egg"; huevoSprite.GetComponent <UISprite>().transform.localScale = new Vector3(200, 200, 1); } else { huevoSprite.GetComponent <UISprite>().spriteName = "0"; } }
public PokemonOwned GenerarAleatorio() { PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); int num = Mathf.FloorToInt(Random.Range(1, pkmBasic.GetAllPokemon().ToList().Count())); PokemonBasic pokemonBasic = pkmBasic.GetPokemon(num); PokemonOwned pokemonOwned = new PokemonOwned(); pokemonOwned.Hp = pokemonBasic.BasicHp; pokemonOwned.HpTotal = pokemonBasic.BasicHp; pokemonOwned.Attack = pokemonBasic.BasicAttack; pokemonOwned.Defense = pokemonBasic.BasicDefense; pokemonOwned.SpecialAttack = pokemonBasic.BasicSpecialAttack; pokemonOwned.SpecialDefense = pokemonBasic.BasicSpecialDefense; pokemonOwned.Speed = pokemonBasic.BasicSpeed; pokemonOwned.Happyness = 100; pokemonOwned.CurrentExperience = 0; pokemonOwned.Level = 5; pokemonOwned.IdBasic = pokemonBasic.Id; return(pokemonOwned); }
public int CalcularExperienciaNecesaria(PokemonOwned pokemonOwned) { PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); int exp = 0; switch (pkmBasic.GetPokemon(pokemonOwned.IdBasic).GrowthRate) { case "Fast": exp = Mathf.FloorToInt((4 * pokemonOwned.Level * pokemonOwned.Level * pokemonOwned.Level) / 5); break; case "Medium": exp = Mathf.FloorToInt(pokemonOwned.Level * pokemonOwned.Level * pokemonOwned.Level); break; case "Slow": exp = Mathf.FloorToInt((5 * pokemonOwned.Level * pokemonOwned.Level * pokemonOwned.Level) / 4); break; } return(exp); }
void Update() { PokemonOwnedDAO pkmOwned = new PokemonOwnedDAO(); List <PokemonOwned> listPokemon = pkmOwned.GetEquippedPokemon().ToList(); PokemonBasicDAO pkmBasic = new PokemonBasicDAO(); EggOwnedDAO eggOwned = new EggOwnedDAO(); if (actualizarDatos) { if (listPokemon.Count() == 1) { float amountFirst = (listPokemon [0].CurrentHappyness * 100) / listPokemon [0].Happyness; nombre1.GetComponent <UILabel>().text = pkmBasic.GetPokemon(listPokemon[0].IdBasic).Name + " Nvl: " + listPokemon[0].Level; pokemon1.GetComponent <UISprite> ().spriteName = (listPokemon [0].IdBasic) + ""; GameObject fore = progressBar1.transform.FindChild("ForegroundBar000").gameObject; fore.GetComponent <UISprite> ().fillAmount = (amountFirst / 100); float amountExp = (listPokemon[0].CurrentExperience * 100) / listPokemon[0].ExperienceNeeded; GameObject foreExp = barraExperiencia1.transform.FindChild("ForeExp000").gameObject; foreExp.GetComponent <UISprite>().fillAmount = (amountExp / 100); } else if (listPokemon.Count() == 2) { float amountFirst = (listPokemon [0].CurrentHappyness * 100) / listPokemon [0].Happyness; nombre1.GetComponent <UILabel>().text = pkmBasic.GetPokemon(listPokemon[0].IdBasic).Name + " Nvl: " + listPokemon[0].Level; pokemon1.GetComponent <UISprite> ().spriteName = (listPokemon [0].IdBasic) + ""; GameObject fore = progressBar1.transform.FindChild("ForegroundBar000").gameObject; fore.GetComponent <UISprite> ().fillAmount = (amountFirst / 100); float amountExp = (listPokemon[0].CurrentExperience * 100) / listPokemon[0].ExperienceNeeded; GameObject foreExp = barraExperiencia1.transform.FindChild("ForeExp000").gameObject; foreExp.GetComponent <UISprite>().fillAmount = (amountExp / 100); float amountSecond = ((listPokemon [1].CurrentHappyness * 100) / listPokemon [1].Happyness); nombre2.GetComponent <UILabel>().text = pkmBasic.GetPokemon(listPokemon[1].IdBasic).Name + " Nvl: " + listPokemon[1].Level; pokemon2.GetComponent <UISprite> ().spriteName = (listPokemon [1].IdBasic) + ""; GameObject fore2 = progressBar2.transform.FindChild("ForegroundBar001").gameObject; fore2.GetComponent <UISprite> ().fillAmount = (amountSecond / 100); float amountExp2 = (listPokemon[1].CurrentExperience * 100) / listPokemon[1].ExperienceNeeded; GameObject foreExp2 = barraExperiencia2.transform.FindChild("ForeExp001").gameObject; foreExp2.GetComponent <UISprite>().fillAmount = amountExp2 / 100; } else if (listPokemon.Count() == 3) { float amountFirst = (listPokemon [0].CurrentHappyness * 100) / listPokemon [0].Happyness; nombre1.GetComponent <UILabel>().text = pkmBasic.GetPokemon(listPokemon[0].IdBasic).Name + " Nvl: " + listPokemon[0].Level; pokemon1.GetComponent <UISprite> ().spriteName = (listPokemon [0].IdBasic) + ""; GameObject fore = progressBar1.transform.FindChild("ForegroundBar000").gameObject; fore.GetComponent <UISprite> ().fillAmount = (amountFirst / 100); float amountExp = (listPokemon[0].CurrentExperience * 100) / listPokemon[0].ExperienceNeeded; GameObject foreExp = barraExperiencia1.transform.FindChild("ForeExp000").gameObject; foreExp.GetComponent <UISprite>().fillAmount = (amountExp / 100); float amountSecond = ((listPokemon [1].CurrentHappyness * 100) / listPokemon [1].Happyness); nombre2.GetComponent <UILabel>().text = pkmBasic.GetPokemon(listPokemon[1].IdBasic).Name + " Nvl: " + listPokemon[1].Level; pokemon2.GetComponent <UISprite> ().spriteName = (listPokemon [1].IdBasic) + ""; GameObject fore2 = progressBar2.transform.FindChild("ForegroundBar001").gameObject; fore2.GetComponent <UISprite> ().fillAmount = (amountSecond / 100); float amountExp2 = (listPokemon[1].CurrentExperience * 100) / listPokemon[1].ExperienceNeeded; GameObject foreExp2 = barraExperiencia2.transform.FindChild("ForeExp001").gameObject; foreExp2.GetComponent <UISprite>().fillAmount = amountExp2 / 100; float amountThird = ((listPokemon [2].CurrentHappyness * 100) / listPokemon [2].Happyness); nombre3.GetComponent <UILabel>().text = pkmBasic.GetPokemon(listPokemon[2].IdBasic).Name + " Nvl: " + listPokemon[2].Level; pokemon3.GetComponent <UISprite> ().spriteName = (listPokemon [2].IdBasic) + ""; GameObject fore3 = progressBar3.transform.FindChild("ForegroundBar002").gameObject; fore3.GetComponent <UISprite> ().fillAmount = (amountThird / 100); float amountExp3 = (listPokemon[2].CurrentExperience * 100) / listPokemon[2].ExperienceNeeded; GameObject foreExp3 = barraExperiencia3.transform.FindChild("ForeExp002").gameObject; foreExp3.GetComponent <UISprite>().fillAmount = amountExp3 / 100; } else if (listPokemon.Count() == 0) { pokemon1.GetComponent <UISprite> ().spriteName = "0"; pokemon2.GetComponent <UISprite> ().spriteName = "0"; pokemon3.GetComponent <UISprite> ().spriteName = "0"; } actualizarDatos = false; if (eggOwned.GetEquippedEgg() != null) { EggOwned egg = eggOwned.GetEquippedEgg(); nombreHuevo.GetComponent <UILabel>().text = "Huevo " + egg.Category; float amountEgg = ((egg.CurrentCycles * 100) / egg.TotalCycles); GameObject fore = barraHuevo.transform.FindChild("Foreground").gameObject; spriteHuevo.GetComponent <UISprite>().spriteName = "Egg"; fore.GetComponent <UISprite>().fillAmount = amountEgg / 100; spriteHuevo.GetComponent <UISprite>().transform.localScale = new Vector3(150, 150, 0); } else { spriteHuevo.GetComponent <UISprite>().spriteName = "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); } } }