Ejemplo n.º 1
0
 /// <summary>
 /// Create transition between Invoker and other component.
 /// </summary>
 /// <param name="p"></param>
 /// <param name="minRate"></param>
 /// <param name="maxRate"></param>
 /// <param name="minCooldown"></param>
 /// <param name="maxCooldown"></param>
 /// <param name="terminate"></param>
 public override void ConnectWith(EliotComponent p, int minRate, int maxRate,
                                  float minCooldown, float maxCooldown, bool terminate)
 {
     if (!p)
     {
         return;
     }
     _transitions.Add(new Transition(p, minRate, maxRate, minCooldown, maxCooldown, terminate));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Iitialize the component.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="activationRateMin"></param>
        /// <param name="activationRateMax"></param>
        /// <param name="minCooldown"></param>
        /// <param name="maxCooldown"></param>
        /// <param name="terminateOriginUpdate"></param>
        public Transition(EliotComponent target, int activationRateMin, int activationRateMax,
                          float minCooldown, float maxCooldown, bool terminateOriginUpdate)
        {
            _target = target;
            if (activationRateMin <= 0)
            {
                activationRateMin = 1;
            }
            if (activationRateMax <= activationRateMin)
            {
                activationRateMax = activationRateMin + 1;
            }
            _activationRateMin = activationRateMin;
            _activationRateMax = activationRateMax;

            if (_activationRateMin == 1 && _activationRateMax == 2)
            {
                _useProbability = false;
            }

            if (minCooldown < 0)
            {
                minCooldown = 0;
            }
            if (maxCooldown < 0)
            {
                maxCooldown = 0;
            }
            if (minCooldown == 0 && maxCooldown == 0)
            {
                _useCooldown = false;
            }
            if (_useCooldown)
            {
                if (maxCooldown <= minCooldown)
                {
                    maxCooldown = minCooldown + 1;
                }
            }

            _minCooldown = minCooldown;
            _maxCooldown = maxCooldown;



            _terminateOriginUpdate = terminateOriginUpdate;
        }