예제 #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;
 }