コード例 #1
0
    public void Update()
    {
        // quit if we're not playing or completed
        if (state != State.Playing)
            return;

		// turn up speed after things get settled
		if ( elapsedTime > 2.0f && elapsedTime < 3.0f )
			Time.timeScale = InteractPlaybackFileMgr.GetInstance().timeScale;

		// elapsed time
		elapsedTime += Time.deltaTime;

		// check playback
		if (currentIdx != -1 && List.Items.Count > 0)
        {
            // get item
            PlaybackItem item = List.Items[currentIdx];

 			// if the elapsed time is greater than item time then just execute it!
			if ( elapsedTime > item.RealTime )
			{
				item.Execute();

				if ( item.Executed == true )
				{
					// reset elapsedTime back to what it should be
					elapsedTime = item.RealTime;
					// increment
	                if (++currentIdx >= List.Items.Count)
	                {
	                   currentIdx = -1;
	                }
				}
			}
        }

		// check break condition, something hung up
		if ( currentIdx != -1 && currentIdx < List.Items.Count-1 )
		{
			PlaybackItem item = List.Items[currentIdx+1];
			if ( item != null )
			{
				if ( item.RealTime-InteractPlaybackMgr.GetInstance().elapsedTime <= 0.0f )
				{
					PlaybackItem current = List.Items[currentIdx];
					UnityEngine.Debug.LogError("InteractPlaybackMgr.Update() : Playback lockup on command <" + current.Debug () + "> at time=" + current.RealTime);
					UnityEngine.Debug.LogError("InteractPlaybackMgr.Update() : prev <" + List.Items[currentIdx-1].Debug () );
					if ( currentIdx+1 < List.Items.Count )
						UnityEngine.Debug.LogError("InteractPlaybackMgr.Update() : next <" + List.Items[currentIdx+1].Debug () );
					if (RestartOnDoneOrError){
						UnityEngine.Debug.LogError("Restarting!");
						RestartWithList(List);
					}
				}
			}

		}

        // check if we're done and then wait 2 seconds and display assessment dialog
        if (Done() == true && elapsedTime > restartTime)
        {
#if DISPLAY_ASSESSMENT_DIALOG
            // run the report here
            // for testing, evaluate on every interact msg...
            ScenarioReport report = new ScenarioReport();
            report.SetInfo("Trauma", "Rob", "123981328123");
            report.SetScenario("Scenario 1");
            report.Evaluate();
            report.SaveDatabase();

            AssessmentMgrDialogMsg amd = new AssessmentMgrDialogMsg();
            amd.command = DialogMsg.Cmd.open;
            amd.Report = report.Report;
            AssessmentMgrDialog.GetInstance().PutMessage(amd);
#endif
			if ( RestartOnDoneOrError == true )
			{
				UnityEngine.Debug.LogError("InteractPlaybackMgr.Update() : Sucessful...Restarting!");
				RestartWithList(List);
			}
        }
    }