コード例 #1
0
        public virtual TUpdate AddUpdatable <TUpdate>(TUpdate updatable) where TUpdate : IUpdate
        {
            lock (Updatables)
            {
                Updatables.Add(updatable);
            }

            return(updatable);
        }
コード例 #2
0
 // *** 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);
     }
 }
コード例 #3
0
        //**********************************************************

        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public Updatable() : base()
 {
     Updatables.Add(this);
 }