Пример #1
0
        public static List <ClientInventoryItem> ParseItemsArray(object[] inventoryItems)
        {
            List <ClientInventoryItem> result = new List <ClientInventoryItem>(inventoryItems.Length);

            foreach (object obj in inventoryItems)
            {
                if (obj is Hashtable)
                {
                    Hashtable           itemInfo  = obj as Hashtable;
                    int                 itemCount = itemInfo.GetValue <int>((int)SPC.Count, 0);
                    InventoryObjectType itemType  = itemInfo.GetValue <byte>((int)SPC.ItemType, (byte)InventoryObjectType.Weapon).toEnum <InventoryObjectType>();

                    var itemObj = Get(itemInfo);
                    if (itemObj != null)
                    {
                        result.Add(new ClientInventoryItem(itemObj, itemCount));
                    }
                    else
                    {
                        throw new NebulaException(string.Format("not founded factory for inventory object type = {0}", itemType));
                    }
                }
            }
            return(result);
        }
Пример #2
0
 public MiscInventoryItemData(string id, InventoryObjectType type, string name, Hashtable data)
 {
     this.id   = id;
     this.type = type;
     this.name = name;
     this.data = data;
 }
Пример #3
0
        public void ParseInfo(System.Collections.Hashtable info)
        {
            rawHash               = info;
            this.id               = info.GetValue <string>((int)SPC.Id, string.Empty);
            this.name             = info.GetValue <string>((int)SPC.Name, string.Empty);
            this.level            = info.GetValue <int>((int)SPC.Level, 0);
            this.workshop         = info.GetValue <byte>((int)SPC.Workshop, 0).toEnum <Workshop>();
            this.type             = info.GetValue <byte>((int)SPC.ItemType, 0).toEnum <InventoryObjectType>();
            this.targetTemplateId = info.GetValue <string>((int)SPC.Template, string.Empty);
            this.color            = (ObjectColor)(byte)info.GetValue <int>((int)SPC.Color, 0);

            if (info.ContainsKey((int)SPC.Set))
            {
                set = info.GetValue <string>((int)SPC.Set, string.Empty);
            }
            else
            {
                set = string.Empty;
            }

            Hashtable craftMaterialsHash = info.GetValue <Hashtable>((int)SPC.CraftMaterials, new Hashtable());

            this.craftMaterials = craftMaterialsHash.toDict <string, int>();
            binded = info.GetValue <bool>((int)SPC.Binded, false);
        }
Пример #4
0
        public async Task <bool> UpdateInventoryObjectTypeAsync(InventoryObjectType newModel)
        {
            _appDbContext.InventoryObjectTypes.Update(newModel);
            await _appDbContext.SaveChangesAsync();

            return(true);
        }
Пример #5
0
 public DropItem(int minCount, int maxCount, float prob, InventoryObjectType type)
 {
     m_MinCount = minCount;
     m_MaxCount = maxCount;
     m_Prob     = prob;
     m_Type     = type;
 }
Пример #6
0
        public void Load(string xml)
        {
#if UP
            UPXDocument document = new UPXDocument(xml);
#else
            XDocument document = XDocument.Parse(xml);
#endif

            this.items = document.Element("items").Elements("item").Select(e => {
                string id = e.GetString("id");
                InventoryObjectType type = (InventoryObjectType)Enum.Parse(typeof(InventoryObjectType), e.GetString("type"));
                string name    = e.GetString("name");
                Hashtable data = new Hashtable();

                var dump = e.Element("inputs").Elements("input").Select(ie => {
                    string key     = ie.GetString("key");
                    string valType = ie.GetString("type");
                    string valStr  = ie.GetString("value");
                    object val     = CommonUtils.ParseValue(valStr, valType);
                    data.Add(key, val);
                    return(key);
                }).ToList();

                return(new ResMiscInventoryItemData(id, type, name, data));
            }).ToDictionary(obj => obj.Id(), obj => obj);
        }
Пример #7
0
        public void ParseInfo(Hashtable info)
        {
            rawHash               = info;
            this.id               = info.GetValueString((int)SPC.Id);
            this.name             = info.GetValueString((int)SPC.Name);
            this.level            = info.GetValueInt((int)SPC.Level, 0);
            this.workshop         = info.GetValueByte((int)SPC.Workshop).toEnum <Workshop>();
            this.type             = info.GetValueByte((int)SPC.ItemType).toEnum <InventoryObjectType>();
            this.targetTemplateId = info.GetValueString((int)SPC.Template);
            this.color            = (ObjectColor)(byte)info.GetValueInt((int)SPC.Color);

            if (info.ContainsKey((int)SPC.Set))
            {
                set = info.GetValueString((int)SPC.Set);
            }
            else
            {
                set = string.Empty;
            }

            Hashtable craftMaterialsHash = info.GetValueHash((int)SPC.CraftMaterials);

            this.craftMaterials = craftMaterialsHash.toDict <string, int>();
            binded = info.GetValueBool((int)SPC.Binded);
            isNew  = info.GetValueBool((int)SPC.IsNew);
        }
Пример #8
0
 public CountOfItemsGECondition(InventoryObjectType type, string id, int value, string updateText)
     : base(QuestConditionName.COUNT_OF_ITEMS_GE)
 {
     m_Type       = type;
     m_Id         = id;
     m_Value      = value;
     m_UpdateText = updateText;
 }
Пример #9
0
 public ConsumableItem(string id, InventoryObjectType type, int price, int count, MoneyType moneyType)
 {
     this.id        = id;
     this.type      = type;
     this.price     = price;
     this.count     = count;
     this.moneyType = moneyType;
 }
Пример #10
0
 public override void Load(XElement element)
 {
     base.Load(element);
     if (element.HasAttribute("inventory_type"))
     {
         ObjectType = element.GetEnum <InventoryObjectType>("inventory_type");
     }
 }
Пример #11
0
        public InventoryVector(InventoryObjectType type, Hash objectHash)
        {
            Contract.Requires <ArgumentNullException>(objectHash != null);

            Type       = type;
            ObjectHash = objectHash;

            ByteSize = (uint)InventoryVector.ConstantByteSize;
        }
Пример #12
0
        public int ItemCount(InventoryObjectType type, string id)
        {
            T item = default(T);

            if (TryGetItem(type, id, out item))
            {
                return(item.Count);
            }
            return(0);
        }
Пример #13
0
        public bool HasItem(InventoryObjectType type, string id)
        {
            T item = default(T);

            if (TryGetItem(type, id, out item))
            {
                return(item.Has);
            }
            return(false);
        }
Пример #14
0
 public bool Contains(string contentID, InventoryObjectType objType)
 {
     foreach (var contentObj in content)
     {
         if (contentObj.Material.Id == contentID && contentObj.Material.Type == objType)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #15
0
 public bool HasTypeObject(InventoryObjectType objectType)
 {
     foreach (GameObject item in objects)
     {
         if (item.GetComponent <InteractableObject>().type == objectType)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #16
0
        public bool TryGetItem(InventoryObjectType type, string id, out T item)
        {
            item = default(T);
            Dictionary <string, T> typedItems;

            if (_items.TryGetValue(type, out typedItems))
            {
                return(typedItems.TryGetValue(id, out item));
            }
            return(false);
        }
Пример #17
0
        public DropItem Create(XElement element)
        {
            InventoryObjectType type = (InventoryObjectType)Enum.Parse(typeof(InventoryObjectType), element.GetString("type"));
            int   min  = element.GetInt("min");
            int   max  = element.GetInt("max");
            float prob = element.GetFloat("prob");

            switch (type)
            {
            case InventoryObjectType.Weapon:
                return(new WeaponDropItem(min, max, prob));

            case InventoryObjectType.Scheme:
                return(new SchemeDropItem(min, max, prob));

            case InventoryObjectType.Material: {
                string template = element.GetString("template");
                return(new MaterialDropItem(template, min, max, prob));
            }

            case InventoryObjectType.nebula_element: {
                string template = element.GetString("template");
                return(new NebulaElementDropItem(template, min, max, prob));
            }

            case InventoryObjectType.craft_resource: {
                string template = element.GetString("template");
                return(new CraftResourceDropItem(template, min, max, prob));
            }

            case InventoryObjectType.pet_scheme: {
                PetColor color    = (PetColor)Enum.Parse(typeof(PetColor), element.GetString("color"));
                string   template = element.GetString("template");
                return(new PetSchemeDropItem(template, color, min, max, prob));
            }

            case InventoryObjectType.contract_item: {
                string template = element.GetString("template");
                string contract = element.GetString("contract");
                return(new ContractObjectDropItem(template, contract, min, max, prob));
            }

            case InventoryObjectType.planet_resource_hangar: {
                return(new PlanetHangarDropItem(min, max, prob));
            }

            case InventoryObjectType.planet_resource_accelerator: {
                return(new PlanetResourceAcceleratorDropItem(min, max, prob));
            }

            default:
                return(null);
            }
        }
Пример #18
0
 public static Hashtable ItemHash(string id, int level, ObjectColor color, InventoryObjectType type, PlacingType placingType, bool binded, bool splittable)
 {
     return(new Hashtable {
         { (int)SPC.Id, id },
         { (int)SPC.Level, level },
         { (int)SPC.Color, (int)(byte)color },
         { (int)SPC.ItemType, (int)(byte)type },
         { (int)SPC.PlacingType, (int)placingType },
         { (int)SPC.Binded, binded },
         { (int)SPC.Splittable, splittable }
     });
 }
Пример #19
0
        public void Remove(InventoryObjectType type, string id, int count)
        {
            T item = default(T);

            if (TryGetItem(type, id, out item))
            {
                item.Remove(count);
                if (false == item.Has)
                {
                    _items[type].Remove(item.Object.Id);
                }
            }
        }
Пример #20
0
 public bool TryGetItemData(InventoryObjectType type, out MiscInventoryItemData data)
 {
     data = null;
     foreach (var kv in this.items)
     {
         if (kv.Value.Type() == type)
         {
             data = kv.Value;
             return(true);
         }
     }
     return(false);
 }
Пример #21
0
        private DialogCondition Create(UniXMLElement element)
        {
            string type = element.GetString("type");

            switch (type)
            {
            case QuestConditionName.ON_STATION: {
                return(new OnStationCondition());
            }

            case QuestConditionName.QUEST_COMPLETED: {
                string questId = element.GetString("id");
                return(new QuestCompletedCondition(questId));
            }

            case QuestConditionName.AT_SPACE: {
                return(new AtSpaceCondition());
            }

            case QuestConditionName.DIALOG_COMPLETED: {
                string id = element.GetString("id");
                return(new DialogCompletedCondition(id));
            }

            case QuestConditionName.USER_EVENT: {
                UserEventName eventName = (UserEventName)Enum.Parse(typeof(UserEventName), element.GetString("name"));
                return(CreateUserEventCondition(element, eventName));
            }

            case QuestConditionName.COUNT_OF_ITEMS_GE: {
                string id = element.GetString("id");
                InventoryObjectType itemType = (InventoryObjectType)Enum.Parse(typeof(InventoryObjectType), element.GetString("item_type"));
                int    value      = element.GetInt("value");
                string updateText = string.Empty;
                if (element.HasAttribute("update_text"))
                {
                    updateText = element.GetString("update_text");
                }
                return(new CountOfItemsGECondition(itemType, id, value, updateText));
            }

            case QuestConditionName.INT_VARIABLE_VALUE_EQ:
            case QuestConditionName.INT_VARIABLE_VARLUE_GE:
            case QuestConditionName.FLOAT_VARIABLE_VALUE_EQ:
            case QuestConditionName.BOOL_VARIABLE_VALUE_EQ:
                return(ParseVariableValueCondtion(type, element));

            default:
                return(null);
            }
        }
Пример #22
0
        private QuestReward LoadReward(XElement element)
        {
            QuestRewardType rewardType = element.GetEnum <QuestRewardType>("type");

            switch (rewardType)
            {
            case QuestRewardType.credits: {
                QuestReward creditsReward = new QuestReward();
                creditsReward.Load(element);
                return(creditsReward);
            }

            case QuestRewardType.exp: {
                QuestReward expReward = new QuestReward();
                expReward.Load(element);
                return(expReward);
            }

            case QuestRewardType.nebula_credits: {
                QuestReward nebCreditsReward = new QuestReward();
                nebCreditsReward.Load(element);
                return(nebCreditsReward);
            }

            case QuestRewardType.item: {
                InventoryObjectType inventoryObjectType = element.GetEnum <InventoryObjectType>("inventory_type");
                switch (inventoryObjectType)
                {
                case InventoryObjectType.Scheme: {
                    SchemeItemQuestReward schemeReward = new SchemeItemQuestReward();
                    schemeReward.Load(element);
                    return(schemeReward);
                }

                case InventoryObjectType.Material: {
                    MaterialItemQuestReward materialReward = new MaterialItemQuestReward();
                    materialReward.Load(element);
                    return(materialReward);
                }

                case InventoryObjectType.Weapon: {
                    WeaponItemQuestReward weaponReward = new WeaponItemQuestReward();
                    weaponReward.Load(element);
                    return(weaponReward);
                }
                }
                break;
            }
            }
            return(null);
        }
Пример #23
0
        public void Load(string basePath)
        {
            items.Clear();
            string fullPath = Path.Combine(basePath, "assets/consumable.xml");

            XDocument document = XDocument.Load(fullPath);
            var       dumpList = document.Element("items").Elements("item").Select(itemElementt => {
                string id = itemElementt.GetString("id");
                InventoryObjectType type = (InventoryObjectType)Enum.Parse(typeof(InventoryObjectType), itemElementt.GetString("type"));
                int price                     = itemElementt.GetInt("price");
                int count                     = itemElementt.GetInt("count");
                MoneyType moneyType           = (MoneyType)Enum.Parse(typeof(MoneyType), itemElementt.GetString("money_type"));
                ConsumableItem consumableItem = new ConsumableItem(id, type, price, count, moneyType);
                items.TryAdd(consumableItem.id, consumableItem);
                return(consumableItem);
            }).ToList();
        }
Пример #24
0
        public DropList(XElement element)
        {
            id    = element.GetString("id");
            items = element.Elements("item").Select(itemElement => {
                InventoryObjectType category = (InventoryObjectType)Enum.Parse(typeof(InventoryObjectType), itemElement.GetString("category"));
                switch (category)
                {
                case InventoryObjectType.Module:
                    return((DropListItem) new ModuleDropListItem(itemElement));

                case InventoryObjectType.Weapon:
                    return((DropListItem) new WeaponDropListItem(itemElement));

                default:
                    return(null);
                }
            }).ToList();
        }
Пример #25
0
        public List <IDCountPair> GetItemIds(InventoryObjectType type)
        {
            List <IDCountPair> ids = new List <IDCountPair>();

            foreach (var p in _items)
            {
                foreach (var p2 in p.Value)
                {
                    if (p2.Value.Object.Type == type)
                    {
                        ids.Add(new IDCountPair {
                            ID = p2.Key, count = p2.Value.Count
                        });
                    }
                }
            }
            return(ids);
        }
Пример #26
0
        public override bool Check(AuctionItem auctionItem)
        {
            if (auctionItem.objectInfo.ContainsKey((int)SPC.PlacingType))
            {
                PlacingType placingType = (PlacingType)(int)auctionItem.objectInfo[(int)SPC.PlacingType];

                if (auctionItem.objectInfo.ContainsKey((int)SPC.ItemType))
                {
                    InventoryObjectType itemType = (InventoryObjectType)(byte)(int)auctionItem.objectInfo[(int)SPC.ItemType];
                    if (itemType == InventoryObjectType.Weapon && mAuctionObjectType == AuctionObjectType.Weapon)
                    {
                        return(true);
                    }
                    else if (itemType == InventoryObjectType.Scheme && mAuctionObjectType == AuctionObjectType.Scheme)
                    {
                        return(true);
                    }
                    else if (itemType == InventoryObjectType.Material && mAuctionObjectType == AuctionObjectType.Ore)
                    {
                        return(true);
                    }
                    else if (itemType == InventoryObjectType.Module && mAuctionObjectType == AuctionObjectType.Module)
                    {
                        return(true);
                    }
                    else if (itemType == InventoryObjectType.nebula_element && mAuctionObjectType == AuctionObjectType.nebula_element)
                    {
                        return(true);
                    }
                    else if (itemType == InventoryObjectType.craft_resource && mAuctionObjectType == AuctionObjectType.craft_resource)
                    {
                        return(true);
                    }
                    else if (itemType == InventoryObjectType.pet_scheme && mAuctionObjectType == AuctionObjectType.pet_scheme)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #27
0
        public void Load(string basePath)
        {
            string    fullPath = Path.Combine(basePath, "Data/misc_inventory_items.xml");
            XDocument document = XDocument.Load(fullPath);

            this.items = document.Element("items").Elements("item").Select(e => {
                string id = e.GetString("id");
                InventoryObjectType type = (InventoryObjectType)Enum.Parse(typeof(InventoryObjectType), e.GetString("type"));
                string name    = e.GetString("name");
                Hashtable data = new Hashtable();

                var dump = e.Element("inputs").Elements("input").Select(ie => {
                    string key     = ie.GetString("key");
                    string valType = ie.GetString("type");
                    string valStr  = ie.GetString("value");
                    object val     = CommonUtils.ParseValue(valStr, valType);
                    data.Add(key, val);
                    return(key);
                }).ToList();

                return(new MiscInventoryItemData(id, type, name, data));
            }).ToDictionary(obj => obj.Id(), obj => obj);
        }
Пример #28
0
 public DropItem(string itemId, InventoryObjectType itemType, int count)
 {
     this.itemId   = itemId;
     this.itemType = itemType;
     this.count    = count;
 }
Пример #29
0
        public static IInventoryObjectInfo Get(Hashtable info)
        {
            if (info.ContainsKey((int)SPC.ItemType))
            {
                InventoryObjectType type = (InventoryObjectType)(byte)info.Value <int>((int)SPC.ItemType, (int)(byte)InventoryObjectType.DrillScheme);

                switch (type)
                {
                case InventoryObjectType.Weapon:
                    return(new WeaponInventoryObjectInfo(info));

                case InventoryObjectType.Scheme:
                    return(new SchemeInventoryObjectInfo(info));

                case InventoryObjectType.Material:
                    return(new MaterialInventoryObjectInfo(info));

                case InventoryObjectType.DrillScheme:
                    return(new DrillSchemeObjectInfo(info));

                case InventoryObjectType.Module:
                    return(new ClientShipModule(info));

                case InventoryObjectType.fortification:
                    return(new FortificationInventoryObjectInfo(info));

                case InventoryObjectType.fort_upgrade:
                    return(new FortUpgradeInventoryObjectInfo(info));

                case InventoryObjectType.mining_station:
                    return(new MiningStationInventoryObjectInfo(info));

                case InventoryObjectType.outpost:
                    return(new OutpostInventoryObjectInfo(info));

                case InventoryObjectType.out_upgrade:
                    return(new OutpostUpgradeInventoryObjectInfo(info));

                case InventoryObjectType.personal_beacon:
                    return(new PersonalBeaconInventoryObjectInfo(info));

                case InventoryObjectType.repair_kit:
                    return(new RepairKitInventoryObjectInfo(info));

                case InventoryObjectType.repair_patch:
                    return(new RepairPatchInventoryObjectInfo(info));

                case InventoryObjectType.turret:
                    return(new TurretInventoryObjectInfo(info));

                case InventoryObjectType.nebula_element:
                    return(new NebulaElementObjectInfo(info));

                case InventoryObjectType.pass:
                    return(new PassInventoryObjectInfo(info));

                //case InventoryObjectType.credits:
                //    return new CreditsObjectInfo(info);
                default:
                    return(null);
                }
            }
            return(null);
        }
Пример #30
0
 public WeaponDropListItem(InventoryObjectType category, string colorList) :
     base(category, colorList)
 {
 }