/// <summary>
 /// Primary Constructor for ComponentDesignAbilityDB
 /// </summary>
 /// <param name="expressionString"></param>
 /// <param name="designAbility"></param>
 /// <param name="factionTech"></param>
 /// <param name="staticDataStore"></param>
 internal ChainedExpression(string expressionString, ComponentDesignAttribute designAbility, FactionTechDB factionTech, StaticDataStore staticDataStore)
 {
     _staticDataStore = staticDataStore;
     _factionTechDB   = factionTech;
     _designer        = designAbility.ParentComponent;
     _designAttribute = designAbility;
     ReplaceExpression(expressionString);
 }
 /// <summary>
 /// a private constructor that is used internaly for a one use Expression
 /// </summary>
 /// <param name="expression"></param>
 /// <param name="designAbility"></param>
 /// <param name="factionTech"></param>
 /// <param name="staticDataStore"></param>
 private ChainedExpression(Expression expression, ComponentDesignAttribute designAbility, FactionTechDB factionTech, StaticDataStore staticDataStore)
 {
     _staticDataStore = staticDataStore;
     _factionTechDB   = factionTech;
     _designer        = designAbility.ParentComponent;
     _designAttribute = designAbility;
     _expression      = expression;
     SetupExpression();
 }
Exemplo n.º 3
0
        public ComponentAbilityDesignVM(ComponentDesignVM designVM, ComponentDesignAttribute designAbility, StaticDataStore staticData)
        {
            _designAbility  = designAbility;
            _staticData     = staticData;
            _parentDesignVM = designVM;


            switch (designAbility.GuiHint)
            {
            case GuiHint.GuiTechSelectionList:

                foreach (var kvp in designAbility.GuidDictionary)
                {
                    TechSD sd = _staticData.Techs[Guid.Parse((string)kvp.Key)];
                    TechList.Add(sd, sd.Name);
                }
                TechList.SelectedIndex          = 0;
                TechList.SelectionChangedEvent += TechList_SelectionChangedEvent;
                break;

            case GuiHint.GuiSelectionMaxMin:
            {
                minMaxSliderVM = new MinMaxSliderVM();

                designAbility.SetMax();
                designAbility.SetMin();
                designAbility.SetValue();
                designAbility.SetStep();
                minMaxSliderVM.Name             = Name;
                minMaxSliderVM.MaxValue         = MaxValue;
                minMaxSliderVM.MinValue         = MinValue;
                minMaxSliderVM.StepValue        = StepValue;
                minMaxSliderVM.Value            = Value; //.PreLoadedValue = Value; //hack due to eto bug. MinMaxSlider.Value = Value;
                minMaxSliderVM.PropertyChanged += MinMaxSlider_PropertyChanged;
            }
            break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// takes a ComponentSD staticData and turns it into a DesignDB
        /// </summary>
        /// <param name="component">the componentSD</param>
        /// <param name="factionTech">this factions TechDB</param>
        /// <param name="staticData">the game staticData</param>
        /// <returns></returns>
        public static ComponentDesign StaticToDesign(ComponentTemplateSD component, FactionTechDB factionTech, StaticDataStore staticData)
        {
            ComponentDesign design = new ComponentDesign();

            design.RawName     = component.Name;
            design.Name        = component.Name;
            design.Description = component.Description;

            design.MassFormula         = new ChainedExpression(component.MassFormula, design, factionTech, staticData);
            design.VolumeFormula       = new ChainedExpression(component.VolumeFormula, design, factionTech, staticData);
            design.CrewFormula         = new ChainedExpression(component.CrewReqFormula, design, factionTech, staticData);
            design.HTKFormula          = new ChainedExpression(component.HTKFormula, design, factionTech, staticData);
            design.ResearchCostFormula = new ChainedExpression(component.ResearchCostFormula, design, factionTech, staticData);
            design.BuildCostFormula    = new ChainedExpression(component.BuildPointCostFormula, design, factionTech, staticData);
            design.MineralCostFormulas = new Dictionary <Guid, ChainedExpression>();
            design.CreditCostFormula   = new ChainedExpression(component.CreditCostFormula, design, factionTech, staticData);
            design.ComponentMountType  = component.MountType;
            design.ConstructionType    = component.ConstructionType;
            design.CargoTypeID         = component.CargoTypeID;

            foreach (var kvp in component.MineralCostFormula)
            {
                design.MineralCostFormulas.Add(kvp.Key, new ChainedExpression(kvp.Value, design, factionTech, staticData));
            }

            design.ComponentDesignAttributes = new List <ComponentDesignAttribute>();
            foreach (var abilitySD in component.ComponentAbilitySDs)
            {
                ComponentDesignAttribute designAttribute = new ComponentDesignAttribute(design);

                designAttribute.Name        = abilitySD.Name;
                designAttribute.Description = abilitySD.Description;
                designAttribute.GuiHint     = abilitySD.GuiHint;

                if (abilitySD.AbilityFormula != null)
                {
                    designAttribute.Formula = new ChainedExpression(abilitySD.AbilityFormula, designAttribute, factionTech, staticData);
                }

                if (abilitySD.GuidDictionary != null)
                {
                    designAttribute.GuidDictionary = new Dictionary <object, ChainedExpression>();
                    if (designAttribute.GuiHint == GuiHint.GuiTechSelectionList)
                    {
                        foreach (var kvp in abilitySD.GuidDictionary)
                        {
                            if (factionTech.ResearchedTechs.ContainsKey(Guid.Parse(kvp.Key.ToString())))
                            {
                                TechSD techSD = staticData.Techs[Guid.Parse(kvp.Key.ToString())];
                                designAttribute.GuidDictionary.Add(kvp.Key, new ChainedExpression(ResearchProcessor.DataFormula(factionTech, techSD).ToString(), designAttribute, factionTech, staticData));
                            }
                        }
                    }
                    else
                    {
                        foreach (var kvp in abilitySD.GuidDictionary)
                        {
                            designAttribute.GuidDictionary.Add(kvp.Key, new ChainedExpression(kvp.Value, designAttribute, factionTech, staticData));
                        }
                    }
                }
                if (designAttribute.GuiHint == GuiHint.GuiSelectionMaxMin)
                {
                    designAttribute.MaxValueFormula  = new ChainedExpression(abilitySD.MaxFormula, designAttribute, factionTech, staticData);
                    designAttribute.MinValueFormula  = new ChainedExpression(abilitySD.MinFormula, designAttribute, factionTech, staticData);
                    designAttribute.StepValueFormula = new ChainedExpression(abilitySD.StepFormula, designAttribute, factionTech, staticData);
                }
                if (abilitySD.AbilityDataBlobType != null)
                {
                    designAttribute.DataBlobType = Type.GetType(abilitySD.AbilityDataBlobType);
                }

                design.ComponentDesignAttributes.Add(designAttribute);
            }

            design.MassFormula.Evaluate();
            design.SetCrew();
            design.SetHTK();
            design.SetResearchCost();
            design.SetBuildCost();
            design.SetMineralCosts();

            return(design);
        }