Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

BulletBuilder

By: Kaltinril on Apr 12th, 2012  |  syntax: C#  |  size: 1.38 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using XML_Data_Loader;
  6. using Microsoft.Xna.Framework.Content;
  7.  
  8. namespace TopFalling3
  9. {
  10.     class BulletBuilder
  11.     {
  12.         Dictionary<string, Bullet> bulletList = new Dictionary<string, Bullet>();
  13.  
  14.         //ContentManager contentManager;
  15.  
  16.         public BulletBuilder()//ContentManager contentIn)
  17.         {
  18.             //contentManager = contentIn;
  19.         }
  20.  
  21.         public void LoadBullet(ContentManager contentManager, string BulletXMLFilename)
  22.         {
  23.             BulletData bd = new BulletData();
  24.             bd = contentManager.Load<BulletData>(BulletXMLFilename);
  25.  
  26.             Bullet b = new Bullet();
  27.  
  28.             b.LoadBulletData(bd);
  29.             b.LoadContent(contentManager, bd.textureName);
  30.  
  31.             string key = BulletXMLFilename.Substring(BulletXMLFilename.LastIndexOf("/")+1);
  32.  
  33.             bulletList.Add(key,b);
  34.         }
  35.  
  36.         public Bullet Peak(string BulletName)
  37.         {
  38.             return bulletList[BulletName];
  39.         }
  40.  
  41.         public Bullet CreateBullet(string BulletName)
  42.         {
  43.             if (bulletList.ContainsKey(BulletName))
  44.             {
  45.  
  46.                 Bullet b = (Bullet)bulletList[BulletName].ShallowCopy();
  47.                 b.Initialize();
  48.                 return b;
  49.             }
  50.  
  51.             return null;
  52.         }
  53.     }
  54. }
clone this paste RAW Paste Data