示例#1
0
        public Map GenerateRandomMap(int width, int height, MapParser.SpecialMapElement specialMapElement)
        {
            //Map deklarieren
            Map returnvalue = null;
            //Zugehöriges Grid erzeugen:
            Grid tempGrid = new Grid();

            tileCountX = width;
            tileCountY = height;

            theSpecialMapElement = specialMapElement;
            if (theSpecialMapElement == MapParser.SpecialMapElement.CentralPark)
            {
                theCentralParkCreator = new CentralParkCreator(tileCountX, tileCountY);
                ParkGridElementPossibilitiesList = GetListFromXML(@"ParkElementList.xml");
            }

            else if (theSpecialMapElement == MapParser.SpecialMapElement.RiverCrossing)
            {
                theRiverCrossingCreator = new RiverCrossingCreator(tileCountX, tileCountY);
            }

            //Die Elementliste aus der Xml "ElementList.xml" ziehen:
            GridElementPossibilitiesList = GetListFromXML(@"ElementList.xml");

            //Im Folgenden das Grid in der in den Parametern zugewiesenen Dimension als Jagged Array erzeugen.
            tempGrid.GridElementCollection = new GridElement[height][];

            for (int i = 0; i < height; i++)
            {
                tempGrid.GridElementCollection[i] = new GridElement[width];
            }

            tileWidth = width;
            tileHeight = height;
            SetMapProperties(width, height);
            tempGrid = SetMapBoundaries(width, height);
            SetTileIds(tempGrid.GridElementCollection);
            returnvalue = new Map(tempGrid);

            return returnvalue;
        }
示例#2
0
        private Grid SetMapBoundaries(int width, int height)
        {
            Grid grid = null;
            grid = new Grid();

            grid.Height = 500;
            grid.Width = 500;

            //For Schleife neu strukturieren
            grid.GridElementCollection = new GridElement[width][];
            for (var i = 0; i < grid.GridElementCollection.Length; i++)
            {
                grid.GridElementCollection[i] = new GridElement[width];

                //Initialisierung iterieren:
                for (int j = 0; j < grid.GridElementCollection[i].Length; j++)
                {
                    //Console.WriteLine("{0} / {1}", i, j);
                    grid.GridElementCollection[i][j] = new GridElement();
                    grid.GridElementCollection[i][j].ImageId = "n/a";
                    grid.GridElementCollection[i][j].PassableSides = 0;
                    grid.GridElementCollection[i][j].RandomPlacableSides = 0;
                }
            }

            return grid;
        }
示例#3
0
 internal CollisionManager(Grid mapGrid, int gridElementWidth, int gridElementHeight)
 {
     grid = mapGrid;
     elementWidth = gridElementWidth;
     elementHeight = gridElementHeight;
 }
示例#4
0
文件: Map.cs 项目: ddg-igh/crazy-taxi
        //Hält die Steuerelemente auf diesem UserControl
        //private PictureBox[][] elementBoxes = null;
        internal Map(Grid mapGrid)
        {
            InitializeComponent();

            MapGrid = mapGrid;
        }
示例#5
0
        //Hält die Steuerelemente auf diesem UserControl
        //private PictureBox[][] elementBoxes = null;

        internal Map(Grid mapGrid)
        {
            InitializeComponent();

            MapGrid = mapGrid;
        }
示例#6
0
        public Map GenerateRandomMap(int width, int height)
        {
            //Map deklarieren
            Map returnvalue = null;
            //Zugehöriges erzeugen:
            Grid tempGrid = new Grid();

            //Die Elementliste aus der Xml "ElementList.xml" ziehen:
            GridElementPossibilitiesList = GetListFromXML();

            //Im Folgenden das Grid in der in den Parametern zugewiesenen Dimension als Jagged Array erzeugen.
            tempGrid.GridElementCollection = new GridElement[height][];

            for (int i = 0; i < height; i++)
            {
                tempGrid.GridElementCollection[i] = new GridElement[width];
            }

            tileWidth = width;
            tileHeight = height;

            SetMapProperties(width, height);
            tempGrid = SetMapBoundaries(width, height);

            SetTileIds(tempGrid.GridElementCollection);

            returnvalue = new Map(tempGrid);

            return returnvalue;
        }