Пример #1
0
 public override bool OnMessage(UIMessage msg)
 {
     if (msg.type == UIMsgType.Assemble_Part_PropertyChange)
     {
         Config.PartsCustomConfig.ConfigData configData = (Config.PartsCustomConfig.ConfigData)msg.content[0];
         float currentValue = (float)msg.content[1];
         return(CalculateValue(configData, currentValue));
     }
     else if (msg.type == UIMsgType.Assemble_PartTab_Select)
     {
         string typeName = (string)msg.content[0];
         return(RefreshChooseContent(typeName));
     }
     else if (msg.type == UIMsgType.Assemble_PartPreset_Select)
     {
         AssemblePartInfo info = new AssemblePartInfo();
         if (info.InitData((int)msg.content[0]))
         {
             _info = info;
             SetUpContent();
         }
     }
     return(true);
 }
Пример #2
0
        bool CalculateValue(Config.PartsCustomConfig.ConfigData config, float Value)
        {
            if (config == null)
            {
                return(false);
            }

            int diffValue = (int)System.Math.Round((Value - config.CustomDataRangeMin) * 10, 0);

            if (config.TimeCostPerUnit != 0)
            {
                AssemblePartTimeCostDetialInfo info = new AssemblePartTimeCostDetialInfo
                {
                    customDataName  = config.CustomDataName,
                    modifyTimeValue = diffValue * (float)config.TimeCostPerUnit
                };
                RefreshTimeCostValue(info);
            }

            for (int i = 0; i < config.propertyLinkData.Count; i++)
            {
                var propertyName = config.propertyLinkData[i].Name;
                foreach (var item in _propertyItem)
                {
                    if (item._configData.Name == propertyName)
                    {
                        if (item._configData.PropertyType == 1)
                        {
                            ///Fix Value
                            float currentValue = diffValue * (float)config.propertyLinkData[i].PropertyChangePerUnitValue;
                            AssemblePartPropertyDetailInfo detailInfo = new AssemblePartPropertyDetailInfo
                            {
                                customDataName   = config.CustomDataName,
                                propertyLinkName = config.propertyLinkData[i].Name,
                                modifyType       = config.propertyLinkData[i].PropertyChangeType,
                                modifyValueFix   = currentValue
                            };

                            item.ChangeValue(detailInfo);
                        }
                        else if (item._configData.PropertyType == 2)
                        {
                            float currentValueMin = diffValue * (float)config.propertyLinkData[i].PropertyChangePerUnitMin;
                            float currentValueMax = diffValue * (float)config.propertyLinkData[i].PropertyChangePerUnitMax;
                            AssemblePartPropertyDetailInfo detailInfo = new AssemblePartPropertyDetailInfo
                            {
                                customDataName   = config.CustomDataName,
                                propertyLinkName = config.propertyLinkData[i].Name,
                                modifyType       = config.propertyLinkData[i].PropertyChangeType,
                                modifyValueMin   = currentValueMin,
                                modifyValueMax   = currentValueMax
                            };

                            item.ChangeValue(detailInfo);
                        }
                    }
                }
            }

            return(true);
        }