예제 #1
0
        public void ParseJsonStringToSaveItemModel(string jsString)
        {
            // var mainNode = JsonWriter..JSON.Instance.Parse(jsString) as Dictionary<string, object>;
            var mainNode = JsonReader.Deserialize(jsString) as Dictionary <string, object>;

            LogoutTs        = DateTime.Parse(mainNode["LogoutTs"] as string);
            Stats           = SaveModelConvertor.DictObjToDictFloat(mainNode["Stats"] as Dictionary <string, object>);
            PlayerPosition  = GetVector3Object(mainNode, "PlayerPosition");
            PlayerRotation  = Convert.ToSingle(mainNode["PlayerRotation"]);
            PlayerInventory = SaveModelConvertor.ConvertToPlayerInventory(mainNode["PlayerInventory"]);
            GroundItems     = SaveModelConvertor.ConvertToGroundItems((mainNode["GroundItems"] as List <object>));
            if (mainNode.ContainsKey("CarModel"))
            {
                CarModel = SaveModelConvertor.ConvertToCarModel(mainNode["CarModel"]);
            }
            CurrentTime     = Convert.ToSingle(mainNode["CurrentTime"]);
            CurrentCurrency = Convert.ToInt32(mainNode["CurrentCurrency"]);
            CurrentBackpack = Convert.ToInt32(mainNode["CurrentBackpack"]);
            if (mainNode.ContainsKey("CurrentTerratinId"))
            {
                CurrentTerratinId = Convert.ToInt32(mainNode["CurrentTerratinId"]);
            }
            IsBuyStarterPack = Convert.ToBoolean(mainNode["IsBuyStarterPack"]);
            IsBuyFirst30000  = Convert.ToBoolean(mainNode["IsBuyFirst30000"]);
            if (mainNode.ContainsKey("IsBuyNoAds"))
            {
                IsBuyNoAds = Convert.ToBoolean(mainNode["IsBuyNoAds"]);
            }
            if (mainNode.ContainsKey("InCar"))
            {
                InCar = Convert.ToBoolean(mainNode["InCar"]);
            }
        }
예제 #2
0
        public static InventorySaveModel ConvertToPlayerInventory(object inventoryObj)
        {
            var inventorySaveModel = new InventorySaveModel();
            var nodeDict           = inventoryObj as Dictionary <string, object>;

            if (nodeDict == null)
            {
                return(null);
            }

            var itemsInSlots = nodeDict["ItemInSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemInSlots = DictObjToDictString(itemsInSlots);
            var itemAmountInSlots = nodeDict["ItemAmountInSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemAmountInSlots = DictObjToDictInt(itemAmountInSlots);
            var itemDurabilityInSlots = nodeDict["ItemDurabilityInSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemDurabilityInSlots = DictObjToDictNullInt(itemDurabilityInSlots);

            var itemInQuickSlots = nodeDict["ItemInQuickSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemInQuickSlots = DictObjToDictString(itemInQuickSlots);
            var itemAmountInQickSlots = nodeDict["ItemAmountInQuickSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemAmountInQuickSlots = DictObjToDictInt(itemAmountInQickSlots);
            var itemDurabilityInQuickSlots = nodeDict["ItemDurabilityInQuickSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemDurabilityInQuickSlots = DictObjToDictNullInt(itemDurabilityInQuickSlots);

            var itemInEquipSlots = nodeDict["ItemInEquipSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemInEquipSlots = DictObjToDictString(itemInEquipSlots);
            var itemAmountInEquipSlots = nodeDict["ItemAmountInEquipSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemAmountInEquipSlots = DictObjToDictInt(itemAmountInEquipSlots);
            var itemDurabilityInEquipSlots = nodeDict["ItemDurabilityInEquipSlots"] as Dictionary <string, object>;

            inventorySaveModel.ItemDurabilityInEquipSlots = DictObjToDictNullInt(itemDurabilityInEquipSlots);

            return(inventorySaveModel);
        }