Exemple #1
0
    // Return the message to be displayed in notification when level up
    public string GetLevelUpMessage()
    {
        Level currentLevel             = DataManager.Instance.GameData.Level.CurrentLevel;
        ImmutableDataPetLevel petLevel = DataLoaderPetLevels.GetLevel(currentLevel);

        return(petLevel.LevelUpMessage);
    }
    public static ImmutableDataPetLevel GetLevel(int nLevel)
    {
        ImmutableDataPetLevel petLevel = null;

        Level level = (Level)nLevel;

        petLevel = GetLevel(level);

        return(petLevel);
    }
Exemple #3
0
    // Return the required points for next level up
    public int NextLevelPoints()
    {
        int adjustedNextLevel = NextLevel;

        // check for max level, because there may not be data that exists after it
        if (IsAtMaxLevel())
        {
            adjustedNextLevel -= 1;
        }
        ImmutableDataPetLevel petLevel = DataLoaderPetLevels.GetLevel((Level)adjustedNextLevel);

        return(petLevel.LevelUpCondition);
    }
    protected override void XMLNodeHandler(string id, IXMLNode xmlNode, Hashtable hashData, string errorMessage)
    {
        ImmutableDataPetLevel data = new ImmutableDataPetLevel(id, xmlNode, errorMessage);

        // store the data
        if (hashData.ContainsKey(id))
        {
            Debug.LogError(errorMessage + "Duplicate keys!");
        }
        else
        {
            hashData.Add(id, data);
        }
    }
Exemple #5
0
    //---------------------------------------------------
    // CalculateXP()
    // Based on the incoming hash bonus data, this function
    // will calculate how much xp the pet should get.
    //---------------------------------------------------
    public int CalculateXP(Hashtable hashBonusData)
    {
        // if the pet is already at max level, then just return 0
        if (LevelLogic.Instance.IsAtMaxLevel())
        {
            return(0);
        }

        // first, we want to get the pet's level
        int nLevel = (int)LevelLogic.Instance.CurrentLevel;

        // now, get the range for that level
        XpRewardRange range = GetRange(nLevel);

        // if the range exists, the get % of xp earned
        float fXP = 0;

        if (range != null)
        {
            fXP = range.GetPercentage(hashBonusData);
        }

        // now get the total xp a pet of this level requires
        int nTotalXP = 0;
        ImmutableDataPetLevel dataLevel = DataLoaderPetLevels.GetLevel(nLevel + 1);

        if (dataLevel != null)
        {
            nTotalXP = dataLevel.LevelUpCondition;
        }

        // multiple this total by percentage to be awarded -- this is our total xp
        int nXP = Mathf.RoundToInt(nTotalXP * fXP);

        //Debug.Log("Awarding " + nXP + " xp(" + fXP + " of " + nTotalXP +")");

        return(nXP);
    }