Exemple #1
0
 private void OnMax()
 {
     if (this.mCacheExpItemList == null || this.mCacheExpItemList.Count < 0)
     {
         return;
     }
     for (int index = 0; index < this.mItems.Count; ++index)
     {
         UnitLevelUpListItem component = (UnitLevelUpListItem)this.mItems[index].GetComponent <UnitLevelUpListItem>();
         if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
         {
             component.Reset();
         }
     }
     this.CalcCanUnitLevelUpMax();
 }
Exemple #2
0
 private void OnCancel()
 {
     if (this.mSelectExpItems.Count <= 0)
     {
         return;
     }
     for (int index = 0; index < this.mItems.Count; ++index)
     {
         UnitLevelUpListItem component = (UnitLevelUpListItem)this.mItems[index].GetComponent <UnitLevelUpListItem>();
         if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
         {
             component.Reset();
         }
     }
     this.mSelectExpItems.Clear();
     this.RefreshFinishedStatus();
 }
Exemple #3
0
        private void Init()
        {
            if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ListParent, (UnityEngine.Object)null) || UnityEngine.Object.op_Equality((UnityEngine.Object) this.ListItemTemplate, (UnityEngine.Object)null))
            {
                return;
            }
            this.master = MonoSingleton <GameManager> .Instance.MasterParam;
            if (this.master == null)
            {
                return;
            }
            this.player = MonoSingleton <GameManager> .Instance.Player;
            if (this.player == null)
            {
                return;
            }
            UnitData dataOfClass1 = DataSource.FindDataOfClass <UnitData>(((Component)this).get_gameObject(), (UnitData)null);

            if (dataOfClass1 != null)
            {
                int exp = dataOfClass1.GetExp();
                int num = exp + dataOfClass1.GetNextExp();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.CurrentLevel, (UnityEngine.Object)null))
                {
                    this.CurrentLevel.set_text(dataOfClass1.Lv.ToString());
                }
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.FinishedLevel, (UnityEngine.Object)null))
                {
                    this.FinishedLevel.set_text(this.CurrentLevel.get_text());
                }
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.MaxLevel, (UnityEngine.Object)null))
                {
                    this.MaxLevel.set_text("/" + dataOfClass1.GetLevelCap(false).ToString());
                }
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.NextExp, (UnityEngine.Object)null))
                {
                    this.NextExp.set_text(dataOfClass1.GetNextExp().ToString());
                }
                if (num <= 0)
                {
                    num = 1;
                }
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.LevelGauge, (UnityEngine.Object)null))
                {
                    this.LevelGauge.AnimateValue(Mathf.Clamp01((float)exp / (float)num), 0.0f);
                }
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.GetAllExp, (UnityEngine.Object)null))
                {
                    this.GetAllExp.set_text("0");
                }
                this.mOriginUnit = dataOfClass1;
                this.mExp        = dataOfClass1.Exp;
                this.mLv         = dataOfClass1.Lv;
            }
            List <string>   stringList   = new List <string>((IEnumerable <string>)PlayerPrefsUtility.GetString(PlayerPrefsUtility.UNIT_LEVELUP_EXPITEM_CHECKS, string.Empty).Split('|'));
            List <ItemData> itemDataList = this.player.Items;
            UnitEnhanceV3   dataOfClass2 = DataSource.FindDataOfClass <UnitEnhanceV3>(((Component)this).get_gameObject(), (UnitEnhanceV3)null);

            if (UnityEngine.Object.op_Inequality((UnityEngine.Object)dataOfClass2, (UnityEngine.Object)null))
            {
                itemDataList = dataOfClass2.TmpExpItems;
            }
            for (int index = 0; index < itemDataList.Count; ++index)
            {
                ItemData data = itemDataList[index];
                if (data != null && data.Param != null && (data.Param.type == EItemType.ExpUpUnit && data.Num > 0))
                {
                    GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.ListItemTemplate);
                    if (UnityEngine.Object.op_Inequality((UnityEngine.Object)gameObject, (UnityEngine.Object)null))
                    {
                        DataSource.Bind <ItemData>(gameObject, data);
                        gameObject.get_transform().SetParent((Transform)this.ListParent, false);
                        UnitLevelUpListItem component = (UnitLevelUpListItem)gameObject.GetComponent <UnitLevelUpListItem>();
                        if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                        {
                            component.OnSelect     = new UnitLevelUpListItem.SelectExpItem(this.RefreshExpSelectItems);
                            component.ChangeUseMax = new UnitLevelUpListItem.ChangeToggleEvent(this.RefreshUseMaxItems);
                            component.OnCheck      = new UnitLevelUpListItem.CheckSliderValue(this.OnCheck);
                            this.mUnitLevelupLists.Add(component);
                            if (stringList != null && stringList.Count > 0)
                            {
                                component.SetUseMax(stringList.IndexOf(data.Param.iname) != -1);
                            }
                            if (component.IsUseMax())
                            {
                                this.mCacheExpItemList.Add(data);
                            }
                            gameObject.SetActive(true);
                        }
                        this.mItems.Add(gameObject);
                    }
                }
            }
            if (this.mCacheExpItemList != null && this.mCacheExpItemList.Count > 0)
            {
                this.mCacheExpItemList.Sort((Comparison <ItemData>)((a, b) => b.Param.value - a.Param.value));
            }
            ((Selectable)this.MaxBtn).set_interactable(this.mCacheExpItemList != null && this.mCacheExpItemList.Count > 0);
            ((Selectable)this.DecideBtn).set_interactable(this.mSelectExpItems != null && this.mSelectExpItems.Count > 0);
        }
Exemple #4
0
        private void CalcCanUnitLevelUpMax()
        {
            if (this.mCacheExpItemList == null)
            {
                return;
            }
            long num1 = 0;

            using (List <ItemData> .Enumerator enumerator = this.mCacheExpItemList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ItemData current = enumerator.Current;
                    int      num2    = current.Param.value * current.Num;
                    num1 += (long)num2;
                }
            }
            long num3 = (long)Mathf.Min((float)(this.mOriginUnit.GetGainExpCap() - this.mExp), (float)num1);

            this.mSelectExpItems.Clear();
            int index1 = 0;

            for (int index2 = 0; index2 < this.mCacheExpItemList.Count; ++index2)
            {
                if (num3 <= 0L)
                {
                    num3 = 0L;
                    break;
                }
                ItemData mCacheExpItem1 = this.mCacheExpItemList[index2];
                if (mCacheExpItem1 != null || mCacheExpItem1.Num > 0)
                {
                    ItemData mCacheExpItem2 = this.mCacheExpItemList[index1];
                    if (index2 == index1 || mCacheExpItem2 != null || mCacheExpItem2.Num > 0)
                    {
                        if ((long)mCacheExpItem1.Param.value > num3)
                        {
                            index1 = index2;
                        }
                        else
                        {
                            int num2 = (int)(num3 / (long)mCacheExpItem1.Param.value);
                            int num4 = Mathf.Min(mCacheExpItem1.Num, num2);
                            int num5 = mCacheExpItem1.Param.value * num4;
                            int num6 = mCacheExpItem2.Param.value;
                            if ((long)Mathf.Abs((float)(num3 - (long)num5)) > (long)Mathf.Abs((float)(num3 - (long)num6)))
                            {
                                if (this.mSelectExpItems.ContainsKey(mCacheExpItem2.Param.iname))
                                {
                                    if (mCacheExpItem2.Num - this.mSelectExpItems[mCacheExpItem2.Param.iname] > 0)
                                    {
                                        Dictionary <string, int> mSelectExpItems;
                                        string iname;
                                        (mSelectExpItems = this.mSelectExpItems)[iname = mCacheExpItem2.Param.iname] = mSelectExpItems[iname] + 1;
                                        num3 = 0L;
                                        break;
                                    }
                                }
                                else
                                {
                                    this.mSelectExpItems.Add(mCacheExpItem2.Param.iname, 1);
                                    num3 = 0L;
                                    break;
                                }
                            }
                            num3 -= (long)num5;
                            this.mSelectExpItems.Add(mCacheExpItem1.Param.iname, num4);
                            index1 = index2;
                        }
                    }
                }
            }
            if (num3 > 0L)
            {
                ItemData mCacheExpItem = this.mCacheExpItemList[index1];
                if (mCacheExpItem != null && mCacheExpItem.Num > 0)
                {
                    if (this.mSelectExpItems.ContainsKey(mCacheExpItem.Param.iname))
                    {
                        if (mCacheExpItem.Num - this.mSelectExpItems[mCacheExpItem.Param.iname] > 0)
                        {
                            Dictionary <string, int> mSelectExpItems;
                            string iname;
                            (mSelectExpItems = this.mSelectExpItems)[iname = mCacheExpItem.Param.iname] = mSelectExpItems[iname] + 1;
                        }
                    }
                    else
                    {
                        this.mSelectExpItems.Add(mCacheExpItem.Param.iname, 1);
                    }
                }
            }
            if (this.mSelectExpItems.Count > 0)
            {
                for (int index2 = 0; index2 < this.mItems.Count; ++index2)
                {
                    GameObject mItem       = this.mItems[index2];
                    ItemData   dataOfClass = DataSource.FindDataOfClass <ItemData>(mItem, (ItemData)null);
                    if (dataOfClass != null && this.mSelectExpItems.ContainsKey(dataOfClass.Param.iname))
                    {
                        UnitLevelUpListItem component = (UnitLevelUpListItem)mItem.GetComponent <UnitLevelUpListItem>();
                        if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                        {
                            component.SetUseExpItemSliderValue(this.mSelectExpItems[dataOfClass.Param.iname]);
                        }
                    }
                }
            }
            this.RefreshFinishedStatus();
        }