Exemplo n.º 1
0
        public void InitData(int blockID, int posX, int posZ)
        {
            functionBlock = FunctionBlockModule.GetFunctionBlockByBlockID(blockID);

            UIinfo = UIUtility.SafeGetComponent <BlockUIScriptInfo>(transform);
            UIinfo.SetData(this);
            ModelRoot       = UIUtility.FindTransfrom(transform, "Root/ModelRoot").gameObject;
            gameObject.name = instanceID + "[Block]";

            SetPosition(new Vector3(posX, transform.localScale.y / 2, posZ));
            info = new FunctionBlockInfoData();
            info.CreateBaseInfo(transform.position, functionBlock,
                                new FunctionBlockModifier(ModifierTarget.FunctionBlock, instanceID));

            var blockType = info.dataModel.BlockType;

            if (blockType == FunctionBlockType.ElementCapsule)
            {
                var manuBase = transform.SafeAddCmpt <ManufactoryBase>();
                manuBase.SetData();
            }
            else if (blockType == FunctionBlockType.EnergyStorageUnit)
            {
                var normalBase = transform.SafeAddCmpt <BlockNormalBase>();
                normalBase.SetData();
            }

            InitBase();
        }
Exemplo n.º 2
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);
            }
        }
Exemplo 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);
        }
Exemplo n.º 4
0
 public void DoManufactModifier(ManufactoryInfo manuInfo, FunctionBlockInfoData baseInfo, string modifierName)
 {
     ModifierManager.Instance.AddManufactBlockModifier(manuInfo, baseInfo, modifierName);
 }
Exemplo n.º 5
0
 public void AddManufactBlockModifier(ManufactoryInfo manuInfo, FunctionBlockInfoData baseInfo, string modifierName)
 {
     AddManufactoryBlockModifier(manuInfo, baseInfo, GetModifierBase(modifierName));
 }
Exemplo n.º 6
0
 public FunctionBlockHistory(FunctionBlockInfoData blockInfo, string buildData)
 {
     FacotoryID        = blockInfo.BlockID;
     FunctionBlockGUID = blockInfo.dataModel.GUID;
     this.BuildDate    = buildData;
 }