コード例 #1
0
    public void Move(float dt)
    {
        if (line.isEnd(nextIndex))
        {
            StopMove();
            return;
        }

        if (!endWaitPoint)
        {
            return;
        }


        while (myPos >= line.getTime(myIndex, nextIndex))
        {
            myPos     -= line.getTime(myIndex, nextIndex);
            myIndex    = nextIndex;
            nextIndex += turnBack ? -1 : 1;



            if (line.isEnd(nextIndex))
            {
                if (loop)
                {
                    turnBack   = !turnBack;
                    nextIndex += turnBack ? -2 : 2;

                    StartCoroutine(WaitTime(myIndex));
                    myRigidbody.MovePosition(line.getConcretePosiion(myIndex));
                }
                else
                {
                    StopMove();
                    myRigidbody.MovePosition(line.getConcretePosiion(myIndex));
                    return;
                }
            }
            else
            {
                StartCoroutine(WaitTime(myIndex));
                myRigidbody.MovePosition(line.getConcretePosiion(myIndex));
            }
        }

        myPos += dt;
        var temp = line.getPosition(myIndex, nextIndex, myPos / line.getTime(myIndex, nextIndex));

        myRigidbody.MovePosition(temp);
        transform.position = temp;
    }