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

            if (B != null)
            {
                _behaviorTicks[_behaviors.IndexOf(B)] = B.FramesPerTick;
            }
        }
Esempio 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);
 }
Esempio 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);
     }
 }
Esempio 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++;
         }
     }
 }