Beispiel #1
0
        public override void BuildItemDropWalls()
        {
            Random r    = new Random();
            int    rand = 0;

            var       wallFactory     = new WallFactory();
            ItemArray itemsRepository = new  ItemArray();
            var       iter            = itemsRepository.GetIterator();

            for (int i = 0; i < Map.Objects.GetLength(0); i++)
            {
                for (int j = 0; j < Map.Objects.GetLength(0); j++)
                {
                    rand = r.Next(0, 10);

                    if (j == 0 || j == (Map.Objects.GetLength(0) - 1) || i == 0 || i == (Map.Objects.GetLength(0) - 1))
                    {
                        continue;
                    }
                    else
                    {
                        if (i % 2 == 0 && j % 2 == 0)
                        {
                            continue;
                        }

                        else
                        {
                            if (((i == 1 && (j == 1 || j == 2)) || (i == 2 && j == 1) ||
                                 (i == (Map.Objects.GetLength(0) - 1) - 2 && j == (Map.Objects.GetLength(0) - 1) - 1) || (i == (Map.Objects.GetLength(0) - 1) - 1 && (j == (Map.Objects.GetLength(0) - 1) - 1 || j == (Map.Objects.GetLength(0) - 1) - 2))))
                            {
                                //empty path
                                continue;
                            }
                            else if (rand >= 9)
                            {
                                Map.Objects[i][j].entity = wallFactory.CreateWall(3);

                                iter.HasNext();
                                Map.Objects[i][j].item = iter.Next(j, numSquaresY);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void AddNewItem()
        {
            int    x = 0, y = 0;
            Random r = new Random();

            while (!(Map.Objects[x][y].entity == null))
            {
                x = r.Next(0, numSquaresX);
                y = r.Next(0, numSquaresY);
            }

            var       wallFactory     = new WallFactory();
            ItemArray itemsRepository = new ItemArray();
            var       iter            = itemsRepository.GetIterator();

            Map.Objects[x][y].entity = wallFactory.CreateWall(3);

            iter.HasNext();
            Map.Objects[x][y].item = iter.Next(y, numSquaresY);
        }