Exemple #1
0
    public SC_BasePokemon getRandomPokemonFromList(List <SC_BasePokemon> _pokemonsList)
    {
        int            _randomIndex   = Random.Range(0, _pokemonsList.Count);
        SC_BasePokemon _randomPokemon = Instantiate(_pokemonsList[_randomIndex]);

        return(_randomPokemon);
    }
Exemple #2
0
    public SC_BasePokemon getRandomPokemonFromList(List <SC_BasePokemon> pokemonsList)
    {
        int            randomIndex   = Random.Range(0, pokemonsList.Count);
        SC_BasePokemon randomPokemon = Instantiate(pokemonsList[randomIndex]);

        //allPokemons.Remove(pokemonsList[randomIndex]);
        return(randomPokemon);
    }
Exemple #3
0
    private void AttackOpponent(SC_BasePokemon _attackPokemon, SC_PokemonMove _attackMove, SC_BasePokemon _defensePokemon)
    {
        isAbleToPress = false;
        if (canExit != true)
        {
            _attackMove.moveSound.Play();
        }
        currentMenu  = GlobalEnums.BattleMenus.Message;
        MessageState = GlobalEnums.MessageBoxState.Attack;
        attackMove   = _attackMove;
        ManageMessageBox(attackMove);
        isWaitingForRespond = true;

        _attackMove.currPP--;

        float _lvl    = (float)_attackPokemon.level;
        float _power  = (float)attackMove.power;
        float _A      = (float)_attackPokemon.attack;
        float _D      = (float)_defensePokemon.defense;
        float _damage = (((((((2f * _lvl) / 5f) + 2f) * _power) * (_A / _D)) + 2f) / 50f);

        if (currentTurn == GlobalEnums.Turns.PlayersTurn)
        {
            playerAnimator.SetTrigger("Attack");
            backgroundAnimator.SetTrigger("Attack");
            StartCoroutine(FlashAfterAttack(Img_foePokemon, 4, 0.1f));
        }
        else if (currentTurn == GlobalEnums.Turns.FoesTurn)
        {
            playerBoxAnimator.SetTrigger("Attack");
            foeAnimator.SetTrigger("Attack");
            foeBoxAnimator.SetTrigger("Attack");
            backgroundAnimator.SetTrigger("Attack");
            StartCoroutine(FlashAfterAttack(Img_playerPokemon, 4, 0.1f));
        }

        if (_defensePokemon.HpStats.curr - _damage < 1)
        {
            PlayerTimeLeft.enabled = false;
            FoeTimeLeft.enabled    = false;
            float _oldHP = (_defensePokemon.HpStats.curr) / _defensePokemon.HpStats.max;
            StartCoroutine(handlePlayerHpDecrease(_defensePokemon, Text_PlayerHP, _defensePokemon.HpStats.curr, 0, 0.06f));
            StartCoroutine(_defensePokemon.healthBar.SetHealthBarScale(_oldHP, 0));
            _defensePokemon.HpStats.curr = 0;
            battleState = GlobalEnums.BattleStates.GameOver;
        }
        else
        {
            float _newHP = (_defensePokemon.HpStats.curr - _damage) / _defensePokemon.HpStats.max;
            float _oldHP = (_defensePokemon.HpStats.curr) / _defensePokemon.HpStats.max;
            StartCoroutine(handlePlayerHpDecrease(_defensePokemon, Text_PlayerHP, _defensePokemon.HpStats.curr, _defensePokemon.HpStats.curr - _damage, 0.06f));
            StartCoroutine(_defensePokemon.healthBar.SetHealthBarScale(_oldHP, _newHP));
            _defensePokemon.HpStats.curr -= _damage;
        }
    }
Exemple #4
0
 public void AddToOwnedPokemons(SC_BasePokemon pokemon)
 {
     if (pokemon != null)
     {
         ownedPokemon.Add(pokemon);
     }
     else
     {
         Debug.Log("ERROR: Adding null pokemon");
     }
 }
 private void initFoe()
 {
     foePokemon               = SC_GameLogic.getRandomPokemonFromList(SC_GameLogic.allPokemons);
     Img_foePokemon.sprite    = foePokemon.frontImage;
     Text_pokemonNameFoe.text = foePokemon.name;
     Text_pokemonLvlFoe.text  = "Lv" + foePokemon.level.ToString();
     foePokemon.HpStats.curr  = foePokemon.HpStats.max;
     foePokemon.healthBar     = foeHealthBar.GetComponent <SC_HealthBar>();
     foePokemon.healthBar.SetHealthBarScale(1f);
     for (int i = 0; i < foePokemon.moves.Count; i++)
     {
         foePokemon.moves[i].currPP = foePokemon.moves[i].maxPP;
     }
 }
Exemple #6
0
    private IEnumerator handlePlayerHpDecrease(SC_BasePokemon _pokemon, Text _pokemonHP, float _oldHP, float _newHP, float _delay)
    {
        yield return(new WaitForSeconds(_delay));

        while (_oldHP >= _newHP)
        {
            _oldHP--;
            if (currentTurn == GlobalEnums.Turns.FoesTurn)
            {
                _pokemonHP.text = ((int)_oldHP).ToString() + "/" + _pokemon.HpStats.max.ToString();
            }
            yield return(new WaitForSeconds(_delay));
        }
        isAbleToPress = true;
    }
    private void AttackOpponent(SC_BasePokemon _attackPokemon, SC_PokemonMove _attackMove, SC_BasePokemon _defensePokemon)
    {
        currentMenu  = GlobalEnums.BattleMenus.Message;
        MessageState = GlobalEnums.MessageBoxState.Attack;
        attackMove   = _attackMove;
        ManageMessageBox(attackMove);
        isWaitingForRespond = true;

        _attackMove.currPP--;

        float _lvl      = (float)_attackPokemon.level;
        float _power    = (float)attackMove.power;
        float _A        = (float)_attackPokemon.attack;
        float _D        = (float)_defensePokemon.defense;
        float _modifier = (float)(UnityEngine.Random.Range(0.8f, 1f));
        float _damage   = (((((((2f * _lvl) / 5f) + 2f) * _power) * (_A / _D)) + 2f) / 50f) * _modifier;

        //float damage = (((((((2f * lvl) / 5f) + 2f) * power) * (A/D)) / 50f) + 2f) * modifier;
        //Debug.Log("damage: " + damage);

        if (currentTurn == GlobalEnums.Turns.PlayersTurn)
        {
            StartCoroutine(FlashAfterAttack(Img_foePokemon, 4, 0.1f));
        }
        else if (currentTurn == GlobalEnums.Turns.FoesTurn)
        {
            StartCoroutine(FlashAfterAttack(Img_playerPokemon, 4, 0.1f));
        }

        if (_defensePokemon.HpStats.curr - _damage < 0)
        {
            _defensePokemon.HpStats.curr = 0;
            _defensePokemon.healthBar.SetHealthBarScale(0);
            Text_PlayerHP.text = ((int)playerPokemon.HpStats.curr).ToString() + "/" + playerPokemon.HpStats.max.ToString();
            battleState        = GlobalEnums.BattleStates.GameOver;
        }
        else
        {
            float newHP = (_defensePokemon.HpStats.curr - _damage) / _defensePokemon.HpStats.max;
            _defensePokemon.HpStats.curr -= _damage;
            _defensePokemon.healthBar.SetHealthBarScale(newHP);
            Text_PlayerHP.text = ((int)playerPokemon.HpStats.curr).ToString() + "/" + playerPokemon.HpStats.max.ToString();
        }
    }
 private void initPlayer()
 {
     playerPokemon               = SC_GameLogic.getRandomPokemonFromList(SC_GameLogic.allPokemons);
     Img_playerPokemon.sprite    = playerPokemon.backImage;
     Text_pokemonNamePlayer.text = playerPokemon.name;
     Text_pokemonLvlPlayer.text  = "Lv" + playerPokemon.level.ToString();
     playerPokemon.HpStats.curr  = playerPokemon.HpStats.max;
     Text_PlayerHP.text          = playerPokemon.HpStats.curr.ToString() + "/" + playerPokemon.HpStats.max.ToString();
     playerPokemon.healthBar     = playerHealthBar.GetComponent <SC_HealthBar>();
     playerPokemon.healthBar.SetHealthBarScale(1f);
     Move1Txt = playerPokemon.moves[0].name;
     Move2Txt = playerPokemon.moves[1].name;
     Move3Txt = playerPokemon.moves[2].name;
     Move4Txt = playerPokemon.moves[3].name;
     for (int i = 0; i < playerPokemon.moves.Count; i++)
     {
         playerPokemon.moves[i].currPP = playerPokemon.moves[i].maxPP;
     }
 }
Exemple #9
0
    private void initPlayer(int _pokemonID = 000, int _pokemonLvl = 000)
    {
        playerAnimator.Rebind();

        if (_pokemonID == 000)
        {
            playerPokemon = SC_GameLogic.getRandomPokemonFromList(SC_GameLogic.allPokemons);
        }
        else
        {
            playerPokemon = SC_GameLogic.getPokemonByID(_pokemonID);
        }

        Img_playerPokemon.sprite    = playerPokemon.backImage;
        Text_pokemonNamePlayer.text = playerPokemon.name;

        if (_pokemonLvl == 000)
        {
            Text_pokemonLvlPlayer.text = "Lv" + playerPokemon.level.ToString();
        }
        else
        {
            Text_pokemonLvlPlayer.text = "Lv" + _pokemonLvl.ToString();
        }

        playerPokemon.HpStats.curr = playerPokemon.HpStats.max;
        Text_PlayerHP.text         = playerPokemon.HpStats.curr.ToString() + "/" + playerPokemon.HpStats.max.ToString();
        playerPokemon.healthBar    = playerHealthBar.GetComponent <SC_HealthBar>();
        StartCoroutine(playerPokemon.healthBar.SetHealthBarScale(1f, 1f));
        Move1Txt = playerPokemon.moves[0].name;
        Move2Txt = playerPokemon.moves[1].name;
        Move3Txt = playerPokemon.moves[2].name;
        Move4Txt = playerPokemon.moves[3].name;

        for (int i = 0; i < playerPokemon.moves.Count; i++)
        {
            playerPokemon.moves[i]        = Instantiate(playerPokemon.moves[i]);
            playerPokemon.moves[i].currPP = playerPokemon.moves[i].maxPP;
        }
    }
Exemple #10
0
    private void initFoe(int _pokemonID = 000, int _pokemonLvl = 000)
    {
        foeAnimator.Rebind();

        if (_pokemonID == 000)
        {
            foePokemon = SC_GameLogic.getRandomPokemonFromList(SC_GameLogic.allPokemons);
        }
        else
        {
            foePokemon = SC_GameLogic.getPokemonByID(_pokemonID);
        }

        Img_foePokemon.sprite    = foePokemon.frontImage;
        Text_pokemonNameFoe.text = foePokemon.name;


        if (_pokemonLvl == 000)
        {
            Text_pokemonLvlFoe.text = "Lv" + foePokemon.level.ToString();
        }
        else
        {
            Text_pokemonLvlFoe.text = "Lv" + _pokemonLvl.ToString();
        }

        foePokemon.HpStats.curr = foePokemon.HpStats.max;
        foePokemon.healthBar    = foeHealthBar.GetComponent <SC_HealthBar>();
        StartCoroutine(foePokemon.healthBar.SetHealthBarScale(1f, 1f));

        for (int i = 0; i < foePokemon.moves.Count; i++)
        {
            foePokemon.moves[i]        = Instantiate(foePokemon.moves[i]);
            foePokemon.moves[i].currPP = foePokemon.moves[i].maxPP;
        }
    }