private void CheckNeedExecAutoFocus()
        {
            this.AutoFit.set_velocity(new Vector2(Mathf.Clamp((float)this.AutoFit.get_velocity().x, -this.VELOCITY_MAX, this.VELOCITY_MAX), 0.0f));
            if ((double)Mathf.Abs((float)this.AutoFit.get_velocity().x) > (double)this.AUTOFIT_BEGIN_VELOCITY)
            {
                return;
            }
            List <GameObject> objects = new List <GameObject>();

            foreach (Component componentsInChild in (UnitInventoryJobIcon[])((Component)this).GetComponentsInChildren <UnitInventoryJobIcon>())
            {
                objects.Add(componentsInChild.get_gameObject());
            }
            GameObject gameObject = this.Focus(objects, false, false, 0.1f);

            if (UnityEngine.Object.op_Inequality((UnityEngine.Object)gameObject, (UnityEngine.Object)null))
            {
                UnitInventoryJobIcon component = (UnitInventoryJobIcon)gameObject.GetComponent <UnitInventoryJobIcon>();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null) && !component.IsDisabledBaseJobIcon())
                {
                    UnitEnhanceV3.Instance.OnJobSlotClick(((Component)component.BaseJobIconButton).get_gameObject());
                }
            }
            this.IsNeedAutoFit = false;
        }
 private void UpdateItemsPositionReverse(bool is_move_right, bool is_move_left)
 {
     for (int index = 0; index < this.mItems.Count; ++index)
     {
         UnitInventoryJobIcon jobIcon1 = this.mItems[index].job_icon;
         UnitInventoryJobIcon jobIcon2 = this.mItems[0].job_icon;
         UnitInventoryJobIcon jobIcon3 = this.mItems[this.mItems.Count - 1].job_icon;
         if (is_move_right && this.CheckRightAreaOut(this.mItems[index]))
         {
             this.OnItemUpdate.Invoke(int.Parse(((UnityEngine.Object) this.mItems[0].gameObject).get_name()) - 1, this.mItems[index].gameObject);
             float num = (float)this.mItems[0].position.x - jobIcon2.HalfWidth - this.ITEM_DISTANCE - jobIcon1.HalfWidth;
             this.mItems[index].position = new Vector2(num, (float)this.mItems[index].position.y);
             JobIconScrollListController.ItemData mItem = this.mItems[index];
             this.mItems.RemoveAt(index);
             this.mItems.Insert(0, mItem);
             index = -1;
         }
         else if (is_move_left && this.CheckLeftAreaOut(this.mItems[index]))
         {
             this.OnItemUpdate.Invoke(int.Parse(((UnityEngine.Object) this.mItems[this.mItems.Count - 1].gameObject).get_name()) + 1, this.mItems[index].gameObject);
             float num = (float)this.mItems[this.mItems.Count - 1].position.x + jobIcon3.HalfWidth + this.ITEM_DISTANCE + jobIcon1.HalfWidth;
             this.mItems[index].position = new Vector2(num, (float)this.mItems[index].position.y);
             JobIconScrollListController.ItemData mItem = this.mItems[index];
             this.mItems.RemoveAt(index);
             this.mItems.Add(mItem);
             index = -1;
         }
     }
 }
 public ItemData(GameObject obj)
 {
     this.gameObject    = obj;
     this.rectTransform = obj.get_transform() as RectTransform;
     this.position      = this.rectTransform.get_anchoredPosition();
     this.job_icon      = (UnitInventoryJobIcon)obj.GetComponent <UnitInventoryJobIcon>();
 }
        public void Repotision()
        {
            this.GetRectTransForm.set_anchoredPosition(Vector2.get_zero());
            this.mPreAnchoredPositionX = this.AnchoredPosition;
            float num1 = 0.0f;
            float num2 = 0.0f;
            float num3 = 0.0f;

            for (int index = 0; index < this.mItems.Count; ++index)
            {
                UnitInventoryJobIcon jobIcon = this.mItems[index].job_icon;
                float num4;
                if (index <= 0)
                {
                    num4 = num3 + jobIcon.HalfWidth;
                    num1 = jobIcon.HalfWidth;
                }
                else
                {
                    num4 = num3 + (jobIcon.HalfWidth + this.ITEM_DISTANCE);
                    num2 = jobIcon.HalfWidth;
                }
                this.mItems[index].rectTransform.set_anchoredPosition(new Vector2(num4 * this.ScrollDir, 0.0f));
                this.mItems[index].position = this.mItems[index].rectTransform.get_anchoredPosition();
                num3 = num4 + jobIcon.HalfWidth;
            }
            this.mViewArea = new Rect((float)this.mItems[0].rectTransform.get_anchoredPosition().x - num1, 0.0f, (float)this.mItems[this.mItems.Count - 1].rectTransform.get_anchoredPosition().x + num2, 0.0f);
            int           num5       = 0;
            List <string> stringList = new List <string>();

            for (int index = 0; index < this.mItems.Count; ++index)
            {
                if (!stringList.Contains(((UnityEngine.Object) this.mItems[index].job_icon.BaseJobIconButton).get_name()))
                {
                    stringList.Add(((UnityEngine.Object) this.mItems[index].job_icon.BaseJobIconButton).get_name());
                    if (this.mItems[index].job_icon.IsSingleIcon)
                    {
                        ++num5;
                    }
                }
            }
            float num6 = this.SINGLE_ICON_ZERO_MERGIN;

            if (num5 == 1)
            {
                num6 = this.SINGLE_ICON_ONE_MERGIN;
            }
            if (num5 == 2)
            {
                num6 = this.SINGLE_ICON_TWO_MERGIN;
            }
            if (num5 >= 3)
            {
                num6 = this.SINGLE_ICON_THREE_MERGIN;
            }
            this.mViewPort.set_offsetMin(new Vector2(num6, 0.0f));
            this.mViewPort.set_offsetMax(new Vector2(-num6, 0.0f));
            this.IsInitialized = true;
        }
Example #5
0
        public void Refresh(bool is_hide = false)
        {
            UnitData unit = UnitEnhanceV3.Instance.CurrentUnit;

            DataSource.Bind <UnitData>(((Component)this).get_gameObject(), unit);
            for (int index = 0; index < this.UnitJobIconSetList.Count; ++index)
            {
                this.UnitJobIconSetList[index].ResetParam();
            }
            JobSetParam[] cc_jobset_array = MonoSingleton <GameManager> .Instance.GetClassChangeJobSetParam(unit.UnitID);

            if (cc_jobset_array == null)
            {
                cc_jobset_array = new JobSetParam[0];
            }
            this.mJobSetDatas.Clear();
            int key = 0;

            for (int i = 0; i < unit.Jobs.Length; ++i)
            {
                int index = Array.FindIndex <JobSetParam>(cc_jobset_array, (Predicate <JobSetParam>)(jobset => jobset.job == unit.Jobs[i].JobID));
                if (index >= 0)
                {
                    JobSetParam base_jobset_param = MonoSingleton <GameManager> .Instance.GetJobSetParam(cc_jobset_array[index].jobchange);

                    if (Array.FindIndex <JobData>(unit.Jobs, (Predicate <JobData>)(job => job.JobID == base_jobset_param.job)) < 0)
                    {
                        int[] numArray = new int[2] {
                            i, -1
                        };
                        this.mJobSetDatas.Add(key, numArray);
                        ++key;
                    }
                }
                else
                {
                    int num = -1;
                    for (int j = 0; j < cc_jobset_array.Length; ++j)
                    {
                        if (MonoSingleton <GameManager> .Instance.GetJobSetParam(cc_jobset_array[j].jobchange).job == unit.Jobs[i].JobID)
                        {
                            num = Array.FindIndex <JobData>(unit.Jobs, (Predicate <JobData>)(job => job.JobID == cc_jobset_array[j].job));
                            break;
                        }
                    }
                    int[] numArray = new int[2] {
                        i, num
                    };
                    this.mJobSetDatas.Add(key, numArray);
                    ++key;
                }
            }
            for (int index = 0; index < this.mJobIconScrollListController.Items.Count; ++index)
            {
                ((Component)this.mJobIconScrollListController.Items[index].job_icon).get_gameObject().SetActive(false);
            }
            if (this.mJobSetDatas.Count <= 2)
            {
                for (int job_index = 0; job_index < this.mJobSetDatas.Count; ++job_index)
                {
                    ((Component)this.mJobIconScrollListController.Items[job_index].job_icon).get_gameObject().SetActive(true);
                    this.RefreshJobIcon(((Component)this.mJobIconScrollListController.Items[job_index].job_icon).get_gameObject(), job_index);
                }
            }
            else
            {
                for (int index = 0; index < this.mJobIconScrollListController.Items.Count; ++index)
                {
                    ((Component)this.mJobIconScrollListController.Items[index].job_icon).get_gameObject().SetActive(true);
                    int job_index = int.Parse(((UnityEngine.Object) this.mJobIconScrollListController.Items[index].job_icon).get_name());
                    this.RefreshJobIcon(((Component)this.mJobIconScrollListController.Items[index].job_icon).get_gameObject(), job_index);
                }
            }
            this.mJobIconScrollListController.Repotision();
            List <GameObject> objects = new List <GameObject>();

            for (int index = 0; index < this.mJobIconScrollListController.Items.Count; ++index)
            {
                if (((UnityEngine.Object) this.mJobIconScrollListController.Items[index].job_icon.BaseJobIconButton).get_name() == UnitEnhanceV3.Instance.CurrentUnit.JobIndex.ToString())
                {
                    objects.Add(((Component)this.mJobIconScrollListController.Items[index].job_icon).get_gameObject());
                }
            }
            if (objects.Count <= 0)
            {
                for (int index = 0; index < this.mJobIconScrollListController.Items.Count; ++index)
                {
                    if (((UnityEngine.Object) this.mJobIconScrollListController.Items[index].job_icon.CcJobButton).get_name() == UnitEnhanceV3.Instance.CurrentUnit.JobIndex.ToString())
                    {
                        objects.Add(((Component)this.mJobIconScrollListController.Items[index].job_icon).get_gameObject());
                    }
                }
            }
            GameObject gameObject = this.ScrollClampedJobIcons.Focus(objects, true, is_hide, 0.0f);

            if (UnityEngine.Object.op_Inequality((UnityEngine.Object)gameObject, (UnityEngine.Object)null))
            {
                UnitInventoryJobIcon component = (UnitInventoryJobIcon)gameObject.GetComponent <UnitInventoryJobIcon>();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                {
                    UnitEnhanceV3.Instance.OnJobSlotClick(((Component)component.BaseJobIconButton).get_gameObject());
                }
            }
            this.mJobIconScrollListController.Step();
            DataSource.Bind <UnitData>(this.JobNameObject, unit);
            GameParameter.UpdateAll(((Component)this).get_gameObject());
            this.UpdateJobSlotStates(true);
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.SkinButton, (UnityEngine.Object)null))
            {
                ((Selectable)this.SkinButton).set_interactable(unit.IsSkinUnlocked());
            }
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.VoiceButton, (UnityEngine.Object)null) || !UnityEngine.Object.op_Inequality((UnityEngine.Object) this.VoiceUnlock, (UnityEngine.Object)null))
            {
                return;
            }
            this.VoiceUnlock.SetActive(!unit.CheckUnlockPlaybackVoice());
        }