Esempio n. 1
0
 public void AddShieldModifier(bool addAll, AssemblePartInfo partInfo, ModifierBase modifier, MainShip_ShieldDirection direction)
 {
     if (addAll)
     {
         foreach (var info in mainShipInfo.shieldInfoDic.Values)
         {
             ModifierManager.Instance.AddMainShipShieldModifier(partInfo, info, modifier);
         }
     }
     else
     {
         ModifierManager.Instance.AddMainShipShieldModifier(partInfo, mainShipInfo.shieldInfoDic[direction], modifier);
     }
 }
Esempio n. 2
0
        private bool IsAddMainShipShieldModifier(MainShipShieldInfo info, ModifierBase modifier)
        {
            ModifierData oldData = info.shipShieldModifier.GetModifierByID(modifier.ModifierName);

            if (oldData != null)
            {
                switch (modifier.OverlapType)
                {
                case ModifierOverlapType.TimeReset:
                    oldData.ResetTime();
                    break;
                }
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// 是否已经拥有该Modifier
        /// </summary>
        /// <param name="info"></param>
        /// <param name="modifier"></param>
        /// <returns></returns>
        private bool IsAddFunctionBlockModifier(FunctionBlockInfoData info, ModifierBase modifier)
        {
            ModifierData oldData = info.blockModifier.GetModifierByID(modifier.ModifierName);

            if (oldData != null)
            {
                switch (modifier.OverlapType)
                {
                case ModifierOverlapType.TimeReset:
                    oldData.ResetTime();
                    break;
                }
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public static ModifierData Create(ModifierBase modifier, Action callback, Action <ModifierData> addLayerAction, Action <ModifierData> removeLayerAction)
        {
            ModifierData data = Pop();

            data.modifierAddType     = modifier.AddType;
            data.modifierName        = modifier.ModifierName;
            data.CallFrequency       = modifier.CallFrequency;
            data._persistentTime     = modifier.Time;
            data.modifierOverlapType = modifier.OverlapType;
            data.modifierRemoveType  = modifier.RemoveType;
            data.target        = modifier.ParseTargetType(modifier.Target);
            data.MaxLimit      = modifier.MaxLimit;
            data.OnCallBack    = callback;
            data.OnAddLayer    = addLayerAction;
            data.OnDeleteLayer = removeLayerAction;
            data._Limit        = 1;
            return(data);
        }
Esempio n. 5
0
        public void AddMainShipShieldModifier(AssemblePartInfo partInfo, MainShipShieldInfo shieldInfo, ModifierBase modifierBase)
        {
            if (modifierBase == null)
            {
                DebugPlus.LogError("Modifier Base Data is null");
                return;
            }
            if (modifierBase.ParseTargetType(modifierBase.Target) != ModifierTarget.MainShipShield)
            {
                DebugPlus.LogError("ModifierTargetError  Name=" + modifierBase.ModifierName);
                return;
            }

            ModifierData data = null;

            switch (modifierBase.ParseModifierShieldType(modifierBase.effectType))
            {
            case  ModifierMainShip_Shield.Shield_open_init:
                if (!IsAddMainShipShieldModifier(shieldInfo, modifierBase))
                {
                    data = ModifierData.Create(modifierBase, delegate
                    {
                        shieldInfo.AddShieldOpenInit_Assemble(partInfo.modifierRootType, partInfo.UID, partInfo.partID, (int)modifierBase.Value);
                    });
                }
                break;
            }

            if (data != null)
            {
                ///ADD modifier
                shieldInfo.shipShieldModifier.OnAddModifier(data);
            }
        }
Esempio n. 6
0
        public void AddMainShipPowerAreaModifier(FunctionBlockBase block, MainShipPowerAreaInfo areaInfo, ModifierBase modifierBase)
        {
            if (modifierBase == null)
            {
                DebugPlus.LogError("Modifier Base Data is null");
                return;
            }
            if (modifierBase.ParseTargetType(modifierBase.Target) != ModifierTarget.MainShipPowerArea)
            {
                DebugPlus.LogError("ModifierTargetError  Name=" + modifierBase.ModifierName);
                return;
            }

            ModifierData data = null;

            switch (modifierBase.ParseModifierPowerAreaType(modifierBase.effectType))
            {
            case ModifierMainShip_PowerArea.EnergyStorageMax:
                //Modifier Speed
                if (!IsAddPowerAreaModifier(areaInfo, modifierBase))
                {
                    data = ModifierData.Create(modifierBase, delegate
                    {
                        areaInfo.AddMaxStoragePower(block.info.modifierRootType, block.instanceID, block.info.BlockID, (int)modifierBase.Value);
                    });
                }
                break;

            case ModifierMainShip_PowerArea.AreaDurability:
                if (!IsAddPowerAreaModifier(areaInfo, modifierBase))
                {
                    data = ModifierData.Create(modifierBase, delegate
                    {
                        areaInfo.ChangeAreaDurability_Max(block.info.modifierRootType, block.instanceID, block.info.BlockID, (int)modifierBase.Value);
                    });
                }
                break;
            }

            if (data != null)
            {
                ///ADD modifier
                areaInfo.areaModifier.OnAddModifier(data);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// General FuntionBlock
        /// </summary>
        /// <param name="infoData"></param>
        /// <param name="modifierBase"></param>
        public void AddManufactoryBlockModifier(ManufactoryInfo manuInfo, FunctionBlockInfoData baseInfo, ModifierBase modifierBase)
        {
            if (modifierBase == null)
            {
                Debug.LogError("Modifier Base Data is null");
                return;
            }
            if (modifierBase.ParseTargetType(modifierBase.Target) != ModifierTarget.FunctionBlock)
            {
                Debug.LogError("ModifierTargetError  Name=" + modifierBase.ModifierName);
                return;
            }

            ModifierData data = null;

            switch (modifierBase.ParseModifierFunctionBlockType(modifierBase.effectType))
            {
            case ModifierFunctionBlockType.ManuSpeed:
                //Modifier Speed
                if (!IsAddFunctionBlockModifier(baseInfo, modifierBase))
                {
                    data = ModifierData.Create(modifierBase, delegate
                    {
                        manuInfo.AddCurrentSpeed(modifierBase.Value);
                        UIManager.Instance.SendMessageToWnd(UIPath.WindowPath.BlockManu_Page, new UIMessage(UIMsgType.UpdateSpeedText, new List <object>(1)
                        {
                            manuInfo.CurrentSpeed
                        }));
                    });
                }
                break;

            case ModifierFunctionBlockType.EnergyCostNormal:
                //Modifier EnergyCost
                if (!IsAddFunctionBlockModifier(baseInfo, modifierBase))
                {
                    data = ModifierData.Create(modifierBase, delegate
                    {
                        manuInfo.AddEnergyCostNormal(modifierBase.Value);
                    });
                }
                break;
            }

            if (data != null)
            {
                baseInfo.blockModifier.OnAddModifier(data);
            }
        }
Esempio n. 8
0
 public static ModifierData Create(ModifierBase modifier, Action callback)
 {
     return(Create(modifier, callback, null, null));
 }
Esempio n. 9
0
 public void AddPowerAreaModifier(FunctionBlockBase block, ModifierBase modifier)
 {
     ModifierManager.Instance.AddMainShipPowerAreaModifier(block, mainShipInfo.powerAreaInfo, modifier);
 }