//If the dictionary contains a type of resource, this will instantiate a resource if the count is larger than 0.
 //It will reduce the count an remove the typeOfResource.
 public void UseResource(Keycards typeOfResource, Vector3 position)
 {
     if (this.Keys.ContainsKey(typeOfResource))
     {
         if (this.Keys [typeOfResource].count > 0)
         {
             Instantiate(this.Keys [typeOfResource].prefab, position, Quaternion.identity);
             Keychain ru = this.Keys [typeOfResource];
             ru.count--;
             this.Keys [typeOfResource] = ru;
             if (this.Keys [typeOfResource].count == 0)
             {
                 this.Keys.Remove(typeOfResource);
             }
         }
     }
 }
Exemple #2
0
 // Use this for initialization
 void Start()
 {
     Keycards.Add(new KeyCard(keyColour));
 }