Ejemplo n.º 1
0
    private void LevelUp()
    {
        float previousLv = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("level").n;

        if (previousLv >= StaticVariables.characterData.GetField("maxLevel").n)
        {
            pointsToGain = 0;
            return;
        }
        float previousHp      = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("hp").n;
        float previousMp      = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("mp").n;
        float previousAttack  = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("attack").n;
        float previousDefense = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("defense").n;
        float previousSpeed   = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("speed").n;
        float previousCD      = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("CD").n;

        StaticVariables.saveData.GetField("characters").list[StaticVariables.characterID].SetField("exp", 0);
        float currLevel = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("level").n;

        StaticVariables.saveData.GetField("characters").list[StaticVariables.characterID].SetField("level", currLevel + 1);

        description.text  = "Level = " + previousLv + "  →  " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("level").n;
        description.text += "\nHP = " + previousHp + "  →  " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("hp").n;
        description.text += "\nMP = " + previousMp + "  →  " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("mp").n;
        description.text += "\nAttack = " + previousAttack + "  →  " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("attack").n;
        description.text += "\nDefense = " + previousDefense + "  →  " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("defense").n;
        description.text += "\nSpeed = " + previousSpeed + "  →  " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("speed").n;
        description.text += "\nMP Regen. = " + previousCD + "  →  " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("CD").n;
    }
Ejemplo n.º 2
0
    private void ExpGrow()
    {
        float maxExp  = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("maxExpForThisLevel").n;
        float currExp = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("currentExp").n;
        float level   = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("level").n;

        float expGrowInUpdate =
            Mathf.Min(Time.deltaTime * speed, pointsToGain);
        float expGrow = Mathf.Min(expGrowInUpdate, maxExp - currExp);

        //Debug.Log("expGrow = " + expGrow);
        StaticVariables.saveData["characters"].list[StaticVariables.characterID]["exp"].n = expGrow + currExp;
        pointsToGain -= expGrow;
        accExp       += expGrow;

        if (expGrow + currExp == maxExp)
        {
            LevelUp();
            float previousLv = StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("level").n;
            if (previousLv >= StaticVariables.characterData["maxLevel"].n)
            {
                StaticVariables.saveData.GetField("characters").list [StaticVariables.characterID].SetField("exp", 0);
                pointsToGain = 0;
            }
        }
        //StaticVariables.characterID
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        float currExp = StaticVariables.GetCharacterAttribute(StaticVariables.characterID)["currentExp"].n;
        float maxExp  = StaticVariables.GetCharacterAttribute(StaticVariables.characterID)["maxExpForThisLevel"].n;
        float width   = maxWidth * currExp / maxExp;

        GetComponent <RectTransform>().sizeDelta = new Vector2(width, GetComponent <RectTransform>().sizeDelta.y);
        if (pointsToGain > 0)
        {
            ExpGrow();
        }
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Awake()
    {
        if (isStartDebug)
        {
            Load.initialize();
            StaticVariables.GetCharacterAttribute(StaticVariables.characterID);
        }

        if (debugChar != -1)
        {
            StaticVariables.characterID = debugChar;
        }
        for (int i = 0; i < characters.Length; ++i)
        {
            if (i == StaticVariables.characterID)
            {
                characters[i].SetActive(true);
            }
        }

        /*
         *      int playerID = PlayerPrefs.GetInt ("PlayerID");
         *
         *      if(playerID == 0) {
         *              Destroy (character2);
         *      } else if(playerID == 1) {
         *              Destroy (character1);
         *      }
         */
        coin = StaticVariables.coinNumber;  //PlayerPrefs.GetInt ("Coins");
        rank = StaticVariables.ranking;
        time = StaticVariables.raceTimeStr; //PlayerPrefs.GetString ("TotalTime");
        Debug.Log("rank = " + rank);

        /*
         *      if (rank == 1) {
         *              grade.text = "A";
         *              description.text = "CONGRATULATIONS!\nYou were the FIRST ONE who reached the classroom!! You spent " + time + " to reach the classroom. Professor was very happy and decided to give you a BIG A!!";
         *      } else {
         *              grade.text = "B";
         *              description.text = "UNFORTUNATELY...\nYou were NOT the first one who reached the classroom... You spent " + time + " to reach the classroom. As a result, you are not assigned an A... Try again!!";
         *      }
         *      description.text += "\nYou've eared " + coin + " coins during the race. You can go to store to make upgration!";
         */
    }
Ejemplo n.º 5
0
    void Start()
    {
        Load.initialize(true);
        if (debugExp != -1)
        {
            StaticVariables.expGained = debugExp;
        }
        pointsToGain = StaticVariables.expGained;

        speed             = StaticVariables.expGained / totalTime;
        description.text  = "Level = " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("level").n;
        description.text += "\nHP = " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("hp").n;
        description.text += "\nMP = " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("mp").n;
        description.text += "\nAttack = " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("attack").n;
        description.text += "\nDefense = " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("defense").n;
        description.text += "\nSpeed = " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("speed").n;
        description.text += "\nMP Regen. = " + StaticVariables.GetCharacterAttribute(StaticVariables.characterID).GetField("CD").n;
    }