教育类虚拟仿真参考的一个框架

来源:互联网 发布:linux的启动过程详解 编辑:程序博客网 时间:2024/06/06 05:47

下面这个脚本,适合做事件主线的控制

public enum CurrentState{    clickOne,    clickTwo,    clickThere}/// <summary>/// 作者:徐海涛 (hunk Xu) /// 这个脚本比较适合做教育的虚拟仿真,很明显特点就是:先做什么,后做什么,然后接着做什么/// </summary>public class mainTimeLine : MonoBehaviour{    public  CurrentState stateType;    public int count = 0;    public static mainTimeLine instance;    void Awake()    {        instance = this;    }    void Start()    {        count = 0;    }    // Update is called once per frame    void Update()    {        if (count == 0)        {            count = 1;            step01();            step02();        }        if (Input.GetMouseButtonDown(0))        {            //instroduce             stateType=CurrentState.clickOne;            count = 0;        }    }    public void step01(){        if (stateType == CurrentState.clickOne) {            StartCoroutine(Common.DelayToInvokeDo(() =>                {                    //1秒后做什么                }, 1f));            StartCoroutine(Common.DelayToInvokeDo(() =>                {                    //4秒后做什么                }, 4f));            StartCoroutine(Common.DelayToInvokeDo(() =>                {                    //25秒后做什么                }, 25f));        }    }    public void step02(){        if (stateType == CurrentState.clickOne) {        }    }}


还有一个工具类:

using System;using System.Collections;using System.Collections.Generic;using System.IO;using UnityEngine;public class Common {    public static IEnumerator DelayToInvokeDo(Action action, float _delaySeconds)    {        yield return new WaitForSeconds(_delaySeconds);        action();    }}


FR:海涛高软(hunk Xu) QQ技术交流群:386476712

原创粉丝点击