private void Convert(ShipItem shipContainer, Dictionary <ulong, ItemBase> items) { if (items != null && items.Count != 0) { foreach (var item in items) { ShipItem shipItem = new ShipItem(); shipItem.SetUID(item.Value.UID); shipItem.SetTID(item.Value.TID); shipItem.SetReference(item.Value.Reference); shipItem.SetBaseConfig(item.Value.ItemConfig); switch (item.Value.MainType) { case Category.Package: shipItem.SetCurrentSizeMax((item.Value as ItemContainer).CurrentSizeMax); shipContainer.AddContainer((item.Value as ItemContainer).ContainerType, shipItem); Convert(shipItem, (item.Value as ItemContainer).Items); break; case Category.Weapon: shipItem.SetLv((item.Value as ItemWeaponVO).Lv); shipItem.SetItemPos(item.Value.Position); shipContainer.AddItem(shipItem); Convert(shipItem, (item.Value as ItemContainer).Items); break; case Category.EquipmentMod: shipItem.SetLv((item.Value as ItemModVO).Lv); shipItem.SetItemPos(item.Value.Position); shipContainer.AddItem(shipItem); break; case Category.Equipment: shipItem.SetLv((item.Value as ItemEquipmentVO).Lv); shipItem.SetItemPos(item.Value.Position); shipContainer.AddItem(shipItem); break; case Category.Reformer: shipItem.SetLv((item.Value as ItemReformerVO).Lv); shipContainer.AddItem(shipItem); break; default: shipContainer.AddItem(shipItem); break; } if (m_AllItem.ContainsKey(shipItem.GetUID())) { m_AllItem.Remove(shipItem.GetUID()); } m_AllItem.Add(shipItem.GetUID(), shipItem); } } }
public void AddItem(ItemContainer item) { ShipItem shipItem = new ShipItem(); shipItem.SetUID(item.UID); shipItem.SetTID(item.TID); shipItem.SetReference(item.Reference); switch (item) { case ItemWeaponVO val: shipItem.SetLv(val.Lv); shipItem.SetItemPos(val.Position); m_AllItem[item.ParentUID].AddItem(shipItem); break; case ItemReformerVO val: shipItem.SetLv(val.Lv); m_AllItem[item.ParentUID].AddItem(shipItem); break; case ItemEquipmentVO val: shipItem.SetLv(val.Lv); shipItem.SetItemPos(val.Position); m_AllItem[item.ParentUID].AddItem(shipItem); break; case ItemModVO val: shipItem.SetLv(val.Lv); shipItem.SetItemPos(val.Position); m_AllItem[item.ParentUID].AddItem(shipItem); break; case ItemSkillVO val: shipItem.SetItemPos(val.Position); m_AllItem[item.ParentUID].AddItem(shipItem); break; case ItemContainer val: shipItem.SetCurrentSizeMax(val.CurrentSizeMax); m_AllItem[item.ParentUID].AddContainer(val.ContainerType, shipItem); break; } shipItem.SetBaseConfig(item.ItemConfig); Convert(shipItem, item.Items); if (m_AllItem.ContainsKey(shipItem.GetUID())) { m_AllItem.Remove(shipItem.GetUID()); } m_AllItem.Add(shipItem.GetUID(), shipItem); }