/// <summary>
        /// Initialize all the buttons' scale size.
        /// </summary>
        private void InitAsympScale()
        {
            // if not this effect, return it.
            if (!mAsympEffect)
            {
                return;
            }

            JCS_RollSelectorButton currentBtn = null;

            int centerIndex = JCS_Mathf.FindMiddleIndex(mButtons.Length);

            // initialzie the scroll index.
            for (int index = 0;
                 index < mButtons.Length;
                 ++index)
            {
                currentBtn = mButtons[index];

                Vector3 scale = Vector3.zero;
                if (index <= centerIndex)
                {
                    scale = (mAsympDiffScale * index) + mAsympDiffScale;
                }
                else
                {
                    scale = (mAsympDiffScale * (index - ((index - centerIndex) * 2))) + mAsympDiffScale;
                }

                if (mPanelRoot != null)
                {
                    scale.x /= mPanelRoot.PanelDeltaWidthRatio;
                    scale.y /= mPanelRoot.PanelDeltaHeightRatio;
                }

                JCS_ScaleEffect se = currentBtn.GetScaleEffect();

                if (se == null)
                {
                    JCS_Debug.LogError(
                        "JCS_ScaleEffect are null but we still want the effect. plz make sure all the button have JCS_ScaleEffet component!");

                    // close the effect.
                    mAsympEffect = false;

                    return;
                }

                se.RecordScale += scale;

                // the change value plus the original scale.
                // so it will keep the original setting form the
                // level designer.
                se.TowardScale += scale + se.GetScaleValue();

                se.JCS_OnMouseOver();
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="diffIndex"></param>
        private void ApplyTargetForAnim(int diffIndex)
        {
            JCS_RollSelectorButton currentBtn = null;
            JCS_RollSelectorButton targetBtn  = null;

            Vector3[] newTargetPosHolder = new Vector3[mButtons.Length];
            int[]     scrollIndexHolder  = new int[mButtons.Length];

            // asymp scale effect
            Vector3[] newRecordScaleHolder = new Vector3[mButtons.Length];
            Vector3[] newTowardScaleHolder = new Vector3[mButtons.Length];

            for (int index = 0; index < mButtons.Length; ++index)
            {
                int overflowIndex = JCS_Mathf.OverFlowIndex(index + diffIndex, mButtons.Length);

                currentBtn = mButtons[index];
                targetBtn  = mButtons[overflowIndex];

                if (currentBtn == null || targetBtn == null)
                {
                    JCS_Debug.LogError("Missing jcs_button assign in the inspector...");
                    continue;
                }

                Vector3 newTargetPos = currentBtn.SimpleTrackAction.TargetPosition;

                newTargetPos = targetBtn.SimpleTrackAction.TargetPosition;

                newTargetPosHolder[index] = newTargetPos;
                scrollIndexHolder[index]  = targetBtn.ScrollIndex;

                if (mAsympEffect)
                {
                    newRecordScaleHolder[index] = targetBtn.GetScaleEffect().RecordScale;
                    newTowardScaleHolder[index] = targetBtn.GetScaleEffect().TowardScale;
                }
            }

            for (int index = 0; index < mButtons.Length; ++index)
            {
                currentBtn = mButtons[index];

                currentBtn.SimpleTrackAction.TargetPosition = newTargetPosHolder[index];

                currentBtn.ScrollIndex = scrollIndexHolder[index];

                if (mAsympEffect)
                {
                    JCS_ScaleEffect se = currentBtn.GetScaleEffect();

                    se.RecordScale = newRecordScaleHolder[index];
                    se.TowardScale = newTowardScaleHolder[index];
                    se.JCS_OnMouseOver();
                }
            }
        }