Ejemplo n.º 1
0
    /** 增加当前组CD时间经过(cd减少) */
    public void addGroupTimePass(int groupID, int value)
    {
        if (value == 0)
        {
            return;
        }

        if (_cds.isEmpty())
        {
            return;
        }

        bool has = false;
        //只添加,触发还是基于onTen

        IntIntMap groupCDCount = _groupCDCount;

        bool needReCount = false;

        CDData[] values = _cds.getValues();
        CDData   data;
        int      vv;

        for (int i = values.Length - 1; i >= 0; --i)
        {
            if ((data = values[i]) != null)
            {
                if (data.config.hasGroup(groupID))
                {
                    has = true;

                    vv = (data.timePass) + value;

                    if (vv > data.timeMax)
                    {
                        vv = data.timeMax;
                    }

                    if (vv < 0)
                    {
                        vv = 0;
                    }

                    data.timePass = vv;

                    if (data.config.groups.Length > 1)
                    {
                        foreach (int gv in data.config.groups)
                        {
                            if (gv != groupID)
                            {
                                //不止这个
                                if (groupCDCount.get(gv) > 1)
                                {
                                    needReCount = true;
                                }
                            }
                        }
                    }
                }
            }
        }

        if (has)
        {
            if (needReCount)
            {
                reCountGroupCDMax();
            }

            _parent.onCDChange();
        }
    }