private static DeathTrap LoadDeathTrap(XmlElement node, ContentManager Content) { Vector2 position = new Vector2(); position.X = Convert.ToInt16(node.Attributes["x"].Value); position.Y = Convert.ToInt16(node.Attributes["y"].Value); DeathTrap deathtrap = new DeathTrap(Content.Load<Texture2D>("Texture/deathtrap"), position); return deathtrap; }
/// <summary> /// Determines if a mouse click intersects with a rectangle. /// </summary> /// <returns></returns> private Boolean Intersects(DeathTrap dt, Point ms) { if(Vector2.Distance(dt.Center, new Vector2(ms.X, ms.Y)) < Vector2.Distance( dt.Center, dt.Center+new Vector2(0, dt.Width/2))){ return true; } return false; }
/// <summary> /// Loads graphics content for this screen. This uses the shared ContentManager /// provided by the Game class, so the content will remain loaded forever. /// Whenever a subsequent MessageBoxScreen tries to load this same content, /// it will just get back another reference to the already loaded data. /// </summary> public override void LoadContent(ContentManager shared) { base.LoadContent(shared); _gradientTexture = shared.Load<Texture2D>("Texture/gradient"); _font = shared.Load<SpriteFont>("Font/menufont"); // Create the dictionaries and cache all the textures needed to draw each // platform in the toolbox. platformTextures = new Dictionary<Vector2, Texture2D>(); breakablePlatformTextures = new Dictionary<Vector2, Texture2D>(); foreach (Vector2 size in Platform.NormalPlatNames.Keys) { platformTextures.Add(size, shared.Load<Texture2D>(Platform.NormalPlatNames[size])); } foreach (Vector2 size in Platform.BreakablePlatNames.Keys) { breakablePlatformTextures.Add(size, shared.Load<Texture2D>(Platform.BreakablePlatNames[size])); } if (editableLevel.Custom) { deathTrap = new DeathTrap(shared.Load<Texture2D>("Texture/deathtrap"), new Vector2(200, 400)); treasure = new Treasure(shared.Load<Texture2D>("Texture/treasure"), new Vector2(300, 400)); } }