コード例 #1
0
    //---------------------------------------------------
    // GetPercentage()
    // Returns the % xp to be rewarded by this range
    // given the incoming bonus data.
    //---------------------------------------------------
    public float GetPercentage(Hashtable hashBonusData)
    {
        // this range rewards a base amount of xp even without any bonuses
        float fXP = fReward;

        // now loop through the bonuses and see if any are met
        for (int i = 0; i < listBonuses.Count; ++i)
        {
            XpRewardBonus bonus = listBonuses[i];
            fXP += bonus.GetBonus(hashBonusData);
        }

        return(fXP);
    }
コード例 #2
0
    public XpRewardRange(IXMLNode node, string strError)
    {
        // create list of bonuses for incoming node
        List <IXMLNode> listBonusNodes = XMLUtils.GetChildrenList(node);

        for (int i = 0; i < listBonusNodes.Count; ++i)
        {
            XpRewardBonus bonus = new XpRewardBonus(listBonusNodes[i], strError);
            listBonuses.Add(bonus);
        }

        // get hash of data
        Hashtable hashData = XMLUtils.GetAttributes(node);

        // get the min and max level
        nMinLevel = int.Parse(HashUtils.GetHashValue <string>(hashData, "Min", "1", strError));
        nMaxLevel = int.Parse(HashUtils.GetHashValue <string>(hashData, "Max", Enum.GetNames(typeof(Level)).Length.ToString()));

        // get the base reward
        fReward = float.Parse(HashUtils.GetHashValue <string>(hashData, "Reward", "0", strError));
    }