public static void CreateWeapon(Unit unit, ContentManager content) { if (unit.UnitType == Hero.TYPE_WARRIOR) { Sword s = new Sword (); // Load the sword resources Animation swordAnimation = new Animation(); Texture2D swordTexture = content.Load<Texture2D>("swords_1"); swordAnimation.Initialize(swordTexture, Vector2.Zero, 64, 48, 4, 30, Color.White, 1.0f, true); s.Initialize (swordAnimation, unit.Position); unit.meleeWeapon = s; } else if (unit.UnitType == Hero.TYPE_ARCHER) { Bow b = new Bow (); unit.rangedWeapon = b; } }
protected override void LoadContent() { // Create a new SpriteBatch, which can be use to draw textures. spriteBatch = new SpriteBatch (graphics.GraphicsDevice); // Camera loading Vector2 viewPort = new Vector2 (graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); camera2d.Initialize (viewPort); camera2d.Zoom = 1.0f; // Tiles loading Tile.TileSetTexture = Content.Load<Texture2D>("part2_tileset"); tileMap = new TileMap (viewPort); // CrossHair Loading crossHair.Texture = Content.Load<Texture2D>("crosshair"); // Load the player resources Animation playerAnimation = new Animation(); Texture2D playerTexture = Content.Load<Texture2D>("concept1"); playerAnimation.Initialize(playerTexture, Vector2.Zero, 64, 64, 4, 30, Color.White, 1.0f, true); // Player loading Vector2 playerPosition = new Vector2 (0,0); archer.Initialize(playerAnimation, playerPosition); WeaponFactory.CreateWeapon (archer, Content); // Camera startup camera2d.Position = archer.Position; soldier.Initialize (graphics.GraphicsDevice); // Other tileMap.LoadFile (); WeaponFactory.LoadTextures (Content); }