Exemple #1
0
 //更新放大大小
 void UpdateScale(float time)
 {
     for (int i = 0; i <= _menuList.Count; i++) //如果是單行,i就只會是0
     {
         float scale;
         if (i == _index)
         {
             //物件放大
             scale = AnimationCurveManager.GetValueBetweenTwoParameter(1, _scale, _scaleCurve, time);
         }
         else
         {
             //物件大小正常
             scale = 1;
         }
         //設定大小
         SetMenuScale(i, scale);
     }
 }
Exemple #2
0
    //更新Menu縮放
    void UpdateMenuPosition(float time)
    {
        //先弄出一個陣列,然後算出相對上一個的距離
        Vector3[,] array;
        if (_menuList.Count < _numberInRow)
        {
            array = new Vector3[1, _menuList.Count];//設定陣列範圍
        }
        else
        {
            array = new Vector3[(_menuList.Count / _numberInRow) + 1, _numberInRow];
        }

        for (int i = 0; i <= (_menuList.Count / _numberInRow); i++) //如果是單行,i就只會是0
        {
            for (int k = 0; k < _numberInRow; k++)
            {
                int nowIndex = i * _numberInRow + k;
                if (nowIndex < _menuList.Count)
                {
                    float horizontalPosition = 0; //距離左邊位置
                    float verticlPosition    = 0; //距離上方位置

                    //如果是index那行或是+1,就表示要放大(或是跑動畫)
                    if (IsInIndexColumn(nowIndex))
                    {
                        //表示是剛剛是往上下移動才會有動畫
                        if (IndexMovePosition().left == true || IndexMovePosition().right == true)
                        {
                            horizontalPosition = AnimationCurveManager.GetValueBetweenTwoParameter(_menuHorizontalDistance, _horizontalDistenceBetweenIndexToMenu, _moveCurve, time);
                        }
                        else
                        {
                            horizontalPosition = _horizontalDistenceBetweenIndexToMenu;
                        }
                    }
                    else
                    {
                        horizontalPosition = _menuHorizontalDistance;//正常大小
                    }
                    //計算出橫的的距離,表示目前index為橫的
                    if (IsInIndexRow(nowIndex))
                    {
                        //如果是index那一列或是+1,就表示要放大(或是跑動畫)
                        if (IndexMovePosition().up == true || IndexMovePosition().down == true)
                        {
                            verticlPosition = AnimationCurveManager.GetValueBetweenTwoParameter(_menuVerticalDistance, _verticalDistenceBetweenIndexToMenu, _moveCurve, time);
                        }
                        else
                        {
                            verticlPosition = _verticalDistenceBetweenIndexToMenu;
                        }
                    }
                    else
                    {
                        //正常大小
                        verticlPosition = _menuVerticalDistance;
                    }

                    array[i, k].x = horizontalPosition;//水平
                    array[i, k].y = verticlPosition;
                }
            }
        }


        float nowTotlWidth   = 0; //距離左邊的距離 (( horizontalPosition
        float nowTotalHeight = 0; //距離上面的距離 (( verticlPosition

        if (!_vertical)
        {
            //然後填入位置
            for (int i = 0; i <= (_menuList.Count / _numberInRow); i++) //如果是單行,i就只會是0
            {
                nowTotlWidth = 0;
                for (int k = 0; k < _numberInRow; k++)
                {
                    int nowIndex = i * _numberInRow + k;
                    if (nowIndex < _menuList.Count)
                    {
                        if (_focusViewToIndex)
                        {
                            //設定位置
                            SetMenuPosition(nowIndex, nowTotlWidth + array[i, k].x - array[_index / _numberInRow, _index % _numberInRow].x, nowTotalHeight + array[i, k].y - array[_index / _numberInRow, _index % _numberInRow].y);
                            //幫下一個加好
                            nowTotlWidth = nowTotlWidth + array[i, k].x;
                        }
                        else
                        {
                            //設定位置
                            SetMenuPosition(nowIndex, nowTotlWidth + array[i, k].x, nowTotalHeight + array[i, k].y);
                            //幫下一個加好
                            nowTotlWidth = nowTotlWidth + array[i, k].x;
                        }
                    }
                }
                nowTotalHeight = nowTotalHeight + array[i, 0].y;
            }
        }
        else
        {
            //然後填入位置
            for (int i = 0; i <= (_menuList.Count / _numberInRow); i++) //如果是單行,i就只會是0
            {
                nowTotalHeight = 0;
                for (int k = 0; k < _numberInRow; k++)
                {
                    int nowIndex = i * _numberInRow + k;
                    if (nowIndex < _menuList.Count)
                    {
                        if (_focusViewToIndex)
                        {
                            Debug.Log("_focusViewToIndex" + array[_index / _numberInRow, _index % _numberInRow].y);
                            //設定位置
                            SetMenuPosition(nowIndex, nowTotlWidth + array[i, k].x - array[_index / _numberInRow, _index % _numberInRow].x, nowTotalHeight + array[i, k].y - array[_index / _numberInRow, _index % _numberInRow].y);
                            //設定大小
                            SetMenuScale(nowIndex, array[i, k].z);
                            //幫下一個加好
                            nowTotalHeight = nowTotalHeight + array[i, k].y;
                        }
                        else
                        {
                            //設定位置
                            SetMenuPosition(nowIndex, nowTotlWidth + array[i, k].x, nowTotalHeight + array[i, k].y);
                            //設定大小
                            SetMenuScale(nowIndex, array[i, k].z);
                            //幫下一個加好
                            nowTotalHeight = nowTotalHeight + array[i, k].y;
                        }
                    }
                }
                nowTotlWidth = nowTotlWidth + array[i, 0].x;
            }
        }
    }