/// <summary> /// 取消心跳 /// </summary> /// <param name="timer"></param> public void Unreg(int timer) { var update = Updatables.Find(x => x.Id == timer); if (update != null) { UnregisterUpdatable(update); } }
public virtual TUpdate AddUpdatable <TUpdate>(TUpdate updatable) where TUpdate : IUpdate { lock (Updatables) { Updatables.Add(updatable); } return(updatable); }
public void SetView(View view) { _view = view; _view.ProgressBarMinimum = 0; _view.ProgressBarValue = 0; _view.ProgressBarMaxiumum = Updatables.Count(x => x.RequiresUpdating) * 2; _view.ProgressText1 = "Starting update."; _view.ProgressText2 = ""; //_view.WebBrowserUrl = string.Format("http://outbreak-game.co.uk/launcher.html?i={0}", Guid.NewGuid()); }
// *** Updated in Assignment 3: Section2 ****************************** public void Add <T>(T component) where T : Component { Remove <T>(); component.GameObject = this; component.Transform = Transform; Components.Add(typeof(T), component); if (component is IUpdateable) { Updatables.Add(component as IUpdateable); } if (component is IRenderable) { Renderables.Add(component as IRenderable); } if (component is IDrawable) { Drawables.Add(component as IDrawable); } }
public void Remove <T>() where T : Component { if (Components.ContainsKey(typeof(T))) { Component component = Components[typeof(T)]; Components.Remove(typeof(T)); if (component is IUpdateable) { Updatables.Remove(component as IUpdateable); } if (component is IRenderable) { Renderables.Remove(component as IRenderable); } if (component is IDrawable) { Drawables.Remove(component as IDrawable); } } }
public float GetIntervalMS(int timer) { //IUpdatable te; //Updatables.TryGetValue(timer, out te); //if (te != null) //{ // var t = te as TimerEntry; // return t.Interval; //} var update = (TimerEntry)Updatables.Find(x => x.Id == timer); if (update != null) { return(update.Interval); } return(0f); }
//********************************************************** public T Add <T>() where T : Component, new() { Remove <T>(); T component = new T(); component.GameObject = this; component.Transform = Transform; Components.Add(typeof(T), component); if (component is IUpdateable) { Updatables.Add(component as IUpdateable); } if (component is IRenderable) { Renderables.Add(component as IRenderable); } if (component is IDrawable) { Drawables.Add(component as IDrawable); } return(component); }
public GameplayState() { World = new World(10, 16); Score = 0; PointsForLine = 10; Name = ToString().Split(".").Last(); _droppingScheduler = new RecurrentScheduler() .Schedule() .Every(Sfs.Time.FromSeconds(0.5f)) .Execute(() => World.CurrentPiece.Drop(World.Matrix)); var endGameScheduler = new ConditionScheduler() .Schedule() .When(() => World.WorldEnded) .Execute(() => SwitchState(new SummaryState(Score))); _scoreResolver = new LaneScourer(PointsForLine); Updatables.Add(World); Updatables.Add(_droppingScheduler); Updatables.Add(endGameScheduler); }
public virtual void Die() { Updatables.Remove(this); }
public Updatable() : base() { Updatables.Add(this); }
/// <summary> /// 是否包含计时器 /// </summary> /// <param name="timer"></param> /// <returns></returns> public bool ContainsTimer(int timer) { return(Updatables.Find(x => x.Id == timer) != null); }
public override void Die() { Updatables.Remove(this); Drawables.Remove(this); }