示例#1
0
        public BuildItemUnitView GetMotherViewModel(bool premiumIsActive, StorageResources resources = null)
        {
            //if (resources == null) throw new Exception(Error.UserResourceNotSetInInstance);

            var description = new LangField(Resource.MotherEnergyConverter, Resource.MotherEnergyConverterDescription);

            var images = new SpriteImages().BuildImages(MotherCssNativename);

            var model = new BuildItemUnitView
            {
                TranslateName = description.Name,
                NativeName    = NativeName,
                IconSelf      = images.Icon,
                Info          = new BuildDropItemInfo
                {
                    Description = description.Name,
                    DropImage   = images.Detail
                },
                Action = new BuildDropItemAction
                {
                    ViewPath = BuildEnergyConverterActions.ViewPath,
                    Data     = new BuildEnergyConverterActions
                    {
                        StorageResources = null,
                        ConvertLoses     = GameMathStats.BaseConvertLosses
                    }
                },
                IsBuildItem = true
            };

            model.SetComplexButtonView();
            model.Action.SetButtons();
            return(model);
        }
示例#2
0
        public BuildItemUnitView GetMotherViewModel(bool premiumIsActive, StorageResources resources = null)
        {
            if (resources?.Current == null)
            {
                throw new Exception(Error.ProportionNotSetInModel);
            }


            var description = new LangField(Resource.MotherExtractionModule, Resource.MotherStorageDescription);

            var images = new SpriteImages().BuildImages(MotherCssNativename);

            //todo  временно
            // var power = GetPower(1, premiumIsActive);
            var power      = GetPower(22, premiumIsActive);
            var extraction = new ExtractionResource();

            extraction.SetAndCalcEmpFromProportion(resources.Current, power, BaseProportion.Ir, BaseProportion.Dm);


            var model = new BuildItemUnitView
            {
                TranslateName = description.Name,
                NativeName    = NativeName,
                IconSelf      = images.Icon,
                Info          = new BuildDropItemInfo
                {
                    Description = description.Name,
                    DropImage   = images.Detail
                },
                Action = new BuildDropItemAction
                {
                    ViewPath = BuildExtractionModuleActions.ViewPath,
                    Data     = new BuildExtractionModuleActions
                    {
                        //todo  реализовать
                        Power             = power,
                        Percent           = extraction.ExtractionProportin,
                        ExtractionPerHour = extraction.ExtractionPerHour
                    }
                },
                IsBuildItem = true
            };

            model.SetComplexButtonView();
            model.Action.SetButtons();

            return(model);
        }
        public BuildItemUnitView GetMotherViewModel(bool premiumIsActive, StorageResources resources = null)
        {
            if (resources == null)
            {
                resources = new StorageResources();
                resources.InitializeField();
            }
            var description = new LangField(Resource.MotherStorage, Resource.MotherStorageDescription);
            var images      = new SpriteImages().BuildImages(MotherCssNativename);

            var model = new BuildItemUnitView
            {
                TranslateName = description.Name,
                NativeName    = NativeName,
                IconSelf      = images.Icon,
                Info          = new BuildDropItemInfo
                {
                    Description = description.Name,
                    DropImage   = images.Detail
                },
                Action = new BuildDropItemAction
                {
                    ViewPath = BuildStorageActions.ViewPath,
                    Data     = new BuildStorageActions
                    {
                        StorageResources = resources,
                        Losses           = GetTransferLossesMod(1, premiumIsActive)
                    }
                },
                IsBuildItem = true
            };


            SetRequiredButtons(model);

            return(model);
        }
示例#4
0
    public bool ReadFile(String descFilePath, out string errorString)
    {
        m_FilePaths.Clear();
        m_Description.Clear();

        if (!File.Exists(descFilePath))
        {
            errorString = string.Format("错误:没有找到文件{0}", descFilePath);
            return(false);
        }

        using (FileStream fileStream = new FileStream(descFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
        {
            using (XmlReader reader = XmlReader.Create(descFilePath))
            {
                while (reader.Read())
                {
                    if (reader.Name == "LangElement" && reader.NodeType == XmlNodeType.Element)
                    {
                        String filePath = reader.GetAttribute("File");
                        String fileAbbr = reader.GetAttribute("Abbr");
                        if (m_FilePaths.Contains(filePath))
                        {
                            m_FilePaths.Clear();
                            m_Description.Clear();
                            errorString = string.Format("错误:描述文件中的文件路径重复 {0}", filePath);
                            return(false);
                        }

                        string fileName = Path.GetFileNameWithoutExtension(filePath);
                        if (m_Description.ContainsKey(fileName))
                        {
                            m_FilePaths.Clear();
                            m_Description.Clear();
                            errorString = string.Format("错误:描述文件中的文件名重复 {0}", filePath);
                            return(false);
                        }

                        LangContent langContent = new LangContent();
                        langContent.FileName = fileName;
                        langContent.FileAbbr = fileAbbr;

                        XmlReader subReader = reader.ReadSubtree();
                        while (subReader.Read())
                        {
                            if (subReader.Name == "Field" && subReader.NodeType == XmlNodeType.Element)
                            {
                                LangField field = new LangField();
                                field.FieldName = reader.GetAttribute("Name");
                                field.FieldAbbr = reader.GetAttribute("Abbr");

                                langContent.LangFields.Add(field);

                                Utils.Log(string.Format("LangField: path={0} file={1} field={2}", filePath, fileName, field.FieldName));
                            }
                        }
                        m_FilePaths.Add(filePath);
                        m_Description.Add(fileName, langContent);
                    }
                }
            }
        }

        errorString = null;
        return(true);
    }