예제 #1
0
        public void initializeGame(string level)
        {
            loadPercentage = 0;
            if (!loadedGameContent)
            {
                TextureManager.initialize(this);
                loadPercentage = 0.1f;
                ModelLibrary.initialize(this);
                loadPercentage = 0.2f;
                loadPercentage = 0.25f;
                loadedGameContent = true;
            }

            modelManager = new ModelManager(this);
            ship = new Ship(this);
            core = new BaseCore(this);
            camera = new Camera(this, new Vector3(40, 150, 10), Vector3.Zero, Vector3.Up);
            turretManager = new TurretManager(this);
            asteroidManager = new AsteroidManager(this);
            enemyManager = new EnemyManager(this);
            waveManager = new WaveManager(this);
            hud = new Hud(this, Content.Load<SpriteFont>(@"Hud/Venera40"), spriteBatch, GraphicsDevice);

            minigame = new Minigame(this);
            levelStats = new StatTracker();
            loadPercentage = 0.65f;

            levelFileName = "dends";
            //levelFileName = "map1-revis";
            //levelFileName = "pac-man";
            layout = new MapData(level);
            //layout = new MapData(@"Content/MapXml/Level2.xml");
            //layout = new MapData(@"Content/MapXml/pac-man.xml");
            //layout = new MapData(@"Content/MapXml/broktes.xml");

            map = new Map(this, layout.getNodes());

            bloom = new BloomComponent(this);

            Components.Add(ship);
            Components.Add(camera);
            Components.Add(modelManager);
            Components.Add(enemyManager);
            Components.Add(waveManager);
            Components.Add(core);
            Components.Add(turretManager);
            Components.Add(asteroidManager);
            Components.Add(minigame);

            //make sure the post process effects go second last, and the hud is absolute last
            //Components.Add(bloom);
            Components.Add(hud);

            loadPercentage = 1f;

            modelManager.makeStarField();
            turretManager.Initialize();

            //Debugging stuff for A*
            shortestPath = new Pathfinder(map);
            turretAvoid = new PathfinderTurretAvoid(map);

            System.Diagnostics.Debug.WriteLine("A new map has been loaded, our pathfinding algorithm is now finding the shortest path from each enemy spawn to the core");
            List<Vector2> spawns = map.getEnemySpawn();
            System.Diagnostics.Debug.WriteLine("There are " + spawns.Count() + " enemy spawn point(s) in this map");
            int count = 1;
            foreach(Vector2 spawn in spawns)
            {
                List<Vector2> path = shortestPath.findPath(new Point((int)spawn.X, (int)spawn.Y), new Point((int)map.getCoreLocation().X, (int)map.getCoreLocation().Y));
                System.Diagnostics.Debug.WriteLine("The path from spawn " + count + " is as follows:");
                foreach(Vector2 nodePos in path)
                {
                    System.Diagnostics.Debug.WriteLine(nodePos);
                }
                count++;
            }

            justLoadedContent = true;
        }