コード例 #1
0
        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;
            }
        }