Inheritance: IStateChildren
 public static DoMultiple Instance(int doTimes, int cooldown, Behavior behavior)
 {
     var key = new Tuple<int, int, Behavior>(doTimes, cooldown, behavior);
     DoMultiple ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new DoMultiple(doTimes, cooldown, behavior);
     return ret;
 }
Exemple #2
0
 public static OrderGroup Instance(float radius, string group, Behavior behav)
 {
     var key = new Tuple<float, string, Behavior>(radius, group, behav);
     OrderGroup ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new OrderGroup(radius, group, behav);
     return ret;
 }
Exemple #3
0
 public static OrderEntity Instance(float radius, short objType, Behavior behav)
 {
     var key = new Tuple<float, short, Behavior>(radius, objType, behav);
     OrderEntity ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new OrderEntity(radius, objType, behav);
     return ret;
 }
        //Candies
        static BehaviorDef Behaves(
            string name,
            Behavior movement = null,
            Behavior attack = null,
            Behavior reproduce = null,
            LootBehavior loot = null,
            params ConditionalBehavior[] condBehaviors)
        {
            if (loot != null)
            {
                Array.Resize(ref condBehaviors, condBehaviors.Length + 1);
                condBehaviors[condBehaviors.Length - 1] = loot;
            }

            return new BehaviorDef(
                movement ?? NullBehavior.Instance,
                attack ?? NullBehavior.Instance,
                reproduce ?? NullBehavior.Instance,
                condBehaviors);
        }
Exemple #5
0
 private OrderGroup(float radius, string group, Behavior behav)
 {
     this.radius = radius;
     this.group = group;
     this.behav = behav;
 }
 public static IfLesser Instance(int key, int value, Behavior result, Behavior no = null)
 {
     var k = new Tuple<int, int, Behavior, Behavior>(key, value, result, no);
     IfLesser ret;
     if (!instances.TryGetValue(k, out ret))
         ret = instances[k] = new IfLesser(key, value, result, no);
     return ret;
 }
 public static IfExist Instance(int key, Behavior result, Behavior no = null)
 {
     var k = new Tuple<int, Behavior, Behavior>(key, result, no);
     IfExist ret;
     if (!instances.TryGetValue(k, out ret))
         ret = instances[k] = new IfExist(key, result, no);
     return ret;
 }
 public static IfNot Instance(Behavior cond, Behavior result)
 {
     var key = new Tuple<Behavior, Behavior>(cond, result);
     IfNot ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new IfNot(cond, result);
     return ret;
 }
 public static If Instance(Behavior cond, Behavior result, Behavior no = null)
 {
     var key = new Tuple<Behavior, Behavior, Behavior>(cond, result, no);
     If ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new If(cond, result, no);
     return ret;
 }
 public static CooldownExact Instance(int cooldown, Behavior behav = null)
 {
     var key = new Tuple<int, Behavior>(cooldown, behav);
     CooldownExact ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new CooldownExact(cooldown, behav);
     return ret;
 }
 public static RandomDelay2 Instance(int min, int max, Behavior behav)
 {
     var key = new Tuple<int, int, Behavior>(min, max, behav);
     RandomDelay2 ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new RandomDelay2(min, max, behav);
     return ret;
 }
 public static Or Instance(Behavior x, Behavior y)
 {
     var key = Tuple.Create(x, y);
     Or ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new Or(x, y);
     return ret;
 }
 private Or(Behavior x, Behavior y)
 {
     this.x = x;
     this.y = y;
 }
 private And(Behavior x, Behavior y)
 {
     this.x = x;
     this.y = y;
 }
Exemple #15
0
 public DoMultiple(int doTimes, int cooldown, Behavior behavior)
 {
     this.doTimes  = doTimes;
     this.cooldown = cooldown;
     this.behavior = behavior;
 }
 public OnDeath(Behavior behav)
 {
     this.behav = behav;
 }
 private False(Behavior x)
 {
     this.x = x;
 }
 private CooldownExact(int cooldown, Behavior behav)
 {
     this.cooldown = cooldown;
     this.behav = behav;
 }
 public static False Instance(Behavior x)
 {
     False ret;
     if (!instances.TryGetValue(x, out ret))
         ret = instances[x] = new False(x);
     return ret;
 }
 private If(Behavior cond, Behavior result, Behavior no)
 {
     this.cond = cond;
     this.result = result;
     this.no = no;
 }
 private True(Behavior x)
 {
     this.x = x;
 }
 private IfNot(Behavior cond, Behavior result)
 {
     this.cond = cond;
     this.result = result;
 }
 private Once(Behavior x)
 {
     this.x = x;
 }
 private IfExist(int key, Behavior result, Behavior no)
 {
     this.key = key;
     this.result = result;
     this.no = no;
 }
 public static Once Instance(Behavior x)
 {
     Once ret;
     if (!instances.TryGetValue(x, out ret))
         ret = instances[x] = new Once(x);
     return ret;
 }
 private IfLesser(int key, int value, Behavior result, Behavior no)
 {
     this.key = key;
     this.value = value;
     this.result = result;
     this.no = no;
 }
 private Timed(int time, Behavior behav)
 {
     this.time = time;
     this.behav = behav;
 }
 private IfBetween(int key, int minValue, int maxValue, Behavior result, Behavior no)
 {
     this.key = key;
     this.minValue = minValue;
     this.maxValue = maxValue;
     this.result = result;
     this.no = no;
 }
 public static Timed Instance(int time, Behavior behav)
 {
     var key = new Tuple<int, Behavior>(time, behav);
     Timed ret;
     if (!instances.TryGetValue(key, out ret))
         ret = instances[key] = new Timed(time, behav);
     return ret;
 }
Exemple #30
0
 private OrderEntity(float radius, short objType, Behavior behav)
 {
     this.radius = radius;
     this.objType = objType;
     this.behav = behav;
 }
 public RemoveKey(Behavior behav)
 {
     key = behav.Key;
 }
 private RandomDelay2(int min, int max, Behavior behav)
 {
     this.min = min;
     this.max = max;
     this.behav = behav;
 }
 public OnHit(Behavior behav)
 {
     this.behav = behav;
 }