void IEntity.Tick()
        {
            ISet <Point> free          = pasture.GetFreeNeighbors(this);
            Point        newgrasspoint = Reproduce(free);

            if (newgrasspoint != null)
            {
                pasture.AddEntity(new Grass(pasture, timeUntilReproduce), newgrasspoint);
            }
        }
示例#2
0
        void grow()
        {
            Random random = new Random();

            ISet <Point> neighbors = pasture.GetFreeNeighbors(this);
            int          num       = random.Next(0, neighbors.Count);
            int          count     = 0;

            foreach (Point p in neighbors)
            {
                count++;
                if (count == num)
                {
                    pasture.AddEntity(new Cow(pasture, ttl, ttm, ttr), p);
                }
            }
            curr_ttr = ttr;
        }
示例#3
0
        void grow()
        {
            Random random = new Random();

            if (this != null)
            {
                ISet <Point> neighbors = pasture.GetFreeNeighbors(this);
                int          num       = random.Next(0, neighbors.Count);
                int          count     = 0;

                foreach (Point p in neighbors)
                {
                    count++;
                    if (count == num)
                    {
                        pasture.AddEntity(new Grass(pasture), p);
                    }
                }
                curr_ttg = ttg;
            }
        }