public void StartTimer(float duration = -1, bool hasTimerObject = false, Transform parent = null, bool bar = true, bool numbers = true) { if (duration != -1) { timerDuration = duration; } timerStart = DateTime.Now; if (hasTimerObject) { if (timerObject == null) { GameObject go = (GameObject)GameObject.Instantiate(StateMaster.instance.timer); timerObject = go.GetComponent <TimerObject> (); if (parent != null) { go.transform.SetParent(parent); } go.transform.localPosition = Vector3.zero; go.transform.localEulerAngles = Vector3.zero; timerObject.sm = sm; timerObject.timer = this; timerObject.StartTimer(timerDuration, bar, numbers); } } }
/// <summary> /// Allows the game to setup the environment and matrices. /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); GL.Enable(EnableCap.DepthTest); GL.ClearColor(Color4.CornflowerBlue); GL.Enable(EnableCap.CullFace); view = Matrix4.CreateTranslation(1, -1, -12.5f); // Vector4.Transform(lightPosition, view); projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45), 800f / 480f, 0.01f, 100f); modelManager.BindGeometetry(shaderManager); CreateSystems(); CreateEntities(); mTimer.StartTimer(); }
public static void Start(Action onTImerCallback, float time, float repeatRate = 0) { if (onTImerCallback == null) { Debug.LogError("定时回调不能为空"); return; } if (Instance.m_TimerDic.ContainsKey(onTImerCallback)) { Stop(onTImerCallback); } TimerObject timerObject = Instance.m_TimerPool.Get() as TimerObject; Instance.m_TimerDic[onTImerCallback] = timerObject; timerObject.StartTimer(onTImerCallback, time, repeatRate); }
public static void StartWithArg(Action <object> onTimerWithArgCallback, float time, float repeatRate, object arg) { if (onTimerWithArgCallback == null) { Debug.LogError("定时回调不能为空"); return; } if (Instance.m_TimerWithArgDic.ContainsKey(onTimerWithArgCallback)) { Debug.Log("之前有"); StopWithArg(onTimerWithArgCallback); } TimerObject timerObject = Instance.m_TimerPool.Get() as TimerObject; Instance.m_TimerWithArgDic[onTimerWithArgCallback] = timerObject; timerObject.StartTimer(onTimerWithArgCallback, time, repeatRate, arg); }
public void StartTimer() { m_Timer.StartTimer(); }