Пример #1
0
        public Mission(Point start,Point end, CarImpl car, int gameFieldHeight, int gameFieldWidth, int level)
        {
            this.start = start;
            this.end = end;
            this.playerCar = car;
            this.gameFieldHeight = gameFieldHeight;
            this.gameFieldWidth = gameFieldWidth;
            Finished = false;
            Failed = false;
            this.level = level;

            this.time=calculateTime();
        }
Пример #2
0
        private void loadMap()
        {
            DateTime start;
            gameSize = new Size(size.Width * 10, size.Height * 10);
            //Bilderordner angebe
            MapParser.ImagePath = string.Format(@"{0}{1}MapImages", Directory.GetCurrentDirectory(), Path.DirectorySeparatorChar);
            start = DateTime.Now;

            Random rnd = new Random();
            int random = rnd.Next(0, 3);
            switch (random)
            {
                case 0:
                    map = MapParser.Load(100, 100, MapParser.SpecialMapElement.RiverCrossing);
                    break;
                case 1:
                    map = MapParser.Load(100, 100, MapParser.SpecialMapElement.None);
                    break;
                case 2:
                    map = MapParser.Load(100, 100, MapParser.SpecialMapElement.CentralPark);
                    break;
            }

            Console.WriteLine("MapParser.Load:" + (System.DateTime.Now - start).ToString());
            //Karte vergrößert sich automatisch mit GUI
            //Karte im GUI anzeigen
            start = DateTime.Now;
            map.Initialize(gameSize);
            Console.WriteLine("MapParser.init:" + (System.DateTime.Now - start).ToString());
            //Karte an Größe des GUIs anpassen
            start = DateTime.Now;
            miniMap = map.DrawImage(size);
            Console.WriteLine("MapParser.draw:" + (System.DateTime.Now - start).ToString());

            int entityHeight = size.Height / 39;
            int entityWidth = size.Width / 120;
            Size entitySize = new Size(entityWidth, entityHeight);
            Size carSize = new Size(entityHeight, entityWidth);
            entity = map.Collision.AddEntity(entitySize);
            car = new CarImpl(size, gameSize, entity, carSize);
            car.Location = map.GetRandomTilePosition(true, gameSize);

            loaded = true;
        }