Exemplo n.º 1
0
    public void EnterBattle(Rarity rarity)
    {
        playerCamera.SetActive(false);
        battleCamera.SetActive(true);

        BasePokemon battlePokemon = GetRandomPokemonFromList(GetPokemonByRarity(rarity));

        Debug.Log(battlePokemon.name);

        player.GetComponent <PlayerMovement>().isAllowedToMove = false;

        GameObject dPoke = Instantiate(emptyPoke, defencePodium.transform.position, Quaternion.identity) as GameObject;

        Vector3 pokeLocalPos = new Vector3(0, 1, 0);

        dPoke.transform.parent        = defencePodium;
        dPoke.transform.localPosition = pokeLocalPos;
        BasePokemon tempPoke = dPoke.AddComponent <BasePokemon> () as BasePokemon;

        tempPoke.AddMember(battlePokemon);

        dPoke.GetComponent <SpriteRenderer> ().sprite = battlePokemon.image;

        bm.ChangeMenu(BattleManager.BattleMenu.Selection);
    }
Exemplo n.º 2
0
    public void EnterBattle(Rarity rarity)
    {
        //Camera into BattleMode
        playerCamera.SetActive(false);
        battleCamera.SetActive(true);

        //change State
        bm.state = BattleState.Start;
        //Get a Random Pokemon from the List
        BasePokemon  battlePokemon = GetRandomPokemonFromList(GetPokemonByRarity(rarity));
        OwnedPokemon PlayerPokemon = GetOwnedPokemon(plyr.ownedPokemon);

        //Stop Player from Moving
        player.GetComponent <PlayerMovement>().isAllowedToMove = false;
        //Initiate Pokemon
        dPoke = Instantiate(emptyPoke, defencePodium.transform.position, Quaternion.identity) as GameObject;
        aPoke = Instantiate(emptyPoke, attackPodium.transform.position, Quaternion.identity) as GameObject;
        //Set Position to to a flat Number?
        Vector3 pokeLocalPos     = new Vector3(0, 1, 0);
        Vector3 friendlyLocalPos = new Vector3(0, 0, 0);

        dPoke.transform.parent        = defencePodium;
        aPoke.transform.parent        = attackPodium;
        dPoke.transform.localPosition = pokeLocalPos;
        aPoke.transform.localPosition = friendlyLocalPos;

        dPoke.transform.parent = defencePodium;
        aPoke.transform.parent = attackPodium;
        //copy BasePokemon so it gets individuell
        tempPoke       = dPoke.AddComponent <BasePokemon>() as BasePokemon;
        playerTempPoke = aPoke.AddComponent <BasePokemon>() as BasePokemon;
        tempPoke.AddMember(battlePokemon);
        playerTempPoke.AddMember(PlayerPokemon.pokemon);

        //Random level
        int p = Random.Range(2, 5);

        tempPoke.level = p;
        //PlayerPokemon Level
        playerTempPoke.level = PlayerPokemon.level;
        //calculate HP
        tempPoke.HP              = (((2 * tempPoke.HP) * p) / 100) + p + 10;
        playerTempPoke.HP        = (((2 * playerTempPoke.HP) * playerTempPoke.level) / 100) + playerTempPoke.level + 10;
        tempPoke.currentHP       = tempPoke.HP;
        playerTempPoke.currentHP = playerTempPoke.HP;

        //Set Sprites
        dPoke.GetComponent <SpriteRenderer>().sprite = battlePokemon.image;
        aPoke.GetComponent <SpriteRenderer>().sprite = PlayerPokemon.pokemon.image;
        //User Interface Update
        bm.InfoText.text = "A wild " + battlePokemon.Name + " appeared!";
        bm.ChangeMenu(BattleMenu.Info);
        bm.GetMoves(PlayerPokemon);
        bm.GetBattlePokemon(PlayerPokemon);
        //Update
        bm.UpdatePokemonDetails(tempPoke.Name, tempPoke.level, tempPoke.currentHP, tempPoke.HP, PlayerPokemon.NickName, playerTempPoke.level, playerTempPoke.currentHP, playerTempPoke.HP);
    }
    public BasePokemon activeEPoke;                       //stores an instance of the BasePokemon script as activeEPoke, for the enemy pokemon

    void Start()                                          //on code initialization
    {
        playerCamera.SetActive(true);                     //enables the player camera
        battleCamera.SetActive(false);                    //disables the battle camera
        bm = battleCamera.GetComponent <BattleManager>(); //sets bm to the already existing script stored in the battleCamera object

        //initialises the starting pokemon owned by the player
        BasePokemon startPoke = new BasePokemon();

        startPoke.AddMember(allPokemon[1]);
        player.GetComponent <Player>().ownedPokemon[0].pokemon = startPoke;
        startPoke.level         = player.GetComponent <Player>().ownedPokemon[0].level;
        startPoke.maxHP         = startPoke.HPGain * startPoke.level + startPoke.maxHP;
        startPoke.HP            = startPoke.maxHP;
        startPoke.AttackStat    = startPoke.AttackGain * startPoke.level + startPoke.AttackStat;
        startPoke.DefenceStat   = startPoke.DefenceGain * startPoke.level + startPoke.DefenceStat;
        startPoke.SpeedStat     = startPoke.SpeedGain * startPoke.level + startPoke.SpeedStat;
        startPoke.SpAttackStat  = startPoke.SpAttackGain * startPoke.level + startPoke.SpAttackStat;
        startPoke.SpDefenceStat = startPoke.SpDefenceStat * startPoke.level + startPoke.SpDefenceStat;
        startPoke.XPtoLvl       = 50 * startPoke.level + startPoke.XPtoLvl;
        startPoke.Move1C        = startPoke.learnableMoves[0].MoveCode;
        startPoke.Move1PP       = allMoves[startPoke.Move1C].PP;
    }
    public void EnterBattle(Rarity rarity)
    {
        //changes active camera
        playerCamera.SetActive(false);
        battleCamera.SetActive(true);

        BasePokemon battlePokemon = GetRandomPokemonFromList(GetPokemonByRarity(rarity));                              //runs 2 functions to get a random enemy pokemon

        Debug.Log(battlePokemon.PName);                                                                                //write to console pokemon name
        bm.ename.text = battlePokemon.PName;                                                                           //write to console enemy name
        player.GetComponent <PlayerMovement2>().isAllowedToMove = false;                                               //make sure player doesnt move while in battle

        GameObject aPoke = Instantiate(pokebase, attackPodium.transform.position, Quaternion.identity) as GameObject;  //create object aPoke
        GameObject dPoke = Instantiate(pokebase, defencePodium.transform.position, Quaternion.identity) as GameObject; //create object dPoke

        //creates clones of all of the players pokemon
        OwnedPokemon opoke1 = player.GetComponent <Player>().ownedPokemon[0];
        OwnedPokemon opoke2 = player.GetComponent <Player>().ownedPokemon[1];
        OwnedPokemon opoke3 = player.GetComponent <Player>().ownedPokemon[2];
        OwnedPokemon opoke4 = player.GetComponent <Player>().ownedPokemon[3];
        OwnedPokemon opoke5 = player.GetComponent <Player>().ownedPokemon[4];
        OwnedPokemon opoke6 = player.GetComponent <Player>().ownedPokemon[5];

        //decides which clone is the currently active pokemon
        BasePokemon ppoke = aPoke.AddComponent <BasePokemon>() as BasePokemon;

        ppoke = opoke1.pokemon;
        if (opoke1.pokemon.HP > 0)
        {
            ppoke = opoke1.pokemon;
        }
        else if (opoke2.pokemon.HP > 0)
        {
            ppoke = opoke2.pokemon;
        }
        else if (opoke3.pokemon.HP > 0)
        {
            ppoke = opoke3.pokemon;
        }
        else if (opoke4.pokemon.HP > 0)
        {
            ppoke = opoke4.pokemon;
        }
        else if (opoke5.pokemon.HP > 0)
        {
            ppoke = opoke5.pokemon;
        }
        else if (opoke6.pokemon.HP > 0)
        {
            ppoke = opoke6.pokemon;
        }
        else
        {
            Debug.Log("No Poke Error");
        }
        Debug.Log(ppoke.PName);
        bm.pname.text = ppoke.PName;

        Vector3 pokeLocalPos = new Vector3(0, 1, 0); //lets all pokemon know own vector

        //sets all active pokemon to platform vector
        dPoke.transform.parent        = defencePodium;
        dPoke.transform.localPosition = pokeLocalPos;
        aPoke.transform.parent        = attackPodium;
        aPoke.transform.localPosition = pokeLocalPos;

        //sets up enemy pokemon stats, aswell as tags all pokemon so they can be deleted later.
        //enemy stats are derived from BasePokemon, and updated for level*statgain+basestat
        BasePokemon tempPoke = dPoke.AddComponent <BasePokemon>() as BasePokemon;

        tempPoke.AddMember(battlePokemon);
        tempPoke.level         = Random.Range(EntLvlMin, EntLvlMax);
        bm.elevel.text         = tempPoke.level.ToString();
        tempPoke.maxHP         = tempPoke.HPGain * tempPoke.level + tempPoke.maxHP;
        tempPoke.HP            = tempPoke.maxHP;
        tempPoke.AttackStat    = tempPoke.AttackGain * tempPoke.level + tempPoke.AttackStat;
        tempPoke.DefenceStat   = tempPoke.DefenceGain * tempPoke.level + tempPoke.DefenceStat;
        tempPoke.SpeedStat     = tempPoke.SpeedGain * tempPoke.level + tempPoke.SpeedStat;
        tempPoke.SpAttackStat  = tempPoke.SpAttackGain * tempPoke.level + tempPoke.SpAttackStat;
        tempPoke.SpDefenceStat = tempPoke.SpDefenceStat * tempPoke.level + tempPoke.SpDefenceStat;
        tempPoke.XPtoLvl       = 50 * tempPoke.level + tempPoke.XPtoLvl;
        dPoke.tag      = "epoke";
        aPoke.tag      = "ppoke";
        bm.plevel.text = ppoke.level.ToString();

        //draws the health stat in the UI
        bm.epokehealthmin.text = tempPoke.HP.ToString();
        bm.epokehealthmax.text = tempPoke.maxHP.ToString();
        bm.ppokehealthmin.text = ppoke.HP.ToString();
        bm.ppokehealthmax.text = ppoke.maxHP.ToString();

        //derives player moves
        if (ppoke.Move1C != 0)
        {
            bm.moveO.text = allMoves[ppoke.Move1C].MoveName;
        }
        else
        {
            bm.moveO.text = "Empty";
        }
        if (ppoke.Move2C != 0)
        {
            bm.moveT.text = allMoves[ppoke.Move2C].MoveName;
        }
        else
        {
            bm.moveT.text = "Empty";
        }
        if (ppoke.Move3C != 0)
        {
            bm.moveTH.text = allMoves[ppoke.Move3C].MoveName;
        }
        else
        {
            bm.moveTH.text = "Empty";
        }
        if (ppoke.Move2C != 0)
        {
            bm.moveF.text = allMoves[ppoke.Move2C].MoveName;
        }
        else
        {
            bm.moveF.text = "Empty";
        }

        //derives player moves
        List <LearnableMoves> possibleMoves = new List <LearnableMoves>();

        foreach (LearnableMoves lm in tempPoke.learnableMoves)
        {
            if (lm.LearnedLevel <= tempPoke.level)
            {
                possibleMoves.Add(lm);
            }
        }

        //more deriving enemy moves
        if (possibleMoves.Count > 0)
        {
            int pmindex = Random.Range(0, possibleMoves.Count - 1);
            tempPoke.Move1C = possibleMoves[pmindex].MoveCode;
            possibleMoves.RemoveAt(pmindex);
        }
        if (possibleMoves.Count > 0)
        {
            int pmindex = Random.Range(0, possibleMoves.Count - 1);
            tempPoke.Move2C = possibleMoves[pmindex].MoveCode;
            possibleMoves.RemoveAt(pmindex);
        }
        if (possibleMoves.Count > 0)
        {
            int pmindex = Random.Range(0, possibleMoves.Count - 1);
            tempPoke.Move3C = possibleMoves[pmindex].MoveCode;
            possibleMoves.RemoveAt(pmindex);
        }
        if (possibleMoves.Count > 0)
        {
            int pmindex = Random.Range(0, possibleMoves.Count - 1);
            tempPoke.Move4C = possibleMoves[pmindex].MoveCode;
            possibleMoves.RemoveAt(pmindex);
        }

        //adds finishing touches to scene, rendering everything, and resetting the battle setup if in second fight
        dPoke.GetComponent <SpriteRenderer>().sprite = battlePokemon.image;
        aPoke.GetComponent <SpriteRenderer>().sprite = ppoke.image;
        activePoke  = ppoke;
        activeEPoke = tempPoke;
        bm.ChangeMenu(BattleMenu.Selection);
        bm.runused = false;
    }
Exemplo n.º 5
0
    public void EnterBattle(Rarity rarity)
    {
        playerCamera.SetActive(false);
        battleCamera.SetActive(true);

        PlayMusic(battleMusic);

        BasePokemon battlePokemon = GetRandomPokemonFromList(GetPokemonByRarity(rarity));

        player.GetComponent <PlayerMovement> ().isAllowedToMove = false;



        GameObject dPoke = Instantiate(emptyPoke, defencePodium.transform.position, Quaternion.identity) as GameObject;

        dPoke.AddComponent <WildPokemonMoves> ();                    //add WildPokemonMoves script that will automatically add moves to the the wild pokemon

        Vector3 pokeLocalPos = new Vector3(0, 1, 0);

        dPoke.transform.parent        = defencePodium;
        dPoke.transform.localPosition = pokeLocalPos;
        BasePokemon tempPoke = dPoke.AddComponent <BasePokemon> () as BasePokemon;

        tempPoke.AddMember(battlePokemon);

        dPoke.GetComponent <SpriteRenderer> ().sprite = battlePokemon.image;
        updateText.text = "A wild " + dPoke.GetComponent <BasePokemon>().PName + " appeared!";


        GameObject ownedPoke         = Instantiate(emptyPoke, attackPodium.transform.position, Quaternion.identity) as GameObject;
        Vector3    OwnedPokeLocalPos = new Vector3(0, 1, 0);



        ownedPoke.transform.parent        = attackPodium;
        ownedPoke.transform.localPosition = OwnedPokeLocalPos;
        ownedPoke.transform.Rotate(0, 180, 0);
        BasePokemon ownedPokemon = ownedPoke.AddComponent <BasePokemon> () as BasePokemon;

        ownedPokemon.AddMember(player.GetComponent <Player> ().ownedPokemon [0].ownedPokemon);

        ownedPoke.GetComponent <SpriteRenderer> ().sprite = ownedPokemon.image;


        type.text            = player.GetComponent <Player> ().ownedPokemon [0].moves [0].Category.ToString();
        PP.text              = player.GetComponent <Player> ().ownedPokemon [0].moves [0].PP.ToString();    //eventually move this all to BattleManager?
        pokemonName.text     = player.GetComponent <Player>().ownedPokemon[0].NickName;
        levelTextPlayer.text = player.GetComponent <Player> ().ownedPokemon [0].level.ToString();

        ownedPoke.SetActive(false);
        //playerThrowingPokeball.GetComponent<PlayerThrowingBall> ().move = true;



        int WildPokemonLevel = Random.Range(2, 4);                                                               //here we try to set a random level for our pokemon!    not maximally inclusive hence 4!!!!

        GameObject.Find("DefencePodium/emptyPoke(Clone)").GetComponent <BasePokemon>().level = WildPokemonLevel; // Here we try to set it in the script
        levelTextOppenent.text   = GameObject.Find("DefencePodium/emptyPoke(Clone)").GetComponent <BasePokemon>().level.ToString();
        OpponentPokemonName.text = GameObject.Find("DefencePodium/emptyPoke(Clone)").GetComponent <BasePokemon> ().PName;

        opponentHealthbar.GetComponent <RectTransform> ().offsetMax = new Vector2(-13, opponentHealthbar.GetComponent <RectTransform> ().offsetMax.y);

        bm.ChangeMenu(BattleManager.BattleMenu.Selection);
    }