/// <summary> /// Uses a consumable /// </summary> /// <param name="item">consumable to use</param> public void UseConsumable(InventoryItem item) { if (!playerItems.Contains(item) || !(item is ConsumableItem)) { return; } ConsumableItem i = item as ConsumableItem; switch (i.Type) { case ConsumableType.RADAR: if (consumableDuration > 0) { return; //can only have one consumable with a duration active at once } Gameplay.VoxelGrid.Instance.AdjustTransparency(i.Strength); consumableDuration = i.Duration; activeConsumable = i; break; case ConsumableType.REPAIR: RockManager.Instance.AdjustRockIntegrityPercentage(i.Strength); break; } RemoveItem(item, InventoryType.PLAYER); }
public ConsumableItem GetConsumableData() { ConsumableItem i = ScriptableObject.CreateInstance <ConsumableItem>(); i.SetValues(itemName, itemText, value, spriteName, consumableType, strength, duration); return(i); }
public SaveItem(InventoryItem item) { if (item is ToolItem) { type = ItemType.TOOL; } else if (item is MineralItem) { type = ItemType.MINERAL; } else if (item is ConsumableItem) { type = ItemType.CONSUMABLE; } else { type = ItemType.OTHER; } itemName = item.ItemName; itemText = item.ItemText; value = item.Value; spriteName = item.SpriteName; switch (type) { case ItemType.TOOL: ToolItem t = item as ToolItem; toolType = t.Type; inputType = t.InputType; power = t.Power; precision = t.Precision; sustainedBreakCooldown = t.SustainedBreakCooldown; breakRadius = t.BreakRadius; break; case ItemType.MINERAL: MineralItem m = item as MineralItem; modelName = m.ModelName; colorR = m.Color.r; colorG = m.Color.g; colorB = m.Color.b; break; case ItemType.CONSUMABLE: ConsumableItem c = item as ConsumableItem; consumableType = c.Type; strength = c.Strength; duration = c.Duration; break; } }
/// <summary> /// Ends the effects of the current consumable item /// </summary> public void EndConsumable() { consumableDuration = 0; switch (activeConsumable.Type) { case ConsumableType.RADAR: //makes rock opaque when radar is over Gameplay.VoxelGrid.Instance.AdjustTransparency(); break; } activeConsumable = null; }
private List <Reservation> Reservation_Rows_To_List(IList <DataRow> res_rows) { var ress = new List <Reservation>(); var res_to_cons_item = this.DataBase.Relations["Reservation-ConsumableItem"]; var cons_attr_to_cons_item = this.DataBase.Relations["ConsumableAttr-ConsumableItem"]; var prod_to_cons_attr = this.DataBase.Relations["Product-ConsumableAttr"]; var room_attr_to_res = this.DataBase.Relations["RoomAttr-Reservation"]; var prod_to_room_attr = this.DataBase.Relations["Product-RoomAttr"]; for (int i = 0;; i += 1) { if (i >= res_rows.Count) { break; } DataRow res_row = res_rows[i]; Reservation res = new Reservation(res_row); DataRow[] cons_item_rows = res_row.GetChildRows(res_to_cons_item); DataRow room_attr_row = res_row.GetParentRow(room_attr_to_res); DataRow room_prod_row = room_attr_row.GetParentRow(prod_to_room_attr); res.Room = new Room(room_prod_row, room_attr_row); List <ConsumableItem> cons_items = new List <ConsumableItem>(); for (int j = 0;; j += 1) { if (j >= cons_item_rows.Length) { break; } var cons_item_row = cons_item_rows[j]; var cons_item = new ConsumableItem(cons_item_row); var cons_prod_row = cons_item_row .GetParentRow(cons_attr_to_cons_item) .GetParentRow(prod_to_cons_attr); cons_item.Consumable = new Consumable(cons_prod_row); cons_items.Add(cons_item); } res.ConsumableItems = cons_items; ress.Add(res); } return(ress); }