Example #1
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 #2
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);
        }