/* Function to apply the exp reward dropped by an enemy */
    public void applyExpRewardExp(Coremon mon, Coremon enemy)
    {
        if (mon.Level < maxLvl) //skip if its called for a mon at max level
        {
            int reward = 1;     //Default if enemy level is no valid
            int newExpAmmount;

            //calculate reward if enemy level is valid
            if (enemy.Level > 0)
            {
                reward = baseRewardExp * (enemy.Level / baseRewardLevel);
            }

            newExpAmmount = mon.ExpPoints + reward; //Sees how much exp will the mon gain

            if (newExpAmmount >= mon.LvlUpExp)      //If it's enoguht to level up
            {
                do
                {
                    newExpAmmount = newExpAmmount - mon.LvlUpExp; //Calculates exp points left after leveling up
                    levelUp(mon);
                } while (newExpAmmount >= mon.LvlUpExp);          //if exp left is enough to level up once more
            }
            else                                                  //If it's not enought to level up
            {
                mon.ExpPoints = newExpAmmount;
            }
        }
    }
    int baseRewardExp   = 100;                   //drops an exp point reward of: baseRewardExp


    /*     FOR TESTING.   CHECK BEHAVOUR WITH EDITOR ON DEBUG MODE
     * public Coremon test;
     * public Coremon test1;
     * public Coremon test2;
     * public Coremon test3;
     * public Coremon test4;
     * private void Start()
     * {
     *  test = new Coremon();
     *  Coremon enemy = new Coremon();
     *  enemy.Level = 10;
     *  test1 = new Coremon();
     *  test2 = new Coremon();
     *  test3 = new Coremon();
     *  test4 = new Coremon();
     *
     *  for (int i = 0; i < 500; i++)
     *  {
     *      applyExpRewardExp(test, enemy);
     *  }
     *
     *
     * }
     */

    /*
     *   Leveling up function. Start
     */
    public void levelUp(Coremon mon)
    {
        if (mon.Level < maxLvl)
        {
            mon.Level++;
            mon.ExpPoints = 0;              //Reset experience points
            increaseLvlUpExp(mon);          //Increase experience necessary to level up
            levelUpIncreaseStats(mon);      //Apply stat increase at level up
        }
    }
Example #3
0
    private void Start()
    {
        pointerAtackUI.SetActive(false);
        atacando  = false;
        selecAtac = false;
        masterPointerUI.SetActive(true);
        controllerCoremon = gameObject.GetComponent <CoremonController>();

        //Get  coremons
        cor      = GameData.saveData.team[0];
        enemyCor = controllerCoremon.getWildCoremon();
    }
    //Getsa coremon from the data base using its index
    public Coremon getCoremonNum(int num)
    {
        Coremon cor = null;

        if (num >= 1 && num <= 30)
        {
            cor    = GameData.CoremonData[num - 1];
            cor.Ps = cor.PsMax;
            setLvlUpExp(cor);
            cor.sprite = getCoremonSprite(cor);
        }
        return(cor);
    }
    private void levelUpIncreaseStats(Coremon mon)         //Only called from levelUp function
    {
        //Get random increase for each stat
        int hpIncrease      = UnityEngine.Random.Range(0, maxStatIncrease + 1); // Function is not inclusive of top's value, hence the "+1"
        int attackIncrease  = UnityEngine.Random.Range(0, maxStatIncrease + 1);
        int defenseIncrease = UnityEngine.Random.Range(0, maxStatIncrease + 1);
        int speedIncrease   = UnityEngine.Random.Range(0, maxStatIncrease + 1);

        //Apply level increase
        mon.Ps  += hpIncrease;
        mon.Dam += attackIncrease;
        mon.Def += defenseIncrease;
        mon.Vel += speedIncrease;
    }
    //Function to set the lvlUpExp property to coremon read from database
    public void setLvlUpExp(Coremon mon)
    {
        int ExpGauge = -1;  //Default for invalid level

        if (mon.Level == 1)
        {
            ExpGauge = initialLvlUpExp;  //Set initial value at lvl 1
        }
        else if (mon.Level > 1)
        {
            //lvlUpExp = initialExp * ( 1 + increaseFactor ) ^ level
            Debug.Log(Mathf.Pow(lvlUpExpIncreaseFactor, mon.Level));
            ExpGauge = Mathf.CeilToInt(initialLvlUpExp * Mathf.Pow(1 + lvlUpExpIncreaseFactor, mon.Level));
        }

        mon.LvlUpExp = ExpGauge;
    }
    /*
     *   Leveling up functions. End
     */
    public Sprite getCoremonSprite(Coremon cor)
    {
        string index;

        if (cor.NumCoremon < 10 && cor.NumCoremon > 0)
        {
            index = "0" + cor.NumCoremon.ToString();
        }
        else
        {
            index = cor.NumCoremon.ToString();
        }

        Debug.Log(index);
        Sprite sprite = Resources.Load <Sprite>(@"Sprite Coremon\" + index);

        Debug.Log(sprite);

        return(sprite);
    }
 public void updateText(Coremon cor)
 {
     Name.text   = cor.name;
     PsText.text = cor.Ps + "/" + cor.PsMax;
     Lvl.text    = cor.Level.ToString();
 }
 //Makes Coremon retreived from the database ready to be used in game
 private void ReadyCoremon(Coremon mon)
 {
     corController.setLvlUpExp(mon);
     mon.sprite = corController.getCoremonSprite(mon);
     mon.Ps     = mon.PsMax;
 }
Example #10
0
    public static void atack(AtackMenu.menuOptions action, Coremon cor, Coremon cor2)
    {
        int typeMult = 1;
        int typeDiv  = 1;//variables creadas para evitar errores al convertir int a float

        if (!String.Equals(cor2.Atacks[0].Type, atacando))
        {
            switch (cor2.Atacks[0].Type)
            {
            case "Planta":
                if (cor.Type == "Fuego")
                {
                    typeDiv = 2;
                }
                else
                {
                    typeMult = 2;
                }
                break;

            case "Fuego":
                if (cor.Type == "Agua")
                {
                    typeDiv = 2;
                }
                else
                {
                    typeMult = 2;
                }
                break;

            default:
                if (cor.Type == "Fuego")
                {
                    typeDiv = 2;
                }
                else
                {
                    typeMult = 2;
                }
                break;
            }
        }
        if (action == AtackMenu.menuOptions.At1)
        {
            cor.Ps -= cor2.Atacks[0].Power * cor2.Dam * typeMult / cor.Def / typeDiv;
        }
        else if (action == AtackMenu.menuOptions.At2)
        {
            cor.Ps -= cor2.Atacks[1].Power * cor2.Dam * typeMult / cor.Def / typeDiv;
        }
        else if (action == AtackMenu.menuOptions.At3)
        {
            cor.Ps -= cor2.Atacks[2].Power * cor2.Dam * typeMult / cor.Def / typeDiv;
        }
        else if (action == AtackMenu.menuOptions.At4)
        {
            cor.Ps -= cor2.Atacks[3].Power * cor2.Dam * typeMult / cor.Def / typeDiv;
        }
        atacando = false;
    }
 private void increaseLvlUpExp(Coremon mon)            //Only called from levelUp function
 {
     // lvlUpExp += lvlUpExp * increaseFactor
     mon.LvlUpExp += Mathf.CeilToInt(mon.LvlUpExp * lvlUpExpIncreaseFactor);
 }