示例#1
0
    private void StartNext()
    {
        if (inRoutine && active)
        {
            int lastPos = currentPos - 1;
            if (currentPos == 0)
            {
                lastPos = steps.Length - 1;
            }
            MovementCommand m = steps[lastPos];
            OnEventEnd(lastPos, m.type, m.duration, m.interpretSpeedAsGoal, m.speed, m.angularSpeed, m.freezePosition, m.freezeRotation);
        }
        inRoutine = false;

        if (active)
        {
            MovementCommand m = steps[currentPos];
            inRoutine = true;
            OnEventStart(currentPos, m.type, m.duration, m.interpretSpeedAsGoal, m.speed, m.angularSpeed, m.freezePosition, m.freezeRotation, m.sound);
            switch (m.type)
            {
            case MovementCommand.CommandType.Motion:
                StartCoroutine(Motion(m.duration, m.speed, m.angularSpeed, m.interpretSpeedAsGoal, m.freezePosition, m.freezeRotation, m.sound));
                break;

            case MovementCommand.CommandType.Despawn:
                StartCoroutine(Despawn(m.duration, m.sound));
                break;

            case MovementCommand.CommandType.Kill:
                StartCoroutine(Kill(m.sound));
                break;
            }
            currentPos = (currentPos + 1) % steps.Length;

            if (currentPos == 0 && type == PathType.Single)
            {
                active = false;
            }
        }
        else
        {
            if (attachedBattery)
            {
                attachedBattery.Deactivate();
            }
        }
    }