예제 #1
0
    /// <summary>
    /// 把神格按高等级到低等级排列
    /// </summary>
    /// <param name="prop"></param>
    /// <returns></returns>
    public List <ShenGeInfo> getAllShenGeInStorage(Prop prop)
    {
        Prop tmpProp                 = prop;
        int  shengeLevel             = prop.getShenGeLevel();
        List <ShenGeInfo> shenGeList = new List <ShenGeInfo>();
        List <Prop>       list       = getTheSameTypeShenGe(tmpProp.getType());

        for (int i = shengeLevel; i > 0; i--)
        {
            for (int k = 0; k < list.Count; k++)
            {
                Prop temp = list[k];
                if (i == temp.getShenGeLevel())
                {
                    ShenGeInfo info = new ShenGeInfo();
                    info.sid   = temp.sid;
                    info.level = i;
                    info.num   = temp.getNum();
                    shenGeList.Add(info);
                }
            }
        }
        return(shenGeList);
    }
예제 #2
0
    /// <summary>
    /// 检测是否可以升级
    /// </summary>
    /// <param name="prop"></param>
    /// <returns></returns>
    public bool checkCanGroup(Prop prop, int type)
    {
        Prop tmpProp = prop;

        if (tmpProp == null)
        {
            return(false);
        }
        PropSample sample     = PropSampleManager.Instance.getPropSampleBySid(tmpProp.sid);
        PropSample nextSample = PropSampleManager.Instance.getPropSampleBySid(sample.nextLevelSid);

        if (nextSample == null)
        {
            return(false);
        }
        int nextShenGeExp      = nextSample.expValue;
        List <ShenGeInfo> list = getAllShenGeInStorage(tmpProp);

        //取得升级所需的神格列表
        if (shengeList == null)
        {
            shengeList = new List <ShenGeInfo>();
        }
        else
        {
            shengeList.Clear();
        }
        if (type == 1)
        {
            for (int i = 0; i < list.Count; i++)
            {
                Prop temp = StorageManagerment.Instance.getProp(list[i].sid);
                if (temp.sid == tmpProp.sid)
                {
                    if (temp.getNum() == 1)
                    {
                        list.Remove(list[i]);
                    }
                    else
                    {
                        list[i].num -= 1;
                    }
                }
            }
        }
        int sum = 0;

        for (int i = 0; i < list.Count; i++)
        {
            Prop temp = StorageManagerment.Instance.getProp(list[i].sid);
            //if (type == 1) {//仓库合成
            //    if (tmpProp.sid == temp.sid) {
            //        sum += (temp.getShenGeExp() * (temp.getNum() - 1));
            //    } else
            //        sum += (temp.getShenGeExp() * temp.getNum());
            //} else
            sum += (temp.getShenGeExp() * list[i].num);

            if (sum < (nextShenGeExp / 2))
            {
                shengeList.Add(list[i]);
            }
            else if (sum == (nextShenGeExp / 2))
            {
                shengeList.Add(list[i]);
                return(true);
            }
            else
            {
                int        moreNum = (sum - (nextShenGeExp / 2)) / temp.getShenGeExp();
                ShenGeInfo tmpInfo = new ShenGeInfo();
                tmpInfo.level = temp.getShenGeLevel();
                tmpInfo.sid   = temp.sid;
                tmpInfo.num   = list[i].num - moreNum;
                shengeList.Add(tmpInfo);
                return(true);
            }
        }
        return(false);
    }