public int GetDamage(Pokemon attacker, Pokemon defender) { log.Log(attacker.Name + " used Surf on " + defender.Name); double damage = (2 * attacker.Level + 10) / 250.0; double modifier = random.NextDouble() * (1.0 - 0.85) + 0.85; if (random.Critical()) //determines critical hit! { log.Log("Critical Hit!"); modifier *= 2; } if (random.FlipCoin()) //determines which type is hit with. { modifier *= TypeEffectivenessModifier(attacker.Type_1, defender); } else { modifier *= TypeEffectivenessModifier(attacker.Type_2, defender); } damage *= ((attacker.SpecialAttack) / (defender.SpecialDefense)); damage *= 90; damage += 2; damage *= modifier; log.Log("Total damage: " + damage); if (damage == 1) { return 1; } return (int)(Math.Round(damage)); }
//This should handle keys and clicking void OnGUI() { DrawMenu (); if (click && (Input.GetKeyDown (KeyCode.Escape) || Input.GetMouseButtonDown (0) || Input.GetMouseButtonDown (1))) { doPopup = false; click = false; } if (Input.GetMouseButtonDown(1) && !doPopup){ // when button clicked... click = true; Vector2 mousePos = Event.current.mousePosition; mouseX = mousePos.x; mouseY = mousePos.y; /* This iterates through Rect list and checks to see if the mouse is cotained in one of them */ for(int x = 0; x<rectList.Count;x++) { if(rectList[x].Contains(mousePos)) { pokemon = pokemonList[x]; doPopup = true; break; } } } if (doPopup) { Popup (pokemon); } }
void Update() { switch(currentState){ case States.Ready:{ Vector3 direct = Player.This.transform.position - transform.position; if (direct.sqrMagnitude<10*10 && Vector3.Dot(direct, transform.forward)>0){ Dialog.inDialog = true; Dialog.NPCobj = gameObject; Dialog.NPCname = "Young Trainer"; Dialog.text = "You're a pokemon trainer right? That means we have to battle!"; if (Dialog.doneDialog){ Dialog.inDialog = false; //populate pokemon party = new Pokemon[pokemon.Length]; for(int i=0; i<pokemon.Length; i++){ party[i] = new Pokemon((int)(pokemon[i].pokemon), false, pokemon[i].level); party[i].name = pokemon[i].name; } currentState = States.InBattle; trainerPosition = transform.position - direct.normalized*10; } } break;} case States.InBattle: InBattle(); break; } }
public void Damage(Pokemon otherPoke, Move move){ //this must take p account weakness and attributes (defense, attack, sp_Defense, sp_Attack) //this must be object oriented moveCast = move.moveType.ToString () ; switch(move.moveType){ //These attack type and stab are not included. They(included atkpower) will have to be be invoked directly from database and switch wont be required case MoveNames.Tackle:{ int atkPower = 35; damage = ((((2 * otherPoke.level / 5 + 2) * otherPoke.attack * atkPower / defence) / 50) + 2) * Random.Range(217,255)/255; //((2A/5+2)*B*C)/D)/50)+2)*X)*Y/10)*Z)/255 hp -= damage/TotalHP(); isHPZero(); currentHealth -= damage; GiveXP(10); break; } case MoveNames.Scratch:{ int atkPower = 35; damage = ((((2 * otherPoke.level / 5 + 2) * otherPoke.attack * atkPower / defence) / 50) + 2) * Random.Range(217,255)/255; //((2A/5+2)*B*C)/D)/50)+2)*X)*Y/10)*Z)/255 hp -= damage/TotalHP(); isHPZero(); GiveXP(10); break; } } }
void updatePokemonStats() { poke = Party.S.party [Party.S.activeItem]; nam = this.transform.Find ("NameAndLevel").gameObject; atk1 = this.transform.Find ("Attack1").gameObject; atk2 = this.transform.Find ("Attack2").gameObject; atk3 = this.transform.Find ("Attack3").gameObject; atk4 = this.transform.Find ("Attack4").gameObject; atk = this.transform.Find ("Attack").gameObject; def = this.transform.Find ("Defense").gameObject; spl = this.transform.Find ("Special").gameObject; spd = this.transform.Find ("Speed").gameObject; exp = this.transform.Find ("EXPtoNext").gameObject; GUIText gui = nam.GetComponent<GUIText> (); gui.text = poke.Name + " lvl " + poke.Level; gui = atk1.GetComponent<GUIText> (); gui.text = poke.Attacks [0].AttackName + " " + poke.Attacks [0].AttackType + " " + poke.Attacks [0].AttackPPRemaining + "/" + poke.Attacks [0].AttackPP; gui = atk2.GetComponent<GUIText> (); if (poke.Attacks [1].AttackName == "-") { gui.text = "-"; } else { gui.text = poke.Attacks [1].AttackName + " " + poke.Attacks [1].AttackType + " " + poke.Attacks [1].AttackPPRemaining + "/" + poke.Attacks [1].AttackPP; } gui = atk3.GetComponent<GUIText> (); if (poke.Attacks [2].AttackName == "-") { gui.text = "-"; } else { gui.text = poke.Attacks [2].AttackName + " " + poke.Attacks [2].AttackType + " " + poke.Attacks [2].AttackPPRemaining + "/" + poke.Attacks [2].AttackPP; } gui = atk4.GetComponent<GUIText> (); if (poke.Attacks [3].AttackName == "-") { gui.text = "-"; } else { gui.text = poke.Attacks [3].AttackName + " " + poke.Attacks [3].AttackType + " " + poke.Attacks [3].AttackPPRemaining + "/" + poke.Attacks [3].AttackPP; } gui = atk.GetComponent<GUIText> (); gui.text = "Attack: " + poke.AttackStat; gui = def.GetComponent<GUIText> (); gui.text = "Defense: " + poke.DefenseStat; gui = spl.GetComponent<GUIText> (); gui.text = "Special: " + poke.SpecialStat; gui = spd.GetComponent<GUIText> (); gui.text = "Speed: " + poke.SpeedStat; gui = exp.GetComponent<GUIText> (); gui.text = "Experience to next level: " + (poke.ExperienceToNext - poke.ExperienceCurrent); }
public trdata6(byte[] trData, byte[] trPoke, bool ORAS) { using (BinaryReader br = new BinaryReader(new MemoryStream(trData))) { isORAS = ORAS; Format = ORAS ? br.ReadUInt16() : br.ReadByte(); Class = ORAS ? br.ReadUInt16() : br.ReadByte(); if (ORAS) uORAS = br.ReadUInt16(); Item = ((Format >> 1) & 1) == 1; Moves = (Format & 1) == 1; BattleType = br.ReadByte(); NumPokemon = br.ReadByte(); for (int i = 0; i < 4; i++) Items[i] = br.ReadUInt16(); AI = br.ReadByte(); u1 = br.ReadByte(); u2 = br.ReadByte(); u3 = br.ReadByte(); Healer = br.ReadByte() != 0; Money = br.ReadByte(); Prize = br.ReadUInt16(); // Fetch Team Team = new Pokemon[NumPokemon]; byte[][] TeamData = new byte[NumPokemon][]; int dataLen = trPoke.Length / NumPokemon; for (int i = 0; i < TeamData.Length; i++) TeamData[i] = trPoke.Skip(i * dataLen).Take(dataLen).ToArray(); for (int i = 0; i < NumPokemon; i++) Team[i] = new Pokemon(TeamData[i], Item, Moves); } }
public int GetDamage(Pokemon attacker, Pokemon defender) { //log.Log(attacker.Name + " used Pound on " + defender.Name); double damage = (2 * attacker.Level + 10) / 250.0; double modifier = random.NextDouble() * (1.0 - 0.85) + 0.85; if (random.Critical()) //determines critical hit! { //log.Log("Critical Hit!"); modifier *= 2; } if (random.FlipCoin()) //determines which type is hit with. { modifier *= attacker.Type_1_Chart[defender.Type_1]; modifier *= attacker.Type_1_Chart[defender.Type_2]; } else { modifier *= attacker.Type_1_Chart[defender.Type_1]; modifier *= attacker.Type_1_Chart[defender.Type_2]; } damage *= (double) attacker.AttackPower / (double) defender.Defense; damage *= 40; damage += 2; damage *= modifier; //log.Log("Total damage: " + damage); if (damage == 0) { return 1; } return (int)(Math.Round(damage)); }
void InBattle() { //move trainer to position Vector3 direct = trainerPos-transform.position; direct.y = 0; if (direct.sqrMagnitude>2){ transform.rotation = Quaternion.LookRotation(direct); GetComponent<Animator>().SetBool("run", true); }else{ if (direct.sqrMagnitude>1) transform.position += direct; if (currentPokemon==null){ currentPokemon = trainer.pokemon[0]; } if (currentPokemon.obj!=null){ direct = currentPokemon.obj.transform.position-transform.position; }else{ direct = enemyTrainer.transform.position-transform.position; } direct.y = 0; transform.rotation = Quaternion.LookRotation(direct); GetComponent<Animator>().SetBool("run", false); if (currentPokemon.obj==null) trainer.ThrowPokemon(trainer.pokemon[0]); } /*if (currentPokemonObj!=null){ PokemonTrainer pokeComp = currentPokemonObj.GetComponent<PokemonTrainer>; if (pokeComp!=null){ if (Player.pokemonObj!=null){ pokeComp.AttackEnemy(Player.pokemonObj); } } }*/ }
//Creates a box for a Pokemon Overview. Currently shows a base stat overview for the current //selected pokemon. Having trouble converting out move and item names for the overview. //Currently has hard coded names for items/moves to test UI spacing. public void OpenStatWindow(Pokemon pkmn) { if (dataWindow) { GUI.DrawTexture (new Rect (Screen.width - 275, Screen.height - 250, 250, 250), GUImgr.gradRight); /*foreach (var slot in Player.trainer.party.GetSlots ()) { var pokemon = slot.pokemon; if (party.IsActive (pokemon)) {*/ GUI.Label (new Rect (Screen.width - 270, Screen.height - 245, 200, 25), pkmn.GetName ()); GUI.Label (new Rect (Screen.width - 270, Screen.height - 215, 75, 25), "HP: " + pkmn.CurrentHP () + "/" + pkmn.TotalHP ()); GUI.Label (new Rect (Screen.width - 270, Screen.height - 185, 75, 25), "Atk: " + pkmn.TotalAttack ()); GUI.Label (new Rect (Screen.width - 270, Screen.height - 155, 75, 25), "Def: " + pkmn.TotalDefence ()); GUI.Label (new Rect (Screen.width - 270, Screen.height - 125, 75, 25), "Spd: " + pkmn.TotalSpeed ()); //As far as I can tell, held items aren't implemented, so I'm just hardcoding None. GUI.Label (new Rect (Screen.width - 195, Screen.height - 215, 190, 25), "Item: None" /*+ pokemon.GetItemName()*/); int height = 185; int loop = 1; foreach (Move mve in pkmn.moves) { if (loop > 4) break; GUI.Label (new Rect (Screen.width - 195, Screen.height - height, 190, 25), "Move " + loop + ": " + mve.ToFriendlyString ()); loop++; height -= 30; } } //GUI.Label (new Rect (Screen.width - 195, Screen.height - 185, 190, 25), "Move 1: Hydro Cannon" /*+ pokemon.GetMoveName(0)*/); //GUI.Label (new Rect (Screen.width - 195, Screen.height - 155, 190, 25), "Move 2: " /*+ pokemon.GetMoveName(0)*/); //GUI.Label (new Rect (Screen.width - 195, Screen.height - 125, 190, 25), "Move 3: " /*+ pokemon.GetMoveName(0)*/); //GUI.Label (new Rect (Screen.width - 195, Screen.height - 95, 190, 25), "Move 4: " /*+ pokemon.GetMoveName(0)*/); }
// Use this for initialization void Start() { Attack tackle = new Attack (); Attack tackle2 = new Attack (); Attack tackle3 = new Attack (); Attack tackle4 = new Attack (); Pokemon nikuh = new Pokemon (); tackle.aname = "Milchmelker"; tackle.ap = 30; tackle.maxAp = 30; tackle.precise = 100; tackle.strenght = 10; tackle.type = Attack.Type.physical; tackle2.aname = "Gemuhe"; tackle2.ap = 20; tackle2.maxAp = 30; tackle2.precise = 100; tackle2.strenght = 10; tackle2.type = Attack.Type.physical; tackle3.aname = "Hufstampfer"; tackle3.ap = 10; tackle3.maxAp = 30; tackle3.precise = 100; tackle3.strenght = 10; tackle3.type = Attack.Type.physical; tackle4.aname = "Dubstepkanone"; tackle4.ap = 40; tackle4.maxAp = 50; tackle4.precise = 100; tackle4.strenght = 10; tackle4.type = Attack.Type.physical; nikuh.name = "Nikuh"; nikuh.attack = 20; nikuh.defense = 15; nikuh.specialAttack = 13; nikuh.specialDefense = 8; nikuh.experience = 300; nikuh.level = 6; nikuh.id = 0; nikuh.pokedexId = 1; nikuh.trainer = InterSceneData.main.playerName; nikuh.types = new Pokemon.Type[10]; nikuh.types [0] = Pokemon.Type.grass; nikuh.maxHp = 50; nikuh.hp = 50; nikuh.picture = Resources.LoadAll<Sprite> ("Sprites/pokemon_battle")[245]; nikuh.attacks = new Attack[4]; nikuh.attacks [0] = tackle; nikuh.attacks [1] = tackle2; nikuh.attacks [2] = tackle3; nikuh.attacks [3] = tackle4; insertPokemon (nikuh); }
public Client(ClientIdentifier id) { Id = id; var stats = new Stats { Atk = 10, Def = 10, HP = 30, SpAtk = 10, SpDef = 10, Speed = 10 }; var data = new PokemonData { Id = 0, Type1 = PokemonType.Normal, BaseStats = stats }; var moveData = new MoveData { Name = "Move", Accuracy = 100, Damage = 120, DamageType = DamageCategory.Physical, PokemonType = PokemonType.Normal, PP = 20 }; for (int i = 0; i < 6; i++) { var pkmn = new Pokemon(data, stats) { Name = Id.Name + "_Pkmn" + i, Level = i + 20}; for (int j = 0; j < 2; j++) pkmn.SetMove(j, new Move(moveData)); pkmn.Stats.HP = 30; pkmn.HP = 30; pokemons.Add(pkmn); } }
static void composePoke() { PokemonArray[0] = new Pokemon(); PokemonArray[0].pokename = "Bulbasaur"; PokemonArray[0].type = "Grass"; PokemonArray[0].hp = 45; PokemonArray[0].attack = 49; PokemonArray[0].defence = 49; PokemonArray[0].speed = 45; PokemonArray[0].move = new Move[] { MoveArray[0], MoveArray[1], MoveArray[2], MoveArray[3] }; PokemonArray[1] = new Pokemon(); PokemonArray[1].pokename = "Charmander"; PokemonArray[1].type = "Fire"; PokemonArray[1].hp = 39; PokemonArray[1].attack = 52; PokemonArray[1].defence = 43; PokemonArray[1].speed = 65; PokemonArray[2] = new Pokemon(); PokemonArray[2].pokename = "Squirtle"; PokemonArray[2].type = "Water"; PokemonArray[2].hp = 44; PokemonArray[2].attack = 48; PokemonArray[2].defence = 65; PokemonArray[2].speed = 43; PokemonArray[3] = new Pokemon(); PokemonArray[3].pokename = "Pikachu"; PokemonArray[3].type = "Electric"; PokemonArray[3].hp = 35; PokemonArray[3].attack = 55; PokemonArray[3].defence = 40; PokemonArray[3].speed = 90; }
void LateUpdate() { pokemon = Player.pokemon; pokemonActive = Player.pokemonActive; trainer = Player.trainer; Quaternion camRot = transform.rotation; if (Dialog.NPCobj=null){ //focus on person speaking to you Vector3 camFocus = Dialog.NPCobj.transform.position+Vector3.up; transform.rotation = Quaternion.LookRotation(transform.position-camFocus); }else{ if (pokemon.obj!=null && pokemonActive){ //focus on current pokemon cameraFocus = pokemon.obj.transform.position + Vector3.up; transform.rotation = pokemon.obj.transform.rotation * Quaternion.Euler(ax,0,0); }else{ //focus on player cameraFocus = trainer.transform.position+Vector3.up*2; transform.rotation = Quaternion.Euler(ax,ay,0); } } transform.position = cameraFocus; transform.Translate(0,0,-cameraZoom); transform.position = Vector3.Lerp(camPos, transform.position, Time.deltaTime*5); transform.rotation = Quaternion.Lerp(camRot, transform.rotation, Time.deltaTime*5); camPos = transform.position; RaycastHit hit; Vector3 camDirect = transform.position - cameraFocus; if (Physics.Raycast(cameraFocus, camDirect, out hit, camDirect.magnitude, 1)){ transform.position = hit.point - camDirect.normalized*0.5f; } }
private void btSerializer_Click(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); Pokemon p = new Pokemon(@"DescriptionPokemon\Pikachu.xml", FileType.Description); sw.Start(); XmlSerializer xs = null; try { xs = new XmlSerializer(typeof(Pokemon)); } catch (InvalidOperationException ex) { MessageBox.Show(ex.InnerException.Message); return; } sw.Stop(); MessageBox.Show("Instance XmlSerializer: " + sw.Elapsed.TotalMilliseconds.ToString()); sw.Reset(); Stream s = File.Create("pokétest.xml"); sw.Start(); xs.Serialize(s, p); sw.Stop(); s.Close(); MessageBox.Show("Serialization: " + sw.Elapsed.TotalMilliseconds.ToString()); }
private void btCherche_Click(object sender, EventArgs e) { if (ComboPok閙on.Text != "") { try { //TODO modifier l'acc鑣 au pok閙on par l'index du combo Pokemon p = X.PKlist[ComboPok閙on.SelectedIndex]; if (p.dependevo) { Pokemon evo = X.GetPok閙on(p.evolution.ToArray()[0].nom); Pokemon p2 = new Pokemon(); X.CopyPokemon(p, p2); p2.Oeuf1 = evo.Oeuf1; p2.Oeuf2 = evo.Oeuf2; X.argPokemon = p2; } else X.argPokemon = p; Stack<Capacite> cap = new Stack<Capacite>(); if (txtCapacit�Text == "" && txtCapacit�Text == "" && txtCapacit�Text == "" && txtCapacit�Text == "") { MessageBox.Show("Capacit� mal s閘ectionn�, click eul' nom dans la bo顃e!"); return; } if (txtCapacit�Text != "") cap.Push(Xblood.GetCapacite(txtCapacit�Text)); if (txtCapacit�Text != "") cap.Push(Xblood.GetCapacite(txtCapacit�Text)); if (txtCapacit�Text != "") cap.Push(Xblood.GetCapacite(txtCapacit�Text)); if (txtCapacit�Text != "") cap.Push(Xblood.GetCapacite(txtCapacit�Text)); X.argCapacite = cap.ToArray(); X.deepness = (int)NumUDDepth.Value; lblBranches.Text = ""; lblLeaf.Text = ""; lblResult.Text = "Recherche..."; btChercher.Enabled = false; btStop.Enabled = true; t = new Thread(new ThreadStart(X.StartThread)); //t.Priority = ThreadPriority.AboveNormal; t.Start(); timer1.Start(); } catch { MessageBox.Show("Pok閙on mal s閘ectionn�, click eul' nom dans la bo顃e!"); } } else TVr閟ultat.Nodes.Clear(); }
public static Pokemon CreatePokemon(int numMoves) { var pkmn = new Pokemon(new PokemonData(), new Stats()); for (int i = 0; i < numMoves; i++) pkmn.SetMove(i, new Move(new MoveData { Name = GetMoveName(i) })); return pkmn; }
public static MoveModel CreateModel(Pokemon pkmn) { var wrapper = new PokemonWrapper(new ClientIdentifier()); if(pkmn != null) wrapper.Pokemon = pkmn; return CreateModel(wrapper); }
public void OpenBattle(Pokemon enemy) { BattleMain.S.setFirstPokemon (); Application.LoadLevelAdditive ("_Battle"); BattleMain.S.enemy = enemy; //BattleMain.S.EnemyName = enemy.Name; Main.S.inBattle = true; }
public bool CheckFor(Pokemon pok) { if (pokemon.Contains (pok)) { return true; } else { return false; } }
public void CharactorRevise(Pokemon pokemon) { pokemon.attack *= GetCharactorRatio (pokemon.charactor, PokeValue.Attack); pokemon.magicAttack *= GetCharactorRatio (pokemon.charactor, PokeValue.MagicAttack); pokemon.defend *= GetCharactorRatio (pokemon.charactor, PokeValue.Defend); pokemon.magicDefend *= GetCharactorRatio (pokemon.charactor, PokeValue.MagicDefend); pokemon.attack *= GetCharactorRatio (pokemon.charactor, PokeValue.Attack); }
void OnGUI() { if (activeTarget && targetedPokemon != null) { pokemonWild = targetedPokemon.GetComponent<PokemonWild>(); pokemon = pokemonWild.pokemonObj.pokemon; battleGUI.pokemonObj = pokemonWild.pokemonObj; //battleGUI.ToggleHud(); battleGUI.EnemyTargetWindow(pokemon); } }
public void setFirstPokemon() { int i = 0; while (Player.S.party[i].HealthCurrent < 1) { ++i; } FirstPokemon = i; currentPokemon = Player.S.party [FirstPokemon]; }
int Damage(Pokemon attacker, Pokemon defender, Attack attack) { float Dmg = ((2f * attacker.Level + 10f) / 250f) * attack.AttackPower; float attackStat = attack.IsPhysical == true ? attacker.AttackStat : attacker.SpecialStat; float defenseStat = attack.IsPhysical == true ? defender.DefenseStat : defender.SpecialStat; Dmg *= (attackStat/defenseStat); Dmg = (Dmg * 10) % 10 >= 5 ? Mathf.Ceil(Dmg) : Mathf.Floor(Dmg); int damg = (int)Dmg; return damg; }
void ThrowPokemon(Pokemon poke) { pokemonActive = true; GameObject ball = (GameObject)Instantiate(Resources.Load("Pokeball")); ball.transform.position = transform.position; ball.rigidbody.AddForce( (transform.forward*2+ transform.up)*500 ); ball.GetComponent<Pokeball>().pokemon = poke; ball.GetComponent<Pokeball>().trainer = gameObject; //gamegui.SetChatWindow(ball.GetComponent<Pokeball>().pokemon.GetName() + "! I choose you!"); }
private void Pipe_OnSocketSend(Pokemon.Packets.NetworkMessage msg) { int length = msg.GetUInt16(); if (msg.GetByte() == (byte)PipePacketType.HookSentPacket) { byte[] buf = new byte[msg.GetData().Length - 3]; Array.Copy(msg.GetData(), 3, buf, 0, buf.Length); ProcessFromClient(buf); } }
public void CheckForCommands(ChannelMessageEventArgs command) { if (enabled == false) return; if (awaitingRelease && currentOperator != command.From) return; if (awaitingChallenger && currentOperator == command.From && !command.Message.Contains("!battle")) return; if (!busy || awaitingRelease || awaitingChallenger) if (command.Message.StartsWith("!")) if (CheckForUser(command.From, command)) { currentOperator = command.From; if (command.Message.Contains("!pokemon")) { ParsePokemon(command); } if (command.Message.Contains("!pokeball")) { StartCoroutine(Pokeball(command, useMasterball)); } if (command.Message.Contains("!trainer")) { TwitchIrc.Instance.Message("Feature under construction. Please check back later to learn more about yourself!"); } if (command.Message.Contains("!battle")) { if (!awaitingChallenger) { if (trainerList[command.From].pokemon.Count >= 1) { combatantOne = command.From; string[] s = command.Message.Split(' '); if (s.Length == 2) if (trainerList[command.From].pokemon[Convert.ToInt16(s[1])].name != null) combatantOnePokemon = trainerList[command.From].pokemon[Convert.ToInt16(s[1])]; else combatantOnePokemon = trainerList[command.From].pokemon[UnityEngine.Random.Range(0, trainerList[command.From].pokemon.Count - 1)]; awaitingChallenger = true; TwitchIrc.Instance.Message(command.From + " has issued a challenge to all Trainers. Who will accept? (use !battle # to accept)"); } } else { if (trainerList[command.From].pokemon.Count >= 1) { combatantTwo = command.From; string[] s = command.Message.Split(' '); if (s.Length == 2) combatantTwoPokemon = trainerList[command.From].pokemon[Convert.ToInt16(s[1])]; else combatantTwoPokemon = trainerList[command.From].pokemon[UnityEngine.Random.Range(0, trainerList[command.From].pokemon.Count - 1)]; awaitingChallenger = false; //StartCoroutine(Battle()); } } } if (command.Message.Contains("!help")) { TwitchIrc.Instance.Message("Commands available to play Pokemon are: !pokemon, !pokeball, !battle, and !trainer."); } } }
Attack EnemyAI(Pokemon enemy) { //picks a random attack int i = 0; foreach (Attack att in enemy.Attacks) { if(att.AttackName != "-") ++i; } i = Random.Range (0, i - 1); return enemy.Attacks [i]; }
public override void Use(Pokemon self, Pokemon target) { if (category == SkillCategory.Physical) { target.HP -= self.attack + power - target.defend; } else { target.HP -= self.magicAttack + power - target.magicDefend; } }
public override void SetCharacter(ClientIdentifier id, Pokemon pkmn) { if (!clients.ContainsKey(id)) throw new InvalidOperationException("ClientIdentifier " + id.Name + " not found."); if (clients[id] != null) throw new InvalidOperationException("ClientIdentifer " + id.Name + " has already set its char"); clients[id] = pkmn; clientsLeft--; }
public virtual void Kick(Pokemon enemy) { if (enemy.Armor > 0) { enemy.Armor -= Damage; if (enemy.Armor < 0) enemy.Health += enemy.Armor; } else { enemy.Health -= Damage; } }
public IEnumerator SingleAttack(Pokemon attacker, Pokemon defender, int moveIndex) { MoveInSet moveInSet = attacker.moveset[moveIndex]; yield return(StartCoroutine(SingleAttack(attacker, defender, moveInSet))); }
public virtual void MoveLogic(Pokemon target) { target.pokemonStats.TakeDamage(damage, moveTyping); }
public virtual BTLUI_PokemonHUD GetPokemonHUD(Pokemon pokemon) { Debug.LogWarning("Unimplimented!"); return(null); }
public IEnumerable <PokemonData> GetHighestPerfect(int count) { return(Pokemon.OrderByDescending(PokemonInfo.CalculatePokemonPerfection).Take(count)); }
// Command Panel public virtual void SetCommands(Pokemon pokemon, IEnumerable <BattleCommandType> commandList) { }
public virtual void SetPokemonHUDActive(Pokemon pokemon, bool active) { }
public void DeletePokemon(Pokemon pokemon) { listPkm.Remove(pokemon); }
public virtual void SwitchSelectedPartyMemberTo(Pokemon selected) { }
public PokemonData GetBestPokemonByCp(PokemonId pokemonId) { return(Pokemon.OrderByDescending(x => x.Cp).FirstOrDefault(t => t.PokemonId == pokemonId)); }
private void loadFakeData() { Pokemon pok1 = new Pokemon("DracoFeu", new Caracteristiques(100, 20, 10, 10), ETypeElement.Feu); Pokemon pok2 = new Pokemon("Tortank", new Caracteristiques(100, 20, 10, 10), ETypeElement.Eau); Pokemon pok3 = new Pokemon("Miaou", new Caracteristiques(520, 80, 10, 10), ETypeElement.Feu); Pokemon pok4 = new Pokemon("Florizarre", new Caracteristiques(250, 50, 30, 50), ETypeElement.Plante); Pokemon pok5 = new Pokemon("PIKACHU", new Caracteristiques(150, 20, 10, 10), ETypeElement.Tonnerre); Pokemon pok6 = new Pokemon("Nidoran", new Caracteristiques(175, 70, 10, 20), ETypeElement.Insecte); Pokemon pok7 = new Pokemon("Roucarnage", new Caracteristiques(350, 20, 10, 20), ETypeElement.Feu); Pokemon pok8 = new Pokemon("Rondoudou", new Caracteristiques(200, 50, 10, 20), ETypeElement.Terre); Pokemon pok9 = new Pokemon("Aspicot", new Caracteristiques(120, 40, 10, 20), ETypeElement.Terre); Pokemon pok10 = new Pokemon("Papilution", new Caracteristiques(125, 30, 10, 20), ETypeElement.Insecte); Pokemon pok11 = new Pokemon("Abra", new Caracteristiques(210, 30, 10, 20), ETypeElement.Plante); Pokemon pok12 = new Pokemon("Lamantine", new Caracteristiques(325, 40, 30, 60), ETypeElement.Eau); Pokemon pok13 = new Pokemon("Onix", new Caracteristiques(110, 50, 10, 20), ETypeElement.Sol); Pokemon pok14 = new Pokemon("Rhinocorne", new Caracteristiques(190, 50, 20, 10), ETypeElement.Sol); Pokemon pok15 = new Pokemon("Evoli", new Caracteristiques(230, 50, 20, 30), ETypeElement.Eau); Pokemon pok16 = new Pokemon("Feurisson", new Caracteristiques(300, 40, 30, 20), ETypeElement.Feu); listPkm.Add(pok1); listPkm.Add(pok2); listPkm.Add(pok3); listPkm.Add(pok4); listPkm.Add(pok5); listPkm.Add(pok6); listPkm.Add(pok7); listPkm.Add(pok8); listPkm.Add(pok9); listPkm.Add(pok10); listPkm.Add(pok11); listPkm.Add(pok12); listPkm.Add(pok13); listPkm.Add(pok14); listPkm.Add(pok15); listPkm.Add(pok16); listCarac.Add(pok1.Caracteristiques); listCarac.Add(pok2.Caracteristiques); listCarac.Add(pok3.Caracteristiques); listCarac.Add(pok4.Caracteristiques); listCarac.Add(pok5.Caracteristiques); listCarac.Add(pok6.Caracteristiques); listCarac.Add(pok7.Caracteristiques); listCarac.Add(pok8.Caracteristiques); listCarac.Add(pok9.Caracteristiques); listCarac.Add(pok10.Caracteristiques); listCarac.Add(pok11.Caracteristiques); listCarac.Add(pok12.Caracteristiques); listCarac.Add(pok13.Caracteristiques); listCarac.Add(pok14.Caracteristiques); listCarac.Add(pok15.Caracteristiques); listCarac.Add(pok16.Caracteristiques); Stade stade1 = new Stade(10000, "HotArena", ETypeElement.Feu); listStade.Add(stade1); listStade.Add(new Stade(7000, "GoutteArena", ETypeElement.Eau)); listStade.Add(new Stade(12000, "JardinArena", ETypeElement.Plante)); listStade.Add(new Stade(10000, "BoueArena", ETypeElement.Terre)); listMatch.Add(new Match(pok1, pok2, stade1, EPhaseTournoi.Finale)); }
public PokemonData GetBestPokemonByIv(PokemonId pokemonId) { return(Pokemon.OrderByDescending(PokemonInfo.CalculatePokemonPerfection).FirstOrDefault()); }
public IEnumerable <PokemonData> GetDuplicatePokemonForTransfer(bool keepPokemonsThatCanEvolve = false, bool prioritizeIvoverCp = false, IEnumerable <PokemonId> filter = null) { // TODO:: Gut this horrible code and replace it with something that is readable var pokemonList = Pokemon.Where( p => p.DeployedFortId == string.Empty && p.Favorite == 0 && p.Cp < _logicSettings.KeepMinCp) .ToList(); if (filter != null) { pokemonList = pokemonList.Where(p => !filter.Contains(p.PokemonId)).ToList(); } if (keepPokemonsThatCanEvolve) { var results = new List <PokemonData>(); var pokemonsThatCanBeTransfered = pokemonList.GroupBy(p => p.PokemonId) .Where(x => x.Count() > _logicSettings.KeepMinDuplicatePokemon).ToList(); foreach (var pokemon in pokemonsThatCanBeTransfered) { var settings = PokemonSettings.Single(x => x.PokemonId == pokemon.Key); var familyCandy = PokemonFamilies.Single(x => settings.FamilyId == x.FamilyId); var amountToSkip = _logicSettings.KeepMinDuplicatePokemon; var amountPossible = familyCandy.Candy_ / settings.CandyToEvolve; if (settings.CandyToEvolve > 0 && amountPossible > amountToSkip) { amountToSkip = amountPossible; } if (prioritizeIvoverCp) { results.AddRange(pokemonList.Where(x => x.PokemonId == pokemon.Key) .OrderByDescending(PokemonInfo.CalculatePokemonPerfection) .ThenBy(n => n.StaminaMax) .Skip(amountToSkip) .ToList()); } else { results.AddRange(pokemonList.Where(x => x.PokemonId == pokemon.Key) .OrderByDescending(x => x.Cp) .ThenBy(n => n.StaminaMax) .Skip(amountToSkip) .ToList()); } } return(results); } if (prioritizeIvoverCp) { return(pokemonList .GroupBy(p => p.PokemonId) .Where(x => x.Any()) .SelectMany( p => p.OrderByDescending(PokemonInfo.CalculatePokemonPerfection) .ThenBy(n => n.StaminaMax) .Skip(_logicSettings.KeepMinDuplicatePokemon) .ToList())); } return(pokemonList .GroupBy(p => p.PokemonId) .Where(x => x.Any()) .SelectMany( p => p.OrderByDescending(x => x.Cp) .ThenBy(n => n.StaminaMax) .Skip(_logicSettings.KeepMinDuplicatePokemon) .ToList())); }
public IEnumerable <PokemonData> GetHighestCp(int count) { return(Pokemon.OrderByDescending(x => x.Cp).Take(count)); }
public override void DoMove(Pokemon source) { GetTargets(range, source); }
public bool InsertPokemon(Pokemon pokemon) { listPkm.Add(pokemon); return(true); }
// Party Commands public virtual void SetPartyCommands(Pokemon pokemon, List <BattleExtraCommand> commands) { }
private void modifyHealth(Pokemon player, int HP_Modifier) { player.modifyHealth(HP_Modifier, PokeType.Normal); }
public virtual void SwitchSelectedMoveTo( Pokemon pokemon, Pokemon.Moveslot selected, bool choosingSpecial, bool choosingZMove, bool choosingMaxMove) { }
public async Task <MethodResult> ExportStats() { MethodResult result = await UpdateDetails(); //Prevent API throttling await Task.Delay(500); if (!result.Success) { return(result); } //Possible some objects were empty. StringBuilder builder = new StringBuilder(); builder.AppendLine("=== Trainer Stats ==="); if (Stats != null && PlayerData != null) { builder.AppendLine(String.Format("Username: {0}", UserSettings.PtcUsername)); builder.AppendLine(String.Format("Password: {0}", UserSettings.PtcPassword)); builder.AppendLine(String.Format("Level: {0}", Stats.Level)); builder.AppendLine(String.Format("Current Trainer Name: {0}", PlayerData.Username)); builder.AppendLine(String.Format("Team: {0}", PlayerData.Team)); builder.AppendLine(String.Format("Stardust: {0:N0}", TotalStardust)); builder.AppendLine(String.Format("Unique Pokedex Entries: {0}", Stats.UniquePokedexEntries)); } else { builder.AppendLine("Failed to grab stats"); } builder.AppendLine(); builder.AppendLine("=== Pokemon ==="); if (Pokemon != null) { foreach (PokemonData pokemon in Pokemon.OrderByDescending(x => x.Cp)) { string candy = "Unknown"; MethodResult <PokemonSettings> pSettings = GetPokemonSetting(pokemon.PokemonId); if (pSettings.Success) { Candy pCandy = PokemonCandy.FirstOrDefault(x => x.FamilyId == pSettings.Data.FamilyId); if (pCandy != null) { candy = pCandy.Candy_.ToString("N0"); } } MethodResult <double> perfectResult = CalculateIVPerfection(pokemon); string iv = "Unknown"; if (perfectResult.Success) { iv = Math.Round(perfectResult.Data, 2).ToString() + "%"; } builder.AppendLine(String.Format("Pokemon: {0,-10} CP: {1, -5} IV: {2,-7} Primary: {3, -14} Secondary: {4, -14} Candy: {5}", pokemon.PokemonId, pokemon.Cp, iv, pokemon.Move1.ToString().Replace("Fast", ""), pokemon.Move2, candy)); } } //Remove the hardcoded directory later try { string directoryName = "AccountStats"; if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } string fileName = UserSettings.PtcUsername.Split('@').First(); string filePath = Path.Combine(directoryName, fileName) + ".txt"; File.WriteAllText(filePath, builder.ToString()); LogCaller(new LoggerEventArgs(String.Format("Finished exporting stats to file {0}", filePath), LoggerTypes.Info)); return(new MethodResult { Message = "Success", Success = true }); } catch (Exception ex) { LogCaller(new LoggerEventArgs("Failed to export stats due to exception", LoggerTypes.Warning, ex)); return(new MethodResult()); } }
public virtual IEnumerator AnimatePokemonHUDHPChange(Pokemon pokemon, int preHP, int postHP, float timeSpan = 1f) { yield return(null); }
IEnumerator BattleHandler() { allyPokemon = Player.instance.party.GetFirstNonFaintedPokemon(); allyHPSlider.value = allyPokemon.HP; dialogueManager.ClearDialogue(); dialogueManager.AddDialogue("Foe " + foePokemon.GetName() + " wants to battle!"); allyParent.transform.localPosition = new Vector3(600, -32, 0); dialogueManager.DisplayNextSentence(); foePokemonParent.transform.localPosition = Vector3.zero; for (int i = 600; i >= 0; i -= 10) { foeParent.transform.localPosition = new Vector3(-i, 96, 0); yield return(null); } bool partyDead = false; while (Player.instance.party.HasUsablePokemon() && !foePokemon.CheckForDeath()) { bool allyDied = false; bool foeDied = false; allyParent.transform.localPosition = new Vector3(600, -32, 0); allyPokemon = Player.instance.party.GetFirstNonFaintedPokemon(); dialogueManager.AddDialogue("Go, " + allyPokemon.GetName() + "!"); yield return(dialogueManager.WaitForCaughtUpText()); allyPokemonParent.transform.localPosition = Vector3.zero; for (int i = 500; i >= 0; i -= 10) { allyParent.transform.localPosition = new Vector3(i, -32, 0); yield return(null); } while (!allyPokemon.CheckForDeath() && !foePokemon.CheckForDeath()) { int foeRand = Random.Range(0, foePokemon.GetNumberOfMoves()); int allyRand = Random.Range(0, allyPokemon.GetNumberOfMoves()); Pokemon fasterPokemon; Pokemon slowerPokemon; if (allyPokemon.speed > foePokemon.speed) { fasterPokemon = allyPokemon; slowerPokemon = foePokemon; } else { fasterPokemon = foePokemon; slowerPokemon = allyPokemon; } yield return(StartCoroutine(SingleAttack(fasterPokemon, slowerPokemon, foeRand))); int check = CheckIfEitherPokemonDied(); if (check != 0) { allyDied = (check == 1); foeDied = (check == 2); break; } yield return(StartCoroutine(SingleAttack(slowerPokemon, fasterPokemon, allyRand))); check = CheckIfEitherPokemonDied(); if (check != 0) { allyDied = (check == 1); foeDied = (check == 2); break; } } if (foeDied) { int exp = ExperienceCalculation(allyPokemon, foePokemon); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); for (int i = 0; i < 150; i += 10) { foePokemonParent.transform.localPosition = new Vector3(0, -i, 0); yield return(null); } dialogueManager.AddDialogue(foePokemon.GetName() + " fainted!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue(allyPokemon.GetName() + " gained " + exp + " experience points!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); allyPokemon.ModXP(exp); yield return(StartCoroutine(WaitForBarsToLoad())); break; } if (allyDied) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); for (int i = 0; i < 150; i += 10) { allyPokemonParent.transform.localPosition = new Vector3(0, -i, 0); yield return(null); } dialogueManager.AddDialogue(allyPokemon.GetName() + " fainted!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); if (!Player.instance.party.HasUsablePokemon()) { partyDead = true; } } } if (partyDead) { dialogueManager.AddDialogue(Player.instance.name + " is out of usable Pokemon!"); dialogueManager.AddDialogue(Player.instance.name + " blacked out!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); } //dialogueManager.AddDialogue("BATTLE OVER"); PokemonGameManager.instance.EndBattle(); }
public virtual void UpdatePokemonHUD(Pokemon pokemon, Battle battle) { }
public IEnumerator SingleAttack(Pokemon attacker, Pokemon defender, MoveInSet moveInSet) { float accuracyCheck = Random.Range(0, 100f); MoveData move = moveInSet.move; dialogueManager.AddDialogue(attacker.GetName() + " used " + move.name + "!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpText())); if (move.accuracy > 0 && accuracyCheck > move.accuracy) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("But it missed!"); yield break; } float level = attacker.level; float power = move.basePower; float ratingMultiplier; float burn; if (move.isSpecial) { burn = 1.0f; ratingMultiplier = (float)attacker.specialAttack / defender.specialDefense; } else { burn = attacker.status.Equals(Status.BURN) ? .5f : 1.0f; ratingMultiplier = (float)attacker.attack / defender.defense; } float targets = 1.0f; float weather = 1.0f; float badge = 1.0f; float criticalChance = 1f / 16.0f; bool criticalHappened = Random.Range(0f, 1f) < criticalChance; float critical = (criticalHappened? 2.0f : 1.0f); float randomVariation = Random.Range(.85f, 1.0f); float STAB = (attacker.IsType(move.type) ? 1.5f : 1.0f); float typeEffectiveness = PokemonTypeData.Effectiveness(move.type, defender); float other = 1.0f; float modifier = targets * weather * badge * critical * randomVariation * STAB * typeEffectiveness * burn * other; int damage = Mathf.CeilToInt((2f + ((2f + (2f * level) / 5f) * power * ratingMultiplier) / 50f) * modifier); if (damage <= 0) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("It didn't effect " + defender.GetName() + "..."); yield break; } defender.ModHP(-damage); yield return(StartCoroutine(WaitForBarsToLoad())); if (criticalHappened) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("Critical hit!"); } if (typeEffectiveness > 1.0f) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("It was super effective!"); } if (typeEffectiveness < 1.0f) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("It wasn't very effective..."); } dialogueManager.DisplayNextSentence(); }
// HUD public virtual BTLUI_PokemonHUD DrawPokemonHUD(Pokemon pokemon, Battle battle, bool isNear) { Debug.LogWarning("Unimplimented!"); return(null); }
public virtual bool UndrawPokemonHUD(Pokemon pokemon) { Debug.LogWarning("Unimplimented!"); return(false); }