示例#1
0
    public void PlayTraj()
    {
        PlayButton.SetActive(false);
        PauseButton.SetActive(true);
        FrameSlider.GetComponent <SliderGestureControl>().SetSpan(0, framenum - 1);
        SpeedSlider.GetComponent <SliderGestureControl>().SetSpan(0, 100);
        SpeedSlider.GetComponent <SliderGestureControl>().SetSliderValue(25);
        //Time.timeScale = 1;
        //GameObject.Find("PlayButton").AddComponent<PlayButton2>();

        // gets the total number of frames from Load
        //framenum = Manager.GetComponent<Load>().framenum;


        StartCoroutine("Traj");
    }
示例#2
0
    IEnumerator Traj()
    {
        while (true)
        {
            //MoleculeCollection.transform.rotation = new Quaternion(0, 0, 0, 0);
            //Manager.GetComponent<DestroyPrimitive>().DestroyObjects();
            i = Convert.ToInt32(FrameSlider.GetComponent <SliderGestureControl>().SliderValue);

            if (Manager.GetComponent <Load>().dynamicBonds)
            {
                // TODO: Have bonds form/break depending on distance if dynamic bonds is turned on
            }

            // move the spheres for bns model so they are where they should be for current frame
            transform.parent.GetComponent <BallAndStick>().MoveSpheres(i);
            // update the text below the play button to display the current frame
            //txt.GetComponent<ChangeText>().currentFrame = i;
            //txt.GetComponent<ChangeText>().ChangeIt();

            speed = 100f / ((SpeedSlider.GetComponent <SliderGestureControl>().SliderValue + 1) * framenum); // TODO: get this from another class which is for a slider or smth later

            // Wait for a small amount of time before proceeding
            yield return(new WaitForSeconds(speed));

            // reset slider to 0 if it reaches the max value so it loops
            if (i == FrameSlider.GetComponent <SliderGestureControl>().MaxSliderValue)
            {
                FrameSlider.GetComponent <SliderGestureControl>().SetSliderValue(0);

                // move the spheres to where the should be for frame 0
                transform.parent.GetComponent <BallAndStick>().MoveSpheres(i);
                // make currentframe display 0
                //txt.GetComponent<ChangeText>().currentFrame = i;
                //txt.GetComponent<ChangeText>().ChangeIt();

                //wait for a small amount of time before proceeding
                yield return(new WaitForSeconds(speed));
            }

            // increment the slider value to go to the next frame
            FrameSlider.GetComponent <SliderGestureControl>().SetSliderValue((Convert.ToInt32(FrameSlider.GetComponent <SliderGestureControl>().SliderValue) + 1));
        }
    }