//----------------------------------------------------------------------------------------------------------- //------------------------------------- ATTACKS ---------------------------------------- //----------------------------------------------------------------------------------------------------------- void InitAttacks(PokemonDatabase.PokemonItem pokemonDb) { List <PokemonDatabase.PokemonAttack> pokeAttacks = pokemonDb.m_attacksByLvl; // Get Moveset && attacks info int i = 0; while (i < pokeAttacks.Count && pokeAttacks[i].m_level <= m_level) { i++; } for (int j = 0; j < 4; j++) { if (i > 0) { // Fill attack id m_moveSet[j] = pokeAttacks[j].m_attackId; // Get attack's info AttackDatabase.AttackItem attack = AttackDatabase.GetAttackById(pokeAttacks[j].m_attackId); m_ppMax[j] = attack.m_pp; m_ppCurrent[j] = attack.m_pp; i--; } else { m_moveSet [j] = -1; } } }
//---------------------------------------------------------------------------- void InitBattlePokemons(Pokemon player, Pokemon opponent) { // Sprites m_spritePlayer.sprite = player.m_sprite_fight_back; m_spriteOpponent.sprite = opponent.m_sprite_fight_face; // Pokemons Info m_nameOpponent.text = opponent.m_name; m_namePlayer.text = player.m_name; m_levelOpponent.text = opponent.m_level.ToString(); m_levelPlayer.text = player.m_level.ToString(); // Pokemons Life //m_remainingLife.text = player.m_currentPV.ToString (); //m_maxLife.text = player.m_pv[(int)EStatType.Current].ToString (); // Fight Menu Info m_currentPP.text = player.m_ppCurrent[0].ToString(); m_maxPP.text = player.m_ppMax[0].ToString(); //public Text m_typeAtk; // Fight Menu moves m_move1.text = player.m_moveSet[0] != -1 ? AttackDatabase.GetAttackById(player.m_moveSet[0]).m_name : "-"; m_move2.text = player.m_moveSet[1] != -1 ? AttackDatabase.GetAttackById(player.m_moveSet[1]).m_name : "-"; m_move3.text = player.m_moveSet[2] != -1 ? AttackDatabase.GetAttackById(player.m_moveSet[2]).m_name : "-"; m_move4.text = player.m_moveSet[3] != -1 ? AttackDatabase.GetAttackById(player.m_moveSet[3]).m_name : "-"; //m_typeAtk = player.m_moveSet[0] != -1 ? AttackDatabase.GetAttackById (player.m_moveSet[0]).m_name : "-"; //Pokemon in battle m_opponentPokemon = opponent; m_playerPokemon = player; }
//---------------------------------------------------------------------------- protected override void DrawElement(Rect rect, int index, bool selected, bool focused) { AttackDatabase.AttackItem item = AttackDatabase.GetAttackById(index); if (item != null) { if (!string.IsNullOrEmpty(item.m_name)) { GUI.Label(rect, item.m_index.ToString() + ": " + item.m_name); } else { GUI.Label(rect, "Un-named!"); } if (selected) { if (m_currentlySelected != index) { m_currentlySelected = index; this.Repaint(); } } } }
// ----------------------------------------------------------------------------- void SelectOrderOfActions() { m_isPlayerInPhase1 = false; // TODO - if a wild pokemon can flee the fight without attacking (Safari Park for example), add the condition here; // Running from a fight is resolve before any other action in the turn. // If a player plays an object, it will be done before any action from the AI if (m_playerAction.GetActionType() == ECombatActionType.Run || m_playerAction.GetActionType() == ECombatActionType.Object) { m_isPlayerInPhase1 = true; } // A switch from the player will also be done before any action from the AI, but can be done after some special attacks else if (m_AiAction.GetActionType() == ECombatActionType.Switch) { // For now true. Cannot always be true with some attack like "Pursuit" m_isPlayerInPhase1 = true; } else if (m_AiAction.GetActionType() == ECombatActionType.Attack) // if both pokemon attacks, select the fastest attack { CAttackAction playerAttackAction = (CAttackAction)m_playerAction; CAttackAction aiAttackAction = (CAttackAction)m_AiAction; int playerPriority = AttackDatabase.GetAttackById(playerAttackAction.attackId).m_priorite; int aiPriority = AttackDatabase.GetAttackById(aiAttackAction.attackId).m_priorite; // if higher attack priority for the player's pokemon if (playerPriority > aiPriority) { m_isPlayerInPhase1 = true; } else if (playerPriority == aiPriority) { int playerPokemonSpeed = GetPokemonSpeed(m_playerPokemon, true); int aiPokemonSpeed = GetPokemonSpeed(m_opponentPokemon, false); // If player's pokemon is faster if (playerPokemonSpeed > aiPokemonSpeed) { m_isPlayerInPhase1 = true; } else if (playerPokemonSpeed == aiPokemonSpeed) // if both pokemon goes to the same speed, then select one at random to attack first { if (Random.Range(0, 2) == 0) { m_isPlayerInPhase1 = true; } } } } }
//---------------------------------------------------------------------------- protected override void OnInternalInspectorGUI() { AttackDatabase.AttackItem item = AttackDatabase.GetAttackById(m_currentlySelected); if (item != null) { GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { EditorGUILayout.LabelField("Attack Index", item.m_index.ToString()); item.m_name = EditorGUILayout.TextField("Attack Name", item.m_name); item.m_description = EditorGUILayout.TextField("Attack description", item.m_description); GUILayout.BeginHorizontal(); { item.m_attackType = (EAttackType)EditorGUILayout.EnumPopup("Nature of attack", item.m_attackType); item.m_type = (EPokemonType)EditorGUILayout.EnumPopup("Type of attack", item.m_type); } GUILayout.EndHorizontal(); item.m_puissance = EditorGUILayout.IntField("Puissance", item.m_puissance); item.m_precision = EditorGUILayout.IntField("Precision", item.m_precision); item.m_priorite = EditorGUILayout.IntField("Priorite", item.m_priorite); item.m_pp = EditorGUILayout.IntField("PP", item.m_pp); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } if (GUI.changed) { EditorUtility.SetDirty(target); } }