private static Launcher LoadLauncher(XmlElement node, ContentManager Content) { Vector2 position = new Vector2(); position.X = Convert.ToInt16(node.Attributes["x"].Value); position.Y = Convert.ToInt16(node.Attributes["y"].Value); Texture2D[] launcherTextures = {Content.Load<Texture2D>("Texture/launcher"), Content.Load<Texture2D>("Texture/LauncherBase"), Content.Load<Texture2D>("Texture/power_meter")}; Launcher launcher = new Launcher(launcherTextures, position); return launcher; }
//public EditableLevel(ContentManager content) { // _platforms = new List<Platform>(); // _treasures = new List<Treasure>(); // _deathTraps = new List<DeathTrap>(); // _moveablePlatforms = new List<Platform>(); // _attempts = 4; // _parTime = 1; // _additionsAllowed = 30; // typesAllowed = "RBHV"; // _ballTex = content.Load<Texture2D>("Texture/ball"); // Background = content.Load<Texture2D>("Texture/GameScreen"); // _custom = true; //} /// <summary> /// Constructs a EditableLevel object. /// </summary> /// <param name="level">The Level to use to create the simulation.</param> /// <param name="content">The ContentManager to use to load the ball texture.</param> public EditableLevel(Level level, ContentManager content) { // TODO: This clones the list, but references the same platforms. // If gameplay may modify properties of platforms (or the goal, // or the launcher), a deep copy is necessary instead. _platforms = new List<Platform>(level.Platforms); _treasures = new List<Treasure>(level.Treasures); _deathTraps = new List<DeathTrap>(level.DeathTraps); _goal = level.Goal; _launcher = level.Launcher; _moveablePlatforms = new List<Platform>(); Name = level.Name; _attempts = level.Attempts; _parTime = level.ParTime; //hard coded amount of additions. _additionsAllowed = 3; Background = content.Load<Texture2D>("Texture/GameScreen"); typesAllowed = level.AllowedPlatTypes; // Load the ball's texture and store it. _ballTex = content.Load<Texture2D>("Texture/ball"); _custom = false; // Allow the user to interact with the simulation, and start the timer. // _currentState = SimulationState.Active; }
/// <summary> /// Constructs a Simulation object. /// </summary> /// <param name="level">The Level to use to create the simulation.</param> /// <param name="content">The ContentManager to use to load the ball texture.</param> public Simulation(Level level, ContentManager content) { // TODO: This clones the list, but references the same platforms. // If gameplay may modify properties of platforms (or the goal, // or the launcher), a deep copy is necessary instead. _platforms = new List<Platform>(level.Platforms); _treasures = new List<Treasure>(level.Treasures); _deathTraps = new List<DeathTrap>(level.DeathTraps); _goal = level.Goal; _launcher = level.Launcher; _moveablePlatforms = new List<Platform>(); _name = level.Name; // Initialize various stats. _startingAttempts = level.Attempts; _parTime = level.ParTime; _attemptsLeft = _startingAttempts; _collectedTreasures = 0; _bounces = 0; //hard coded amount of additions. _additionsAllowed = 3; Background = content.Load<Texture2D>("Texture/GameScreen"); // Load the ball's texture and store it. _ballTex = content.Load<Texture2D>("Texture/ball"); // Create the physics simulation. //InitWorld(); // Allow the user to interact with the simulation, and start the timer. _currentState = SimulationState.Active; _elapsedTime = 0f; }
/// <summary> /// Creates a launcher with a valid position. /// </summary> private void OkayInput() { Launcher launcher = new Launcher(null, new Vector2(200, 300)); }
/// <summary> /// Creates a launcher and passes in bad coordinates for its position. /// </summary> private void GarbageInput() { Launcher launcher = new Launcher(null, new Vector2(-1491471, -2523953)); }
/* Put more tests here */ /// <summary> /// Creates and returns a launcher. /// </summary> /// <param name="createBall">Whether a ball should be loaded in the launcher.</param> /// <returns>A Launcher object.</returns> private Launcher CreateLauncher(bool createBall) { // Create the launcher. // We don't need a texture for unit tests, so pass in null for the texture parameters. Launcher launcher = new Launcher(null, new Vector2(0, 0)); if (createBall) { // Give the launcher a ball; otherwise, it won't move. Ball ball = new Ball(null); launcher.LoadBall(ball); } return launcher; }