Beispiel #1
0
 /*
  * Loads the specified level
  */
 public void LoadLevel(ContentFactory factory, GameUnitController unit_controller, 
     ItemController item_controller, int level_num)
 {
     CurLevel = factory.loadLevel(level_num);
     item_controller.Reset();
     unit_controller.Reset();
     unit_controller.SetLevel(CurLevel);
 }
Beispiel #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            if (firstLoop) factory.LoadAllContent();
            canvas.Initialize(this);

            // Game starts at the main menu
            game_state = GameState.MAIN_MENU;

            // Initialize controllers
            input_controller = new InputController();
            collision_controller = new CollisionController();

            level_controller = new LevelController();
            unit_controller = new GameUnitController(factory);
            item_controller = new ItemController();

            // TEST
            HUD_display = factory.createHUD(unit_controller.Player);
            level_controller.NextLevel(factory, unit_controller, item_controller);
            unit_controller.SetLevel(level_controller.CurLevel);

            bool test = level_controller.CurLevel.Map.rayCastHasObstacle(
                new Vector2(0*Map.TILE_SIZE, 0*Map.TILE_SIZE), new Vector2(20*Map.TILE_SIZE, 11*Map.TILE_SIZE),
                Map.TILE_SIZE);
            System.Diagnostics.Debug.WriteLine(test);
            base.Initialize();
            firstLoop = false;
        }