public virtual TUpdate AddUpdatable <TUpdate>(TUpdate updatable) where TUpdate : IUpdate { lock (Updatables) { Updatables.Add(updatable); } return(updatable); }
// *** 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 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 Updatable() : base() { Updatables.Add(this); }