Esempio n. 1
0
        Region CreateRegion(int top,
                            int left,
                            int width,
                            int height,
                            int index = 0)
        {
            Region region =
                new Region(top * kRectSize, left * kRectSize, width,
                           height, kRectSize);
            int i = 0;

            foreach (Rect rect in region)
            {
                Panel panel    = CreatePanel(rect.Left, rect.Top, index.ToString());
                var   position = new Position(rect.Top, rect.Left);
                positions_[position] = panel;
                planta.Controls.Add(panel);
            }

            return(region);
        }
Esempio n. 2
0
        Person CreatePerson(int speed, bool know_exists)
        {
            Person person = null;

            while (person == null)
            {
                int index = rand_.Next(0, regions_.Length);

                // Do not place persons on dummy areas
                if (index > 23)
                {
                    continue;
                }

                //int index = rand_.Next(0, 1);
                Region     region    = regions_[index];
                Location[] locations =
                    region
                    .GetEmptyLocations()
                    .ToArray();

                if (locations.Length > 0)
                {
                    index = rand_.Next(0, locations.Length - 1);
                    Location location = locations[index];
                    person = new Person(speed, location, know_exists);
                    region.PlacePerson(person, location.Index);

                    Rect  rect  = region.GetRectByIndex(location.Index);
                    Panel panel = CreatePanel(rect.Left, rect.Top, "");
                    planta.Controls.Add(panel);
                    panel.BackColor = panel.BackColor = System.Drawing.Color.Red;
                }
            }

            return(person);
        }