示例#1
0
    public void MoveTo(ScollerItemBase toItem)
    {
        Vector3 frontPos = toItem.GetTargetPosition();

        this.cellNumber = toItem.cellNumber;

        targetPos = cellTransform.localPosition = frontPos;
    }
示例#2
0
    public virtual void ExChangeCell(ScollerItemBase toItem, byte direct)
    {
        //向右
        if (direct == 1)
        {
            cellNumber = (sbyte)(toItem.cellNumber - 1);

            cellIndex = toItem.cellIndex - 1;

            float tmpX = toItem.GetTargetPosition().x - GetCellWidth();  //Mathf.Abs(toItem.GetTargetPosition().x) - Mathf.Abs(cellWidth);
            cellTransform.localPosition = new Vector3(tmpX, toItem.GetTargetPosition().y, toItem.GetTargetPosition().z);
        }// 向左
        else if (direct == 2)
        {
            cellNumber = (sbyte)(toItem.cellNumber + 1);



            float tmpX = Mathf.Abs(toItem.GetTargetPosition().x) + Mathf.Abs(toItem.GetCellWidth());
            cellTransform.localPosition = new Vector3(tmpX, toItem.GetTargetPosition().y, toItem.GetTargetPosition().z);

            cellIndex = toItem.cellIndex + 1;
        }
        // 向下拖
        else if (direct == 3)
        {
            cellNumber = (sbyte)(toItem.cellNumber - 1);
            cellIndex  = toItem.cellIndex - 1;


            float tmpY = GetCellHeight(); // Mathf.Abs(toItem.GetTargetPosition().y) - Mathf.Abs(cellHeight);
            cellTransform.localPosition = new Vector3(toItem.GetTargetPosition().x, toItem.GetTargetPosition().y + tmpY, toItem.GetTargetPosition().z);
        }
        // 向上拖
        else if (direct == 4)
        {
            cellNumber = (sbyte)(toItem.cellNumber + 1);

            cellIndex = toItem.cellIndex + 1;

            float tmpY = Mathf.Abs(toItem.GetTargetPosition().y) + Mathf.Abs(toItem.GetCellHeight());
            cellTransform.localPosition = new Vector3(toItem.GetTargetPosition().x, -tmpY, toItem.GetTargetPosition().z);
        }


        targetPos = cellTransform.localPosition;
    }
示例#3
0
    //
    public void FollowFront(ScollerItemBase frontItem)
    {
        Vector3 frontPos = frontItem.GetTargetPosition();



        if (direct == ScollerDirect.Horizontal)
        {
            frontPos.x += frontItem.GetCellWidth();
        }
        else
        {
            frontPos.y -= frontItem.GetCellHeight();
        }

        targetPos = cellTransform.localPosition = frontPos;
    }
示例#4
0
    public void CaculateMovePosition(ScollerItemBase frontItem)
    {
        Vector3 frontPos = frontItem.GetTargetPosition();



        if (direct == ScollerDirect.Horizontal)
        {
            frontPos.x += frontItem.GetCellWidth();
        }
        else
        {
            frontPos.y -= frontItem.GetCellHeight();
        }

        isPlaying = true;


        //UnityEngine.Debug.Log("CaculateMovePosition  isPlaying" + cellIndex);
        animalState = 2;

        targetPos = frontPos;
    }
示例#5
0
    private void ScolerValueChange(Vector2 pos)
    {
        if (!IsPlayingAnimal)
        {
            return;
        }

        RefushCellCount();
        Vector3 contPos = content.InverseTransformPoint(conner);


        ScollerItemBase tmpItem = FindCell(1);

        byte tmpDirect = RejugdeDirect(contPos, tmpItem);



        if (tmpDirect == 0)
        {
            return;
        }



        switch (tmpDirect)
        {
        //    1  水平右
        case 1:
        {
            float tmpFloat = Mathf.Abs(contPos.x - tmpItem.GetTargetPosition().x);


            ScollerItemBase iterm0 = FindCell(0);

            if (tmpFloat >= iterm0.GetCellWidth() * 0.5f && contPos.x < tmpItem.GetTargetPosition().x)
            {
                ExchangeCell(cellCount - 1, 0, tmpDirect);
            }


            // UpdateContent();
        }
        break;

        //2 水平左
        case 2:
        {
            float tmpFloat = Mathf.Abs(tmpItem.GetTargetPosition().x - contPos.x);


            if (tmpFloat >= tmpItem.GetCellWidth() * 0.5f && contPos.x > tmpItem.GetTargetPosition().x)
            {
                ExchangeCell(0, cellCount - 1, tmpDirect);
            }

            //  UpdateContent();
        }
        break;

        // 4,向上拖
        case 4:
        {
            float tmpFloat = Mathf.Abs(tmpItem.GetTargetPosition().y - contPos.y);


            if ((tmpFloat >= tmpItem.GetCellHeight() * 0.5f) && (tmpItem.GetTargetPosition().y > contPos.y))
            {
                ExchangeCell(0, cellCount - 1, tmpDirect);
            }

            //    UpdateContent();
        }
        break;

        //3,向下拖
        case 3:
        {
            float tmpFloat = Mathf.Abs(contPos.y - tmpItem.GetTargetPosition().y);



            ScollerItemBase iterm0 = FindCell(0);
            if (tmpFloat >= iterm0.GetCellHeight() * 0.8f && tmpItem.GetTargetPosition().y < contPos.y)
            {
                ExchangeCell(cellCount - 1, 0, tmpDirect);
            }


            //    UpdateContent();
        }
        break;
        }
    }