Exemple #1
0
        public string GetDefaultPresetName()
        {
            var count      = 1;
            var presetName = string.Format("{0}{1}", EB.Localizer.GetString("ID_SCHEME"), count);

            while (PresetNameSet.Contains(presetName))
            {
                count     += 1;
                presetName = string.Format("{0}{1}", EB.Localizer.GetString("ID_SCHEME"), count);
            }

            return(presetName);
        }
Exemple #2
0
        private void RefreshList(List <KeyValuePair <string, EquipmentPresetModel> > list)
        {
            if (list == null)
            {
                return;
            }

            HashSet <string> samePresets;
            bool             hasSame      = HasSamePresetWithCurrentEquipment(list, out samePresets);
            var currentEquippedPresetName = string.Empty;
            var currentSelectedPresetName = string.Empty;
            var parent = _uiGrid.transform;

            _activeItems.Clear();

            if (CurrentEquipmentPresetItem != null)
            {
                currentSelectedPresetName = CurrentEquipmentPresetItem.KVP.Key;
            }

            if (hasSame)
            {
                if (EquippedPresetItem != null && samePresets.Contains(EquippedPresetItem.KVP.Key))
                {
                    currentEquippedPresetName = EquippedPresetItem.KVP.Key;
                }
                else
                {
                    var enumerator = samePresets.GetEnumerator();

                    if (enumerator.MoveNext())
                    {
                        currentEquippedPresetName = enumerator.Current;
                    }
                }
            }

            for (var i = 0; i < _totalItems.Count; i++)
            {
                _totalItems[i].mDMono.gameObject.SetActive(false);
            }

            for (var i = 0; i < list.Count; i++)
            {
                LTPartnerEquipmentPresetItem item;

                if (_totalItems.Count > i)
                {
                    item = _totalItems[i];
                }
                else
                {
                    var go = GameObject.Instantiate(_currentItemObj, parent);
                    go.transform.SetSiblingIndex(parent.childCount - 2);
                    go.name = list[i].Value.ts.ToString();

                    item = go.GetMonoILRComponent <LTPartnerEquipmentPresetItem>();
                    _totalItems.Add(item);
                }

                item.SetData(list[i].Key.Equals(currentEquippedPresetName), list[i]);
                item.mDMono.gameObject.SetActive(true);
                _activeItems.Add(item);
            }

            if (hasSame)
            {
                _currentItemObj.SetActive(false);
            }
            else
            {
                EnableCurrentItem();
            }

            _addItemObj.SetActive(list.Count < maxPresetCount);
            _uiGrid.Reposition();
            SetCount(list.Count);

            if (PresetNameSet.Contains(currentSelectedPresetName))
            {
                SetHighlightFromName(currentSelectedPresetName);
            }

            LocateToItem(CurrentEquipmentPresetItem);
        }
Exemple #3
0
        public void SaveScheme(string presetName, int ts, int[] eids, string originPresetName = null)
        {
            if (string.IsNullOrEmpty(originPresetName) && PresetList.Count >= maxPresetCount)
            {
                MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, EB.Localizer.GetString("ID_EQUIPMENT_PRESET_FULL"));
                return;
            }

            //编辑方案改名后,先将原方案删除再新增方案
            if (!string.IsNullOrEmpty(originPresetName) && !originPresetName.Equals(presetName) && PresetNameSet.Contains(originPresetName))
            {
                LTPartnerEquipDataManager.Instance.RequestDeleteEquipmentPreset(LoginManager.Instance.LocalUserId.Value, originPresetName, ht => {
                    OnAddScheme(presetName, ts, eids);
                });
            }
            else
            {
                OnAddScheme(presetName, ts, eids);
            }
        }