Exemple #1
0
        public string GetPrivilegeContent(VIPPrivilegeItem item, string key)
        {
            string format    = item.Format;
            string colorText = item.Status == PrivilegeStatus.Ordinary ? "[ECF5FD]" : (item.Status == PrivilegeStatus.Newly ? "[FFFF6E]" : "[41FC7B]");

            if (!key.Equals(VIPPrivilegeKey.EatEquipmentGift))
            {
                int    multiplier = 0;
                string content    = string.Format(format, (item.Value != 0) ? item.Value : item.Percent * multiplier);
                if (key.EndsWith("discount"))
                {
                    multiplier = 10;
                    string per =
                        content = string.Format(format, global::UserData.Locale == EB.Language.English ?
                                                string.Format("{0}%", ((1f - item.Percent) * 100).ToString("0"))
                                        : (item.Percent * multiplier).ToString("0"));
                }
                else
                {
                    multiplier = 100;
                    content    = string.Format(format, (item.Value != 0) ? item.Value : item.Percent * multiplier);
                }

                //content = content.TrimNumberEnd();
                int index = item.Status == PrivilegeStatus.HasChanged ? (content.Contains("+") ? content.IndexOf("+") :
                                                                         (content.Contains(":") ? content.IndexOf(":") + 1 :format.IndexOf("{"))) : 0;
                return(content.Length > index && index >= 0 ? content.Insert(index, colorText) : content);
            }
            else
            {
                string words = string.Empty;
                if (!string.IsNullOrEmpty(item.Format))
                {
                    string[] array = item.DataString.Split('|');
                    List <LTShowItemData> itemDatas = SceneTemplateManager.Instance.ParseShowItem(array[1]);

                    itemDatas.ForEach(data => {
                        //EconemyItemTemplate itemTemplate = EconemyTemplateManager.Instance.GetItem(data.id);
                        if (item.Status == PrivilegeStatus.Ordinary || item.Status == PrivilegeStatus.Newly)
                        {
                            words += colorText + StringUtil.Format(format, array[0], data.count /*, itemTemplate.Name*/) + "\n";
                        }
                        else
                        {
                            words += StringUtil.Format(format, array[0], colorText + data.count /*, itemTemplate.Name*/) + "\n";
                        }
                    });
                }

                return(words.TrimEnd('\n'));
            }
        }
Exemple #2
0
        private Dictionary <string, VIPPrivilegeItem> GetPrivilegeDict(VIPPrivilege profile)
        {
            Dictionary <string, VIPPrivilegeItem> privileges = new Dictionary <string, VIPPrivilegeItem>();

            if (profile == null)
            {
                return(privileges);
            }

            Dictionary <string, int> .Enumerator   numEnumerator     = profile.GetNumEnumerator();
            Dictionary <string, float> .Enumerator percentEnumerator = profile.GetPercentEnumerator();
            while (numEnumerator.MoveNext())
            {
                string key = numEnumerator.Current.Key;
                if (vipData.VipCertificates.Contains(key))
                {
                    int value = profile.GetTotalNum(key);                    // + VIPTemplateManager.Instance.GetMonthVIPNum(key);
                    if (value > 0)
                    {
                        VIPPrivilegeItem item = new VIPPrivilegeItem();
                        item.Value = value;
                        privileges.Add(key, item);
                    }
                }
            }
            while (percentEnumerator.MoveNext())
            {
                string key = percentEnumerator.Current.Key;
                if (vipData.VipCertificates.Contains(key))
                {
                    float value = profile.GetPercent(key);
                    bool  valid = key.Equals(VIPPrivilegeKey.ShopDiscount) ? value > 0 && value < 1 : value > 0;
                    if (valid)
                    {
                        VIPPrivilegeItem item = new VIPPrivilegeItem();
                        item.Percent = value;
                        privileges.Add(key, item);
                    }
                }
            }
            return(privileges);
        }
Exemple #3
0
        private void AppendOrUpdatePrivilegeItem(ref Dictionary <string, VIPPrivilegeItem> privileges, string key, object value, bool valid, VIPPrivilege comparer)
        {
            Dictionary <string, VIPPrivilegeItem> oldPrivileges = GetPrivilegeDict(comparer);

            if (!valid)
            {
                privileges.Remove(key);
                return;
            }

            bool has = privileges.TryGetValue(key, out VIPPrivilegeItem item);

            if (item == null)
            {
                item = new VIPPrivilegeItem();
            }

            if (comparer == null || (comparer != null && !oldPrivileges.ContainsKey(key)))
            {
                item.Status = comparer == null ? PrivilegeStatus.Ordinary : PrivilegeStatus.Newly;
            }
            else
            {
                if (value is int)
                {
                    int oldValue = comparer.GetTotalNum(key);
                    item.Status = oldValue != (int)value ? PrivilegeStatus.HasChanged : PrivilegeStatus.Ordinary;
                }
                else
                {
                    float oldValue = comparer.GetPercent(key);
                    item.Status = oldValue != (float)value ? PrivilegeStatus.HasChanged : PrivilegeStatus.Ordinary;
                }
            }
            item.Format  = GetPrivilegeKeyWords(key);
            item.Value   = value is int?(int)value     : item.Value;
            item.Percent = value is float?(float)value : item.Percent;
            if (!has)
            {
                privileges.Add(key, item);
            }
        }
Exemple #4
0
        private void OnEquipmentGift(ref Dictionary <string, VIPPrivilegeItem> privileges, VIPPrivilege privilege, VIPPrivilege comparer)
        {
            VIPPrivilegeItem item = privileges.ContainsKey(VIPPrivilegeKey.EatEquipmentGift) ? privileges[VIPPrivilegeKey.EatEquipmentGift] : new VIPPrivilegeItem();

            if (!string.IsNullOrEmpty(privilege.EatEquipmentGift))
            {
                item.Format = GetPrivilegeKeyWords(VIPPrivilegeKey.EatEquipmentGift);
                item.Status = comparer == null ? PrivilegeStatus.Ordinary :
                              (string.IsNullOrEmpty(comparer.EatEquipmentGift) ? PrivilegeStatus.Newly :
                               (comparer.EatEquipmentGift.Equals(privilege.EatEquipmentGift) ? PrivilegeStatus.Ordinary : PrivilegeStatus.HasChanged));
                if (!privileges.ContainsKey(VIPPrivilegeKey.EatEquipmentGift))
                {
                    privileges.Add(VIPPrivilegeKey.EatEquipmentGift, item);
                }
                item.DataString = privilege.EatEquipmentGift;
            }
            else
            {
                privileges.Remove(VIPPrivilegeKey.EatEquipmentGift);
            }
        }
Exemple #5
0
        private void OnRefreshVIPPrivilegeUIInfo(List <KeyValuePair <string, VIPPrivilegeItem> > list)
        {
            UIGrid           gridParent = controller.UiGrids["PrivilegeGrid"];
            List <Transform> itemList   = gridParent.GetChildList();

            if (itemList != null)
            {
                itemList.Sort((left, right) => { if (left.localPosition.y < right.localPosition.y)
                                                 {
                                                     return(1);
                                                 }
                                                 else
                                                 {
                                                     return(-1);
                                                 } });
            }

            int index    = 0;
            int posindex = 0;

            for (int i = 0; i < list.Count; i++)
            {
                VIPPrivilegeItem itemData   = list[i].Value;
                GameObject       itemObject = null;
                if (itemList != null && index < itemList.Count)
                {
                    itemObject = itemList[index].gameObject;
                }
                else
                {
                    itemObject = Object.Instantiate(m_PrivilegeItemPrefab);
                    gridParent.AddChild(itemObject.transform);
                }
                itemObject.GetComponent <UIWidget>().alpha = 1;
                UILabel  label = itemObject.transform.Find("Content").GetComponent <UILabel>();
                UISprite icon  = itemObject.transform.Find("Icon").GetComponent <UISprite>();
                label.transform.gameObject.CustomSetActive(true);
                icon.transform.gameObject.CustomSetActive(true);
                itemObject.transform.localScale = Vector3.one;
                label.text = LTVIPDataManager.Instance.GetPrivilegeContent(itemData, list[i].Key);
                icon.color = itemData.Status == PrivilegeStatus.Newly ? Color.yellow : Color.white;
                posindex   = label.height / 40 - 1;
                if (posindex > 0)
                {
                    for (int j = 0; j < posindex; j++)
                    {
                        index++;
                        if (itemList != null && index < itemList.Count)
                        {
                            itemObject = itemList[index].gameObject;
                        }
                        else
                        {
                            itemObject = Object.Instantiate(m_PrivilegeItemPrefab);
                            gridParent.AddChild(itemObject.transform);
                        }
                        itemObject.transform.Find("Icon").gameObject.CustomSetActive(false);
                        itemObject.transform.Find("Content").gameObject.CustomSetActive(false);
                        itemObject.transform.localScale = Vector3.one;
                    }
                }
                index++;
            }

            if (itemList != null && index < itemList.Count)
            {
                for (int i = index; i < itemList.Count; i++)
                {
                    itemList[i].gameObject.GetComponent <UIWidget>().alpha = 0;
                }
            }

            controller.GObjects["PrivilegeArrow"].SetActive(index > 12);

            gridParent.Reposition();
            ResetUIScrollView(gridParent, index);
        }