Ejemplo n.º 1
0
    /// <summary>
    /// Метод конвертации базовых объектов в игровые
    /// </summary>
    /// <returns>Игровые объекты</returns>
    private List <UpgradeBoostItem> ConvertBaseObjectXmlToObjectList()
    {
        List <UpgradeBoostItem> allUpgradeObjectItems = new List <UpgradeBoostItem>();
        var xmlBoostAssignmentItems = xmlUpgrades.Upgrade_Items.Boost_Items.UpgradeBoostAssignment_Items.boostAssignment_Item;

        foreach (var baseItem in baseUpgradeObjectItems)
        {
            try {
                UpgradeBoostItem upgradeObjectItem = UpgradeBoostItem.ConvertUpgradeBaseObject(baseItem);
                var xmlBoostAssignmentItemsForItem = xmlBoostAssignmentItems.Where(x => x.IdUpgrade == baseItem.Id).ToArray();
                UpgradeBoostInfoObject[] upgradeBoostInfoObjects = new UpgradeBoostInfoObject[xmlBoostAssignmentItemsForItem.Length];
                for (int i = 0; i < xmlBoostAssignmentItemsForItem.Length; i++)
                {
                    upgradeBoostInfoObjects[i] = new UpgradeBoostInfoObject()
                    {
                        idBoostObject = xmlBoostAssignmentItemsForItem[i].idBoost_Item,
                        PercentBoost  = xmlBoostAssignmentItemsForItem[i].PercentBoost
                    };
                }
                upgradeObjectItem.BoostObjectsInfo = upgradeBoostInfoObjects;
                allUpgradeObjectItems.Add(upgradeObjectItem);
            } catch (Exception ex) {
                Debug.LogError(ex.Message);
                continue;
            }
        }
        return(allUpgradeObjectItems);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Метод конвертации информации из базы в игровые объекты
    /// </summary>
    /// <returns>Игровые объекты</returns>
    private List <UpgradeBoostItem> ConverSaveXmlToObjectList()
    {
        var saveItemsXml = saveUpgrades.Save_Upgrade_Items.Save_Boost_Items.Save_UpdateBoostObjectItem;

        saveItemsXml = saveItemsXml.Where(x => allUpgradeBoostItems.Any(y => y.Id == x.Id)).ToList();

        List <UpgradeBoostItem> saveGameItems = new List <UpgradeBoostItem>();

        foreach (var paramsItem in saveItemsXml)
        {
            try {
                var idItem                = paramsItem.Id;
                var gameItemInAll         = allUpgradeBoostItems.FirstOrDefault(x => x.Id == paramsItem.Id);
                UpgradeBoostItem gameItem = new UpgradeBoostItem()
                {
                    Id          = idItem,
                    Name        = gameItemInAll.Name,
                    Description = gameItemInAll.Description
                };
                saveGameItems.Add(gameItem);
            } catch (Exception ex) {
                Debug.LogError(ex.Message);
                continue;
            }
        }

        return(saveGameItems);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Добавляет запись в базу данных сохранения
    /// </summary>
    /// <param name="Item">Объект, который будут сохранен в БД</param>
    /// <returns></returns>
    public bool AddItemInSaveFile(UpgradeBoostItem Item)
    {
        try {
            var allSaveItems = saveGameInformation.Save_Upgrades.Save_Upgrade_Items.Save_Boost_Items.Save_UpdateBoostObjectItem;
            allSaveItems.Add(Item);

            saveGameInformation.Save_Upgrades.Save_Upgrade_Items.Save_Boost_Items.Save_UpdateBoostObjectItem = allSaveItems;
            DataBaseManager.dataBaseManager.SaveChanges(saveGameInformation);
        } catch (Exception ex) {
            Debug.LogError($"{ex.Message} \n {ex.StackTrace} \n MethodName: AddItemInSaveFile()");
        }
        return(true);
    }