Exemplo n.º 1
0
        public void RefreshBehaviorTick <T>()
        {
            EntityBehavior B = GetBehavior <T>().ToDynamic();

            if (B != null)
            {
                _behaviorTicks[_behaviors.IndexOf(B)] = B.FramesPerTick;
            }
        }
Exemplo n.º 2
0
 public void AddBehavior(EntityBehavior behavior)
 {
     if (_behaviors == null)
     {
         _behaviors     = new List <EntityBehavior>();
         _behaviorTicks = new List <int>();
     }
     _behaviors.Add(behavior);
     _behaviorTicks.Add(0);
 }
Exemplo n.º 3
0
 public void RemoveBehavior(EntityBehavior behavior)
 {
     if (_behaviors == null)
     {
         _behaviors     = new List <EntityBehavior>();
         _behaviorTicks = new List <int>();
     }
     if (_behaviors.Contains(behavior))
     {
         _behaviorTicks.RemoveAt(_behaviors.IndexOf(behavior));
         _behaviors.Remove(behavior);
     }
 }
Exemplo n.º 4
0
 public virtual void Update()
 {
     Ani.Position += Speed;
     Ani.Update();
     if (_behaviors != null)
     {
         int i = 0;
         while (i < _behaviors.Count)
         {
             EntityBehavior behavior = _behaviors[i];
             if (behavior.enabled && _behaviorTicks[i]++ >= behavior.FramesPerTick)
             {
                 _behaviorTicks[i] = 0;
                 behavior.Update();
             }
             i++;
         }
     }
 }