public void GetItemFromCaravan(SpiceName name, int value) { int curValue = caravan.GetItemValue(name); if (curValue >= value && capacity >= value) { for (int i = 0; i < value; i++) { PutItem(name); } for (int i = 0; i < value; i++) { caravan.RemoveItemByOne(name); } } }
public List <KeyValuePair <string, object> > GetWorldState() { worldData = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("Capacity", inventory.capacity), new KeyValuePair <string, object>("InTu", inventory.GetItemValue(SpiceName.Tu)), new KeyValuePair <string, object>("InSa", inventory.GetItemValue(SpiceName.Sa)), new KeyValuePair <string, object>("InCa", inventory.GetItemValue(SpiceName.Ca)), new KeyValuePair <string, object>("InCi", inventory.GetItemValue(SpiceName.Ci)), new KeyValuePair <string, object>("InCl", inventory.GetItemValue(SpiceName.Cl)), new KeyValuePair <string, object>("InPe", inventory.GetItemValue(SpiceName.Pe)), new KeyValuePair <string, object>("InSu", inventory.GetItemValue(SpiceName.Su)), new KeyValuePair <string, object>("CaTu", caravan.GetItemValue(SpiceName.Tu)), new KeyValuePair <string, object>("CaSa", caravan.GetItemValue(SpiceName.Sa)), new KeyValuePair <string, object>("CaCa", caravan.GetItemValue(SpiceName.Ca)), new KeyValuePair <string, object>("CaCi", caravan.GetItemValue(SpiceName.Ci)), new KeyValuePair <string, object>("CaCl", caravan.GetItemValue(SpiceName.Cl)), new KeyValuePair <string, object>("CaPe", caravan.GetItemValue(SpiceName.Pe)), new KeyValuePair <string, object>("CaSu", caravan.GetItemValue(SpiceName.Su)) }; return(worldData); }
private bool StealRandomItemFromCar() { List <KeyValuePair <SpiceName, int> > values = new List <KeyValuePair <SpiceName, int> > { new KeyValuePair <SpiceName, int>(SpiceName.Tu, caravan.GetItemValue(SpiceName.Tu)), new KeyValuePair <SpiceName, int>(SpiceName.Sa, caravan.GetItemValue(SpiceName.Sa)), new KeyValuePair <SpiceName, int>(SpiceName.Ca, caravan.GetItemValue(SpiceName.Ca)), new KeyValuePair <SpiceName, int>(SpiceName.Ci, caravan.GetItemValue(SpiceName.Ci)), new KeyValuePair <SpiceName, int>(SpiceName.Cl, caravan.GetItemValue(SpiceName.Cl)), new KeyValuePair <SpiceName, int>(SpiceName.Pe, caravan.GetItemValue(SpiceName.Pe)), new KeyValuePair <SpiceName, int>(SpiceName.Su, caravan.GetItemValue(SpiceName.Su)) }; values.RemoveAll(e => (int)e.Value <= 0); if (values.Count != 0) { int remove = Random.Range(0, values.Count); caravan.RemoveItemByOne(values[remove].Key); stealCount++; StealCount.text = stealCount.ToString(); } return(true); }