Пример #1
0
        public double TransferTo(SubstanceCapsule res, double amount)
        {
            if (res == null)
            {
                throw new ArgumentNullException("The resource cannot be null.");
            }
            var energy = this.TransferToEnergy(amount);

            amount      = res.Substance.FromEnergy * energy;
            res.Amount += amount;
            return(amount);
        }
Пример #2
0
        public Life Clone()
        {
            var child = new Life(this.Species, this.World);

            child.Energy = 0;

            //clone reaction
            cloneReaction(this.NoReactionStimulus, child.NoReactionStimulus, child);
            cloneReaction(this.EnergyLowStimulus, child.EnergyLowStimulus, child);
            cloneReaction(this.InteractStimulus, child.InteractStimulus, child);
            cloneReaction(this.EnvironmentStimulus, child.EnvironmentStimulus, child);
            cloneReaction(this.TimeUpdateStimulus, child.TimeUpdateStimulus, child);

            //clone resource
            foreach (var res in this.Resources)
            {
                var resCapsule = new SubstanceCapsule(child, res.Key, 0, res.Value.Max.Value, res.Value.Min.Value, res.Value.TransferLimit.Value);
                cloneReaction(res.Value.Few, resCapsule.Few, child);
                cloneReaction(res.Value.Much, resCapsule.Much, child);
                child.AddResource(resCapsule);
            }

            return(child);
        }
Пример #3
0
 public void AddResource(SubstanceCapsule res)
 {
     Resources.Add(res.Substance, res);
     SubstanceCapsuleList.Add(res);
     RandomWeightList.Add(res);
 }