Beispiel #1
0
    public void StartStopRoomba()
    {
        simFastBtn.interactable = true;
        pauseBtn.interactable   = true;

        if (pathType != roombaSettings.GetPathType() && !usingAllPaths)
        {
            pathType = roombaSettings.GetPathType();
        }

        if (isPaused)    //Roomba is paused and needs to be resumed
        {
            roomba.Resume();
            isPaused  = false;
            isStopped = false;
            isPlaying = true;

            // Change the play button icon into a stop button icon
            startStopBtn.GetComponent <Image>().sprite = stopImage;
            startStopBtn.GetComponent <Image>().color  = new Color(255, 0, 0, 255);
        }
        else if (isPlaying)
        {
            //roomba.Stop();
            isPaused  = false;
            isPlaying = false;
            isStopped = true;
            SetDefaults();
            roomba.Stop();
            pathList = new Queue <PathType>(); //Reset the queue if the stop button is clicked

            // Change the stop button icon into a play button icon
            startStopBtn.GetComponent <Image>().sprite = playImage;
            startStopBtn.GetComponent <Image>().color  = new Color(182, 214, 204, 255);
        }
        else if (isStopped)           //Roomba started for the first time
        {
            if (pathType == PathType.All)
            {
                StartAllPaths();
            }
            InitRoomba();

            // Change the play button icon into a stop button icon
            startStopBtn.GetComponent <Image>().sprite = stopImage;
            startStopBtn.GetComponent <Image>().color  = new Color(255, 0, 0, 255);
        }
    }