Example #1
0
 public override bool Attack(Creature c)
 {
     if (State == CreatureState.Adult && c.GetType() == typeof(Creature) && c.IsAlive())
     {
         return(true);
     }
     return(base.Attack(c));
 }
Example #2
0
 protected override void ProximityCheck(Creature creature, double distance)
 {
     base.ProximityCheck(creature, distance);
     if (State == CreatureState.Adult && creature.GetType() == typeof(Creature) && distance < creature.PrivacyDist * 0.7)
     {
         creature.Kill();
     }
 }
Example #3
0
 protected virtual void ProximityCheck(Creature c, double distance)
 {
     if (distance < PrivacyDist)
     {
         if (Gender == Gender.Female && IsReproductive() &&
             c.Gender == Gender.Male && c.IsReproductive() &&
             !IsInFamily(c) &&
             GetType() == c.GetType())
         {
             ReproduceAction(this, c);
             LastBabyTime       = Age;
             IncubationDuration = 2;
         }
     }
 }
Example #4
0
        private void reproduceAction(Creature mother, Creature father)
        {
            Creature c;

            if (mother.GetType() == typeof(Creature))
            {
                c = new Creature(mother.Position, mother, father);
            }
            else
            {
                c = new Predator(mother.Position, mother, father);
            }
            c.ReproduceAction = reproduceAction;

            newCreatures.Add(c);
            view1.Children.Add(c);
        }
Example #5
0
        protected virtual double GetAttraction(Creature c)
        {
            // Children stay close to their mother
            if (c == Mother && IsChild() && !Mother.IsDead())
                return 6;

            // Brothers and sisters are close when they are children
            if (Mother != null && Mother == c.Mother && IsChild())
                return 4;

            // They are really scared of predators
            if (GetType() == typeof(Creature) && c.GetType() == typeof(Predator))
                return -10;

            // Children play together
            if (State == CreatureState.Child && c.IsChild())
                return 2;

            // They are not interested in the dead
            if (c.State == CreatureState.Dead)
                return -1;

            // Males are really attracted to reproductive females
            if (Gender == Gender.Male && IsReproductive() && c.Gender == Gender.Female && c.IsReproductive())
                return 8;

            // Scared of other types
            if (GetType() != c.GetType())
            {
                return -5;
            }

            if (Gender == Gender.Female)
            {
                if (c.Gender == Gender.Male)
                    return 2;
                else
                    return 2;
            }
            else
            {
                if (c.Gender == Gender.Male)
                    return -4;
                else
                    if (Loves(c))
                        return 4 * c.Fitness;
            }
            return 0;
        }
Example #6
0
 protected virtual void ProximityCheck(Creature c, double distance)
 {
     if (distance < PrivacyDist)
     {
         if (Gender == Gender.Female && IsReproductive()
                 && c.Gender == Gender.Male && c.IsReproductive()
                 && !IsInFamily(c)
                 && GetType() == c.GetType())
         {
             ReproduceAction(this, c);
             LastBabyTime = Age;
             IncubationDuration = 2;
         }
     }
 }
Example #7
0
 public override bool Attack(Creature c)
 {
     if (State == CreatureState.Adult && c.GetType() == typeof(Creature) && c.IsAlive())
         return true;
     return base.Attack(c);
 }
Example #8
0
 protected override void ProximityCheck(Creature creature, double distance)
 {
     base.ProximityCheck(creature, distance);
     if (State == CreatureState.Adult && creature.GetType() == typeof(Creature) && distance < creature.PrivacyDist * 0.7)
         creature.Kill();
 }
Example #9
0
        protected virtual double GetAttraction(Creature c)
        {
            // Children stay close to their mother
            if (c == Mother && IsChild() && !Mother.IsDead())
            {
                return(6);
            }

            // Brothers and sisters are close when they are children
            if (Mother != null && Mother == c.Mother && IsChild())
            {
                return(4);
            }

            // They are really scared of predators
            if (GetType() == typeof(Creature) && c.GetType() == typeof(Predator))
            {
                return(-10);
            }

            // Children play together
            if (State == CreatureState.Child && c.IsChild())
            {
                return(2);
            }

            // They are not interested in the dead
            if (c.State == CreatureState.Dead)
            {
                return(-1);
            }

            // Males are really attracted to reproductive females
            if (Gender == Gender.Male && IsReproductive() && c.Gender == Gender.Female && c.IsReproductive())
            {
                return(8);
            }

            // Scared of other types
            if (GetType() != c.GetType())
            {
                return(-5);
            }

            if (Gender == Gender.Female)
            {
                if (c.Gender == Gender.Male)
                {
                    return(2);
                }
                else
                {
                    return(2);
                }
            }
            else
            {
                if (c.Gender == Gender.Male)
                {
                    return(-4);
                }
                else
                if (Loves(c))
                {
                    return(4 * c.Fitness);
                }
            }
            return(0);
        }
        private void reproduceAction(Creature mother, Creature father)
        {
            Creature c;
            if (mother.GetType() == typeof(Creature))
                c = new Creature(mother.Position, mother, father);
            else
                c = new Predator(mother.Position, mother, father);
            c.ReproduceAction = reproduceAction;

            newCreatures.Add(c);
            view1.Children.Add(c);
        }