Пример #1
0
        private void InitEquipConfig()
        {
            if (isInitDict)
            {
                return;
            }
            isInitDict = true;

            equipRecordDict.Clear();

            Table.ForeachEquipBase(record =>
            {
                if (record.ShowEquip != 1)
                {
                    return(true);
                }

                if (record.Occupation == -1)
                {
                    return(true);
                }

                List <EuqipInfo> equipList;
                if (!equipRecordDict.TryGetValue(record.Occupation, out equipList))
                {
                    equipRecordDict[record.Occupation] = new List <EuqipInfo>();
                    equipList = equipRecordDict[record.Occupation];
                }

                var equipInfo    = new EuqipInfo();
                equipInfo.Record = record;
                equipList.Add(equipInfo);

                return(true);
            });

            var enumerator = equipRecordDict.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var equipList = enumerator.Current.Value;
                if (equipList != null)
                {
                    equipList.Sort((l, r) =>
                    {
                        if (l.Record.Ladder > r.Record.Ladder)
                        {
                            return(1);
                        }
                        else if (l.Record.Ladder == r.Record.Ladder)
                        {
                            return(0);
                        }
                        else
                        {
                            return(-1);
                        }
                    });

                    var enumerator1 = equipList.GetEnumerator();
                    var minLadder   = -1;
                    while (enumerator1.MoveNext())
                    {
                        if (enumerator1.Current == null)
                        {
                            continue;
                        }
                        if (enumerator1.Current.Record.Ladder == minLadder || minLadder == -1)
                        {
                            minLadder = enumerator1.Current.Record.Ladder;
                            enumerator1.Current.CanBuy = true;

                            var tbItem = Table.GetItemBase(enumerator1.Current.Record.Id);
                            if (tbItem == null)
                            {
                                continue;
                            }
                            var itemComposeRecord = Table.GetItemCompose(tbItem.ComposeID);
                            if (itemComposeRecord != null)
                            {
                                // 潜规则第一个了。。
                                enumerator1.Current.BuyCost       = itemComposeRecord.NeedCount[0];
                                enumerator1.Current.BuyNeedItemId = itemComposeRecord.NeedId[0];
                                DataModel.NeedItemId = enumerator1.Current.BuyNeedItemId;
                            }
                        }
                        else
                        {
                            enumerator1.Current.CanBuy = false;
                        }
                    }
                }
            }
        }
Пример #2
0
    public void InitEquipConfig()
    {
        if (isInitDict)
        {
            return;
        }
        isInitDict = true;

        equipRecordDict.Clear();

        Table.ForeachEquipBase(record =>
        {
            if (record.ShowEquip != 1)
            {
                return(true);
            }

            if (record.Occupation == -1)
            {
                return(true);
            }

            List <EuqipInfo> equipList;
            if (!equipRecordDict.TryGetValue(record.Occupation, out equipList))
            {
                equipRecordDict[record.Occupation] = new List <EuqipInfo>();
                equipList = equipRecordDict[record.Occupation];
            }

            var equipInfo    = new EuqipInfo();
            equipInfo.Record = record;
            equipList.Add(equipInfo);

            return(true);
        });

        var enumerator = equipRecordDict.GetEnumerator();

        while (enumerator.MoveNext())
        {
            var equipList = enumerator.Current.Value;
            if (equipList != null)
            {
                equipList.Sort((l, r) =>
                {
                    if (l.Record.Ladder > r.Record.Ladder)
                    {
                        return(1);
                    }
                    else if (l.Record.Ladder == r.Record.Ladder)
                    {
                        return(0);
                    }
                    else
                    {
                        return(-1);
                    }
                });

                var enumerator1 = equipList.GetEnumerator();
                var minLadder   = -1;
                while (enumerator1.MoveNext())
                {
                    if (enumerator1.Current == null)
                    {
                        continue;
                    }
                    if (enumerator1.Current.Record.Ladder == minLadder || minLadder == -1)
                    {
                        minLadder = enumerator1.Current.Record.Ladder;
                        enumerator1.Current.CanBuy = true;
                        var tbItem = Table.GetItemBase(enumerator1.Current.Record.Id);
                        if (tbItem == null || tbItem.StoreID < 0)
                        {
                            return;
                        }
                        var tbStore = Table.GetStore(tbItem.StoreID);
                        if (tbStore == null)
                        {
                            return;
                        }
                        enumerator1.Current.BuyCost = tbStore.NeedValue;
                    }
                    else
                    {
                        enumerator1.Current.CanBuy = false;
                    }
                }
            }
        }
    }