예제 #1
0
        //this removes a key type from the master key and generates a new item
        public BaseStoreKey RemoveKey(int index)
        {
            if (index < 0 || index >= KeyTypes.Count)
            {
                return(null);
            }

            //create new key object
            BaseStoreKey key = (BaseStoreKey)Activator.CreateInstance(KeyTypes[index]);

            key.SetStore(ItemStore.Clone(Stores[index]));

            //set up the key store to the right owner
            key.Store.Owner = key;

            key.LootType = Stores[index].LootType;
            key.Insured  = Stores[index].Insured;

            //remove the entry from the KeyTypes and Stores lists
            Stores.RemoveAt(index);
            KeyTypes.RemoveAt(index);

            return(key);
        }
예제 #2
0
        //add a specified key into the master key, if it can take it
        public bool AddKey(BaseStoreKey key)
        {
            //if this key type already exists within the master key
            if (KeyTypes.IndexOf(key.GetType()) > -1)
            {
                return(false);
            }

            ItemStore newstore = ItemStore.Clone(key.Store);

            newstore.Owner = this;

            //save the loot type for this key into the store
            newstore.LootType = key.LootType;
            newstore.Insured  = key.Insured;

            Stores.Add(newstore);
            KeyTypes.Add(key.GetType());

            //remove the keys from the world
            key.Delete();

            return(true);
        }