Example #1
0
        private void startClick(object sender, RoutedEventArgs e)
        {
            const int MAPSIZEX = 10;
            const int MAPSIZEY = 10;

            FieldObject[,] map = new FieldObject[MAPSIZEX, MAPSIZEY];
            Vector vector;

            int streetFieldAmount = MAPSIZEX * MAPSIZEY / 5;             //amount of streefields

            //create position of the firestation
            Random rnd = new Random();
            int    x   = rnd.Next(0, MAPSIZEX);
            int    y   = rnd.Next(0, MAPSIZEY);

            vector = new Vector(x, y);

            Firestation fireStation = new Firestation(map, vector);

            map[x, y]       = fireStation;
            fireStation.map = map;

            //first streetposition
            vector = fireStation.getNextField();
            Street street = new Street(map, vector);

            map [vector.getPositonX, vector.getPositonY] = street;

            for (int i = 0; i < streetFieldAmount - 1; i++)
            {
                vector = street.getNextField();
                street = new Street(map, vector);
                map [vector.getPositonX, vector.getPositonY] = street;
                street.map = map;
            }
            //forechschleife----------


            // river hinzufügen

            //river -------------


            //Tree hinzufügen

            //Tree --------------


            //Ausgeben map

            CreateMap.Print(CanvasMap);

            //ausgeben map ---------
        }
Example #2
0
        private void createNewCityClick(object sender, RoutedEventArgs e)
        {
            Vector tmpPosition;
            Vector firestationPos;
            int    streetFieldAmount = (int)MAPSIZEX * MAPSIZEY / 4; //amount of streetfields

            this.map = new FieldObject[MAPSIZEX, MAPSIZEY];
            createRiver();

            //create firestation position
            Random rnd = new Random();
            int    x   = rnd.Next(0, MAPSIZEX);
            int    y   = rnd.Next(0, MAPSIZEY);

            this.currentPosition = new Vector(x, y);
            firestationPos       = this.currentPosition;

            this.map[x, y] = new Firestation(currentPosition);

            for (int i = 0; i < streetFieldAmount - 1; i++)
            {
                tmpPosition = getNextField();

                if (tmpPosition == null)
                {
                    this.currentPosition = firestationPos;
                }
                else
                {
                    this.currentPosition = tmpPosition;
                }
                if (i == streetFieldAmount / 2)
                {
                    this.currentPosition = firestationPos;
                }
            }

            for (int i = 0; i < map.GetLength(0); i++)
            {
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    if (map[i, j] == null)
                    {
                        map[i, j] = new Tree(new Vector(i, j), false);
                    }
                }
            }

            CreateMap.Print(canvasMap, map);
        }