Пример #1
0
 public Health(Life life, double value)
 {
     this.Name        = "Health";
     this.Description = "The health rate of the life, and it will die when the healty is empty.";
     this.Life        = life;
     this.value       = value;
     Empty            = new Stimulus(life, life.NoReactionStimulus);
     life.BuildReaction(Empty, life.Behaviours[Behaviours.Action.Die.TypeID]);
     Low = new Stimulus(life, life.NoReactionStimulus);
     life.StimulusList.Add(Low);
 }
Пример #2
0
 public void Stimulate(Stimulus stimulus, params object[] args)
 {
     if (stimulus == null)
     {
         throw new ArgumentNullException();
     }
     if (this.PendingStimulus.Count > 200)
     {
         return;
     }
     this.PendingStimulus.Enqueue(new PendingStimulus(stimulus, args));
 }
Пример #3
0
        private void cloneReaction(Stimulus stimulusFrom, Stimulus stimulusTo, Life life)
        {
            var behaviorList = new List <Behaviour>();

            foreach (var reaction in stimulusFrom.Reactions)
            {
                foreach (var behaviors in reaction.Behaviours)
                {
                    behaviorList.Add(behaviors.Clone(life));
                }
            }
            life.BuildReaction(stimulusTo, behaviorList.ToArray());
        }
Пример #4
0
 public ReactionRecord(Stimulus stimulus, Reaction reaction)
 {
     if (stimulus == null)
     {
         throw new ArgumentNullException("The Stimulus cannot be null.");
     }
     if (reaction == null)
     {
         throw new ArgumentNullException("The reaction cannot be null.");
     }
     this.Stimulus = stimulus;
     this.Reaction = reaction;
 }
Пример #5
0
 public Stimulus(Life life, Stimulus noReaction)
 {
     if (life == null)
     {
         throw new ArgumentNullException("The life cannot be null.");
     }
     this.Life        = life;
     this.NoReaction  = noReaction;
     this.ID          = life.World.CreateStimulusID();
     this.Name        = "Stimulus-" + this.ID;
     this.Description = "A stimulus.";
     life.StimulusList.Add(this);
 }
Пример #6
0
        public Reaction BuildReaction(Stimulus stimulusSource, params Behaviour[] behaviors)
        {
            if (stimulusSource == null || behaviors == null)
            {
                throw new ArgumentNullException();
            }
            if (!this.StimulusList.Contains(stimulusSource))
            {
                throw new Exception("Stimulus no available.");
            }
            var reaction = new Reaction(this, stimulusSource);

            stimulusSource.Reactions.Add(reaction);
            this.ReactionList.Add(reaction);
            return(reaction);
        }
Пример #7
0
 public Reaction(Life life, Stimulus source)
 {
     if (life == null)
     {
         throw new ArgumentNullException("The life cannot be null.");
     }
     if (source == null)
     {
         throw new ArgumentNullException("The source cannot be null.");
     }
     this.Life        = life;
     this.Source      = source;
     this.behaviours  = new LifeGameX.RandomList <LifeGameX.Behaviour>();
     this.Description = "A reaction when " + this.Life + " is stimulated by " + this.Source.Name + " . ";
     life.RandomWeightList.Add(this);
 }
Пример #8
0
        public Stimulus(Life life, Stimulus noReaction)
        {
            if (life == null)
            {
                throw new ArgumentNullException("The life cannot be null.");
            }

            /*if (noReaction == null)
             *  throw new ArgumentNullException("NoReaction stimulus required.");*/
            this.Reactions   = new RandomList <Reaction>();
            this.Life        = life;
            this.NoReaction  = noReaction;
            this.ID          = life.World.CreateStimulusID();
            this.Name        = "Stimulus-" + this.ID;
            this.Description = "A stimulus.";
            life.StimulusList.Add(this);
        }
Пример #9
0
 public void Stimulate(Stimulus stimulus, params object[] args)
 {
     this.PendingStimulus.Enqueue(new PendingStimulus(stimulus, args));
 }
Пример #10
0
 public PendingStimulus(Stimulus stimulus, object[] args)
 {
     this.Stimulus = stimulus;
     this.Args     = args;
 }