Ejemplo n.º 1
0
        private static void DoBreeding()
        {
            Lifeform parentA = null;

            foreach (Lifeform lifeform in BROTHEL)
            {
                if (parentA == null)
                {
                    parentA = lifeform;
                    continue;
                }

                if (lifeform.Species != parentA.Species)
                {
                    continue;
                }

                Lifeform child = Lifeform.Breed(parentA, lifeform);
                parentA = null;

                if (child != null)
                {
                    LIFEFORMS.Add(child);
                }
            }
        }
Ejemplo n.º 2
0
        private static bool IsQualified(Lifeform parent)
        {
            bool unqualified = parent._hp < parent.Init.HealThresholdScale ||
                               parent._food < parent.Init.FoodDrain ||
                               parent._water < parent.Init.WaterDrain;

            return(!unqualified);
        }
Ejemplo n.º 3
0
 private MoodManager(Lifeform lifeform, bool generateBias)
 {
     if (generateBias)
     {
         _urgeBias    = GenerateUrgeBias(lifeform?.Species);
         _emotionBias = GenerateEmotionBias(lifeform?.Species);
     }
 }
Ejemplo n.º 4
0
 private static void BreedAction(Lifeform parent)
 {
     parent._hp     /= 2;
     parent._energy /= 2;
     parent._food   -= parent.Init.FoodDrain;
     parent._water  -= parent.Init.WaterDrain;
     parent._breedCount++;
     parent.MM.Action(Urge.Reproduce);
 }
Ejemplo n.º 5
0
        public MoodManager(Lifeform lifeform = null) : this(lifeform, true)
        {
            Lifeform = lifeform;
            Asleep   = false;

            _urgeValues    = new int[URGE_COUNT];
            _emotionValues = new int[EMOTION_COUNT];

            Update();
        }
Ejemplo n.º 6
0
        public static Lifeform Breed(Lifeform parentA, Lifeform parentB)
        {
            if (!IsQualified(parentA) || !IsQualified(parentB))
            {
                return(null);
            }

            int[] dna = MixDNA();

            Tier[] urgeBias    = new Tier[URGE_COUNT];
            Tier[] emotionBias = new Tier[EMOTION_COUNT];

            for (int i = 0; i < URGE_COUNT; ++i)
            {
                Lifeform parent = dna[i] == 0 ? parentA : parentB;
                urgeBias[i] = parent.MM.UrgeBias[i];
            }

            for (int i = 0; i < EMOTION_COUNT; ++i)
            {
                Lifeform parent = dna[i + URGE_COUNT] == 0 ? parentA : parentB;
                emotionBias[i] = parent.MM.EmotionBias[i];
            }

            MoodManager mood  = new MoodManager(urgeBias, emotionBias);
            Lifeform    child = new Lifeform(parentA.World, parentA.Species, mood, parentA.Id, parentB.Id)
            {
                _food  = parentA.Init.FoodDrain + parentB.Init.FoodDrain,
                _water = parentA.Init.WaterDrain + parentB.Init.WaterDrain
            };

            BreedAction(parentA);
            BreedAction(parentB);

            return(child);
        }
Ejemplo n.º 7
0
 public MoodManager(Tier[] urgeBias, Tier[] emotionBias, Lifeform lifeform = null) : this(lifeform) {
     _urgeBias    = urgeBias;
     _emotionBias = emotionBias;
 }