Exemple #1
0
        /// <summary>
        /// 取消心跳
        /// </summary>
        /// <param name="timer"></param>
        public void Unreg(int timer)
        {
            var update = Updatables.Find(x => x.Id == timer);

            if (update != null)
            {
                UnregisterUpdatable(update);
            }
        }
Exemple #2
0
        public virtual TUpdate AddUpdatable <TUpdate>(TUpdate updatable) where TUpdate : IUpdate
        {
            lock (Updatables)
            {
                Updatables.Add(updatable);
            }

            return(updatable);
        }
Exemple #3
0
 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());
 }
Exemple #4
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);
     }
 }
Exemple #5
0
 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);
         }
     }
 }
Exemple #6
0
        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);
        }
Exemple #7
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);
        }
        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);
        }
Exemple #9
0
 public virtual void Die()
 {
     Updatables.Remove(this);
 }
Exemple #10
0
 public Updatable() : base()
 {
     Updatables.Add(this);
 }
Exemple #11
0
 /// <summary>
 /// 是否包含计时器
 /// </summary>
 /// <param name="timer"></param>
 /// <returns></returns>
 public bool ContainsTimer(int timer)
 {
     return(Updatables.Find(x => x.Id == timer) != null);
 }
Exemple #12
0
 public override void Die()
 {
     Updatables.Remove(this);
     Drawables.Remove(this);
 }