Пример #1
0
        private async Task <ShopModel> InitWppModel(ShopModel shopModel)
        {
            // log.Debug("Ожидание спавна кораблей");
            await MyTaskExtensions.WaitUntil(lobbyEcsController.IsWarshipsCreationCompleted);

            // log.Debug(lobbyEcsController.GetCountOfSpawnedWarships());
            // log.Debug("Ожидание спавна закончено");
            var products = shopModel.UiSections.Select(section => section.UiItems)
                           .SelectMany(item => item)
                           .SelectMany(item => item)
                           .ToList()
            ;

            // log.Debug("Кол-во продуктов "+products.Count());
            foreach (ProductModel productModel in products)
            {
                if (productModel.ResourceTypeEnum == ResourceTypeEnum.WarshipPowerPoints)
                {
                    // log.Debug("Упаковка вспомогательной информации для продукта с id "+productModel.Id);
                    try
                    {
                        WarshipPowerPointsProductModel model = ZeroFormatterSerializer
                                                               .Deserialize <WarshipPowerPointsProductModel>(productModel.SerializedModel);

                        // log.Debug($"{nameof(model.Increment)} {model.Increment}" +
                        //           $"{nameof(model.WarshipId)} {model.WarshipId}"+
                        //           $"{nameof(model.SupportClientModel)} {model.SupportClientModel}"+
                        //           $"{nameof(model.WarshipTypeEnum)} {model.WarshipTypeEnum}"+
                        //           "");
                        int powerLevel = lobbyEcsController.GetWarshipPowerLevel(model.WarshipTypeEnum);
                        var powerModel = WarshipPowerScale.GetModel(powerLevel);

                        var supportModel = new WppSupportClientModel()
                        {
                            StartValue       = lobbyEcsController.GetWarshipPowerPoints(model.WarshipTypeEnum),
                            WarshipSkinName  = lobbyEcsController.GetSkinName(model.WarshipTypeEnum),
                            MaxValueForLevel = powerModel.PowerPointsCost
                        };

                        model.SupportClientModel = supportModel;

                        productModel.SerializedModel = ZeroFormatterSerializer.Serialize(model);
                    }
                    catch (Exception e)
                    {
                        log.Error(e.Message + " " + e.StackTrace);
                        return(null);
                    }
                }
            }

            return(shopModel);
        }