示例#1
0
    void totterSpeed()
    {
        time += Time.deltaTime;

        if (time >= speedChangeFrequency)
        {
            change = Totter.Change;
            time   = 0f;
        }
        else
        {
            change = Totter.Stay;
        }


        if (change == Totter.Change)
        {
            if (curSpeed >= maxSpeed)
            {
                tot = Totter.Down;
                //Debug.Log("going Down");
            }
            else if (curSpeed <= maxSpeed * minSpeedRatio)
            {
                tot = Totter.Up;
                //Debug.Log("going up");
            }

            if (tot == Totter.Up)
            {
                speed    += speedChangeAmount;
                curSpeed += speedChangeAmount;
            }
            else if (tot == Totter.Down)
            {
                speed    -= speedChangeAmount;
                curSpeed -= speedChangeAmount;
            }
        }
        //Debug.Log(curSpeed);
    }
示例#2
0
    void totterSpeed()
    {
        time += Time.deltaTime;

        if (time >= speedChangeFrequency)
        {
            change = Totter.Change;
            time = 0f;
        }
        else
            change = Totter.Stay;

        if (change == Totter.Change)
        {
            if (curSpeed >= maxSpeed)
            {
                tot = Totter.Down;
                //Debug.Log("going Down");
            }
            else if (curSpeed <= maxSpeed * minSpeedRatio)
            {
                tot = Totter.Up;
                //Debug.Log("going up");
            }

            if (tot == Totter.Up)
            {
                speed += speedChangeAmount;
                curSpeed += speedChangeAmount;
            }
            else if (tot == Totter.Down)
            {
                speed -= speedChangeAmount;
                curSpeed -= speedChangeAmount;
            }
        }
        //Debug.Log(curSpeed);
    }