Esempio n. 1
0
 public static void AddWeapon(string name, Weapon wep)
 {
     if (!weapons.ContainsKey(name))
         weapons.Add(name, wep);
     else
         //overwrite old object
         weapons[name] = wep;
 }
Esempio n. 2
0
 public static bool TryGetWeapon(string name, out Weapon weapon)
 {
     if (weapons.ContainsKey(name))
     {
         weapon = weapons[name];
         return true;
     }
     weapon = null;
     return false;
 }
Esempio n. 3
0
        public INIParser(Stream stream)
            : base(stream)
        {
            str = (BigStream)stream;
            //Console.WriteLine(str.Name);
            long filesize = str.Length;
            while (str.Position < filesize)
            {
                ParseLine();
                string s = getString();
                string name;
                switch (s)
                {
                    case "#include":
                        includeFile(getString());
                        break;
                    case "#define":
                        macros.Add(getString().ToUpper(), getStrings());
                        break;

                    case "Armor":
                        Armor ar = new Armor();
                        name = getString();
                        ParseObject(ar);
                        INIManager.AddArmor(name, ar);
                        break;
                    case "AmbientStream":
                        AmbientStream ast = new AmbientStream();
                        name = getString();
                        ParseObject(ast);
                        INIManager.AddAmbientStream(name, ast);
                        break;
                    case "AudioEvent":
                        AudioEvent e = new AudioEvent();
                        name = getString();
                        ParseObject(e);
                        INIManager.AddAudioEvent(name, e);
                        break;
                    case "CommandButton":
                        CommandButton cb = new CommandButton();
                        name = getString();
                        ParseObject(cb);
                        INIManager.AddCommandButton(name, cb);
                        break;
                    case "DialogEvent":
                        DialogEvent de = new DialogEvent();
                        name = getString();
                        ParseObject(de);
                        INIManager.AddDialogEvent(name, de);
                        break;
                    case "FXList":
                        FXList fl = new FXList();
                        name = getString();
                        ParseObject(fl);
                        INIManager.AddFXList(name, fl);
                        break;
                    case "GameData":
                        GameData data = new GameData();
                        ParseObject(data);
                        INIManager.SetGameData(data);
                        break;
                    case "LoadSubsystem":
                        LoadSubsystem ls = new LoadSubsystem();
                        name = getString();
                        ParseObject(ls);
                        ls.LoadFiles();
                        break;
                    case "MappedImage":
                        MappedImage mi = new MappedImage();
                        name = getString();
                        ParseObject(mi);
                        INIManager.AddMappedImage(name, mi);
                        break;
                    case "ModifierList":
                        ModifierList ml = new ModifierList();
                        name = getString();
                        ParseObject(ml);
                        INIManager.AddModifierList(name, ml);
                        break;
                    case "Multisound":
                        Multisound ms = new Multisound();
                        name = getString();
                        ParseObject(ms);
                        INIManager.AddMultisound(name, ms);
                        break;
                    case "MusicTrack":
                        MusicTrack mt = new MusicTrack();
                        name = getString();
                        ParseObject(mt);
                        INIManager.AddMusicTrack(name, mt);
                        break;
                    case "Object":
                        INI.Object o = new INI.Object();
                        name = getString();
                        ParseObject(o);
                        INIManager.AddObject(name, o);
                        break;
                    case "Science":
                        Science sc = new Science();
                        name = getString();
                        ParseObject(sc);
                        INIManager.AddScience(name, sc);
                        break;
                    case "StreamedSound":
                        StreamedSound ss = new StreamedSound();
                        name = getString();
                        ParseObject(ss);
                        INIManager.AddStreamedSound(name, ss);
                        break;
                    case "Upgrade":
                        Upgrade u = new Upgrade();
                        name = getString();
                        ParseObject(u);
                        INIManager.AddUpgrade(name, u);
                        break;
                    case "Weapon":
                        Weapon w = new Weapon();
                        name = getString();
                        ParseObject(w);
                        INIManager.AddWeapon(name, w);
                        break;
                    default:
                        if (!objects.Contains(s))
                        {
                            //PrintError("unhandled entry: " + s);
                            objects.Add(s);
                        }
                        break;
                }
            }
            count++;
        }