예제 #1
0
    //---------------------------------------------------
    // CheckRange()
    // Checks the incoming range to make sure it doesn't
    // overlap with the already loaded ranges.
    //---------------------------------------------------
    private bool CheckRange(string strError, XpRewardRange rangeNew)
    {
        bool bOK = true;

        // min and max levels of new range
        int nMinNew = rangeNew.GetMinLevel();
        int nMaxNew = rangeNew.GetMaxLevel();

        // if the min is below 1 or greater than the max, something is wrong
        if (nMinNew < 1 || nMinNew > nMaxNew)
        {
            bOK = false;
        }

        // loop through all the existing ranges and see if the min or max of this new range fall between them
        for (int i = 0; i < listRanges.Count; ++i)
        {
            XpRewardRange range = listRanges[i];

            if (range.IsInBetween(nMinNew) || range.IsInBetween(nMaxNew))
            {
                bOK = false;
            }
        }

        if (!bOK)
        {
            Debug.LogError(strError + "Something going wrong in range data");
        }

        return(bOK);
    }
예제 #2
0
    //---------------------------------------------------
    // GetRange()
    // Returns the range data for the incoming level.
    //---------------------------------------------------
    private XpRewardRange GetRange(int nLevel)
    {
        // the correct range given the incoming level
        XpRewardRange rangeCorrect = null;

        // loop through and search for the correct range...yeah I could break out of it when it's found, but I always forget how/when break works
        for (int i = 0; i < listRanges.Count; ++i)
        {
            XpRewardRange range = listRanges[i];
            if (range.IsInBetween(nLevel))
            {
                rangeCorrect = range;
            }
        }

        if (rangeCorrect == null)
        {
            Debug.LogError("Attempted to get range data for " + GetID() + " for level " + nLevel + " but it did not exist...");
        }

        return(rangeCorrect);
    }