Esempio n. 1
0
        private int GetVerticalItemNum()
        {
            var scrollRect = UIUtility.SafeGetComponent <RectTransform>(transform).rect;
            var height     = scrollRect.height;

            return(Mathf.CeilToInt(height / (_itemHeight + sepConfig.VerticalSep)) + 1);
        }
Esempio n. 2
0
 public override void Awake()
 {
     Icon        = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Icon/Image"));
     Name        = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Unlock"));
     Unlock      = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Name"));
     RarityImage = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Icon/Rarity"));
 }
Esempio n. 3
0
        private int GetHorizontalItemNum()
        {
            var scrollRect = UIUtility.SafeGetComponent <RectTransform>(transform).rect;
            var width      = scrollRect.width;

            return(Mathf.CeilToInt(width / (_itemWidth + sepConfig.HorizontalSep)) - 1);
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
 private void InitBase()
 {
     //Set Collider
     BlockCollider = UIUtility.SafeGetComponent <BoxCollider>(transform);
     //SetBlockColliderSize(FunctionBlockModule.Instance.InitFunctionBlockBoxCollider(functionBlock,3.0f));
     InitDistrictModel();
 }
Esempio n. 6
0
        private void InitElement()
        {
            _generalBtn.onClick.RemoveAllListeners();

            _icon.sprite     = _model.Info.typePresetData.partSprite;
            _typeIcon.sprite = _model.Info.typePresetData.TypeIcon;
            _typeText.text   = _model.Info.typePresetData.TypeName;
            _name.text       = _model.Info.customName;

            foreach (Transform trans in _propertyContentTrans)
            {
                trans.gameObject.SetActive(false);
            }

            var propertyDic = _model.Info.customDataInfo.propertyDic;

            int i = 0;

            foreach (var data in propertyDic.Values)
            {
                if (i >= Config.GlobalConfigData.AssemblePart_Max_PropertyNum)
                {
                    break;
                }
                Transform propertyItem = _propertyContentTrans.GetChild(i);
                UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(propertyItem, "Icon")).sprite = data.propertyIcon;
                UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(propertyItem, "Name")).text    = data.propertyNameText;
                UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(propertyItem, "Value")).text   = string.Format("{0} ~ {1}", data.propertyValueMin.ToString(), data.propertyValueMax.ToString());
                propertyItem.gameObject.SetActive(true);
                i++;
            }

            RefreshModeType();
        }
Esempio n. 7
0
        public override void Awake()
        {
            Btn         = UIUtility.SafeGetComponent <Button>(transform);
            selectTrans = UIUtility.FindTransfrom(transform, "Content/Icon/Select");
            selectTrans.gameObject.SetActive(false);
            lockTrans     = UIUtility.FindTransfrom(transform, "Lock");
            selectAnim    = UIUtility.SafeGetComponent <Animation>(selectTrans);
            _nameText     = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Content/Name"));
            _timeText     = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Content/Time"));
            _icon         = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Content/Icon/BG/Image"));
            _techCost     = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Content/TechCost/Num"));
            _progressText = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Content/Progress/Value"));

            contentCanvasGroup = UIUtility.SafeGetComponent <CanvasGroup>(UIUtility.FindTransfrom(transform, "Content"));

            _rarityBG       = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Content/Icon/BG"));
            _rarityEffect01 = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Content/Icon/Select/SelectEffect/Image"));
            _rarityEffect02 = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Content/Icon/Select/SelectEffect2/Image"));
            _rarityEffect03 = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Content/Icon/Select/SelectEffect3/Image"));

            progressTrans  = UIUtility.FindTransfrom(transform, "Content/Progress");
            completeTrans  = UIUtility.FindTransfrom(transform, "Content/Complete");
            techCostTrans  = UIUtility.FindTransfrom(transform, "Content/TechCost");
            progressSlider = UIUtility.SafeGetComponent <Scrollbar>(UIUtility.FindTransfrom(progressTrans, "Scrollbar"));
        }
Esempio n. 8
0
        public void InitData(List <BaseDataModel> modelData)
        {
            _modelList = modelData;
            int totalNum = GetTotalItemNum();

            if (_content.childCount == totalNum)
            {
                return;
            }

            UIUtility.SafeGetComponent <ScrollRect>(transform).onValueChanged.RemoveAllListeners();
            foreach (Transform trans in _content)
            {
                ObjectManager.Instance.ReleaseObject(trans.gameObject, 0);
            }

            if (_modelList.Count < totalNum)
            {
                SpawnItem(_modelList.Count, ItemPrefabPath);
            }
            else
            {
                SpawnItem(totalNum, ItemPrefabPath);
            }
            SetContentSize();
            UIUtility.SafeGetComponent <ScrollRect>(transform).onValueChanged.AddListener(ValueChanged);
        }
Esempio n. 9
0
 void InitRefrence()
 {
     mainCanvas = UIUtility.SafeGetComponent <Canvas>(Utility.SafeFindGameobject("MainCanvas").transform);
     uiCamera   = UIUtility.SafeGetComponent <Camera>(Utility.SafeFindGameobject("MainCanvas/UICamera").transform);
     pickedItem = mainCanvas.transform.Find("SPContent/PickedDistrict").GetComponent <SlotItem>();
     _enterInfo = UIUtility.SafeGetComponent <BlockEnterInfo>(UIUtility.FindTransfrom(mainCanvas.transform, "SPContent/BlockEnterInfo"));
 }
Esempio n. 10
0
        public void SetData()
        {
            _blockBase      = UIUtility.SafeGetComponent <FunctionBlockBase>(transform);
            manufactoryInfo = new ManufactoryInfo(_blockBase.functionBlock);
            formulaInfo     = new ManufactFormulaInfo(_blockBase.functionBlock.FunctionBlockID);

            _blockBase.OnBlockSelectAction    += Onselect;
            _blockBase.OnBlockAreaEnterAction += OnBlockAreaEnter;
        }
Esempio n. 11
0
        public void SetData()
        {
            _blockBase = UIUtility.SafeGetComponent <FunctionBlockBase>(transform);
            _infoData  = new BlockNormalInfoData(_blockBase.info.BlockID);
            _blockBase.OnBlockSelectAction    += Onselect;
            _blockBase.OnBlockAreaEnterAction += OnBlockAreaEnter;

            _infoData.InitModifier(_blockBase);
        }
Esempio n. 12
0
 private void Awake()
 {
     foreach (Transform trans in transform)
     {
         var slider = UIUtility.SafeGetComponent <Slider>(trans);
         slider.value = 0;
         sliderList.Add(slider);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Try Get Selecet Block
        /// </summary>
        /// <param name="touch"></param>
        /// <returns></returns>
        private FunctionBlockBase TryGetRaycastHitBlock(Vector2 touch)
        {
            RaycastHit hit;

            if (TryGetRaycastHit(touch, out hit, RaycastTarget.FunctionBlock))
            {
                return(UIUtility.SafeGetComponent <FunctionBlockBase>(hit.collider.transform));
            }
            return(null);
        }
Esempio n. 14
0
 public override void Awake()
 {
     titleWaringTrans  = UIUtility.FindTransfrom(transform, "Title");
     rarityBG          = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "BG/Circle"));
     icon              = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "BG/Icon"));;
     nameText          = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Name"));
     lockIconTrans     = UIUtility.FindTransfrom(transform, "Name/Icon");
     SelectEffectTrans = UIUtility.FindTransfrom(transform, "Select");
     anim              = UIUtility.SafeGetComponent <Animation>(transform);
 }
Esempio n. 15
0
        public override void Awake()
        {
            _icon                 = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Content/Icon"));
            _typeIcon             = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "Content/Type/Icon"));
            _typeText             = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Content/Type/Text"));
            _propertyContentTrans = UIUtility.FindTransfrom(transform, "Content/Property/Content");
            _name                 = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Name"));

            _clickBtn   = UIUtility.SafeGetComponent <Button>(UIUtility.FindTransfrom(transform, "Content/BG"));
            _generalBtn = UIUtility.SafeGetComponent <Button>(UIUtility.FindTransfrom(transform, "Button/ButtonGeneral02/"));
            _btnText    = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(_generalBtn.transform, "Text"));
        }
Esempio n. 16
0
        private int GetTotalItemNum()
        {
            var scrollRect = UIUtility.SafeGetComponent <RectTransform>(transform).rect;

            var width           = scrollRect.width;
            int horizontalCount = Mathf.CeilToInt(width / (_itemWidth + sepConfig.HorizontalSep)) - 1;

            var height        = scrollRect.height;
            int verticalCount = Mathf.CeilToInt(height / (_itemHeight + sepConfig.VerticalSep)) + 1;

            return(horizontalCount * verticalCount);
        }
Esempio n. 17
0
        /// <summary>
        /// Refresh Count
        /// </summary>
        /// <param name="info"></param>
        public void RefreshFormulaSlotNum(ManufactFormulaInfo info)
        {
            _info = info;
            for (int i = 0; i < _info.currentInputItem.Count; i++)
            {
                var element = UIUtility.SafeGetComponent <ManuSlotElement>(InputContent.GetChild(i));
                element.RefreshCount(_info.currentInputItem[i].model, _info.realInputItem[i].count);
            }

            var outputElement = UIUtility.SafeGetComponent <ManuSlotElement>(Output_Trans);

            outputElement.RefreshCount(_info.currentOutputItem.model, _info.realOutputItem.count);
        }
Esempio n. 18
0
        public ManufactoryBase GetManuBlockBase(uint instanceID)
        {
            var obj = GetFunctionBlockObject(instanceID);

            if (obj != null)
            {
                var manuBase = UIUtility.SafeGetComponent <ManufactoryBase>(obj.transform);
                if (manuBase != null)
                {
                    return(manuBase);
                }
            }
            return(null);
        }
Esempio n. 19
0
        private void Awake()
        {
            _elementList = new List <BaseElement>();
            _modelList   = new List <BaseDataModel>();

            if (!string.IsNullOrEmpty(ItemPrefabPath))
            {
                _item       = ResourceManager.Instance.LoadResource <GameObject>("Assets/Prefabs/" + ItemPrefabPath + ".prefab");
                _itemHeight = UIUtility.SafeGetComponent <RectTransform>(_item.transform).rect.height;
                _itemWidth  = UIUtility.SafeGetComponent <RectTransform>(_item.transform).rect.width;
            }

            _content = UIUtility.SafeGetComponent <RectTransform>(transform.Find("Viewport/Content"));
        }
Esempio n. 20
0
        void SetUpPropertyItemSmall(Sprite icon, string name, float value, string propertyName)
        {
            var obj = ObjectManager.Instance.InstantiateObject(UIPath.PrefabPath.Assemble_Part_PropertyItemSmall);

            if (obj != null)
            {
                var cmpt = UIUtility.SafeGetComponent <AssemblePartPropertyItemSmall>(obj.transform);
                cmpt.SetUpItem(icon, name, value, propertyName);
                obj.transform.SetParent(contentTrans, false);
                if (!_propertyItemDic.ContainsKey(propertyName))
                {
                    _propertyItemDic.Add(propertyName, cmpt);
                }
            }
        }
Esempio n. 21
0
        private void SpawnItem(int num, string path)
        {
            GameObject  element    = null;
            BaseElement elementcpt = null;

            for (int i = 0; i < num; i++)
            {
                element = ObjectManager.Instance.InstantiateObject("Assets/Prefabs/" + path + ".prefab");
                element.transform.SetParent(_content, false);
                elementcpt = UIUtility.SafeGetComponent <BaseElement>(element.transform);
                /// Get  Data
                elementcpt.AddGetDataListener(GetData);
                elementcpt.InitGrid(i, num, GetHorizontalItemNum(), GetVerticalItemNum(), sepConfig, loopType);
                _elementList.Add(elementcpt);
            }
        }
Esempio n. 22
0
        void InitSubTag(MaterialType type)
        {
            var list = MaterialModule.GetMaterialSubTypeList(type);

            for (int i = 0; i < list.Count; i++)
            {
                var obj  = ObjectManager.Instance.InstantiateObject(UIPath.PrefabPath.WareHouse_Subtag_Prefab_Path);
                var cmpt = UIUtility.SafeGetComponent <WareHouseSubTagCmpt>(obj.transform);
                subTagHeight      = UIUtility.SafeGetComponent <RectTransform>(obj.transform).rect.height;
                cmpt.toggle.group = subToggleGroup;
                //Init Info
                cmpt.InitSubTag(list[i]);
                obj.transform.SetParent(SubTagContent.transform, false);
                subTagCmptList.Add(cmpt);
            }
        }
Esempio n. 23
0
 public void ShowSelectionUI(bool show)
 {
     if (show)
     {
         if (selectionUIInstance == null)
         {
             selectionUIInstance = UIUtility.SafeGetComponent <SelectionUIObject>(ShowUI(UIPath.Misc.Block_Selection_UI).transform);
         }
     }
     else
     {
         if (selectionUIInstance != null)
         {
             ObjectManager.Instance.ReleaseObject(selectionUIInstance.gameObject);
             selectionUIInstance = null;
         }
     }
 }
Esempio n. 24
0
        /// <summary>
        /// Init
        /// </summary>
        /// <param name="info"></param>
        private void InitFormulaSlot(InitType type)
        {
            ///Input
            for (int i = 0; i < _info.currentInputItem.Count; i++)
            {
                var element = UIUtility.SafeGetComponent <ManuSlotElement>(InputContent.GetChild(i));
                if (type == InitType.Normal)
                {
                    element.SetUpElement(_info.currentInputItem[i].model, _info.currentInputItem[i].count, _info.realInputItem[i].count);
                }
                else
                {
                    element.SetUpFormulaChangeElement(_info.currentInputItem[i].model, _info.currentInputItem[i].count);
                }
            }

            ///Enhance
            if (_info.currentEnhanceItem.model.ID != 0 && _info.currentEnhanceItem != null)
            {
                Enhance_Trans.gameObject.SetActive(true);
                var element = UIUtility.SafeGetComponent <ManuSlotElement>(Enhance_Trans);
                if (type == InitType.Normal)
                {
                    element.SetUpElement(_info.currentEnhanceItem.model, _info.currentEnhanceItem.count, _info.realEnhanceItem.count);
                }
                else
                {
                    element.SetUpFormulaChangeElement(_info.currentEnhanceItem.model, _info.currentEnhanceItem.count);
                }
            }

            ///OutPut
            var outputElement = UIUtility.SafeGetComponent <ManuSlotElement>(Output_Trans);

            if (type == InitType.Normal)
            {
                outputElement.SetUpElement(_info.currentOutputItem.model, _info.currentOutputItem.count, _info.realOutputItem.count);
            }
            else
            {
                outputElement.SetUpFormulaChangeElement(_info.currentOutputItem.model, _info.currentOutputItem.count);
            }
        }
Esempio n. 25
0
        public void InitSlot(FunctionBlockDistrictInfo info)
        {
            infoData = info;
            var count = info.size.x * info.size.y;

            foreach (KeyValuePair <Vector2, DistrictAreaInfo> kvp in info.currentDistrictDataDic)
            {
                var element      = ObjectManager.Instance.InstantiateObject(UIPath.PrefabPath.DISTRICT_PREFAB_PATH);
                var districtSlot = UIUtility.SafeGetComponent <DistrictSlot>(element.transform);
                if (districtSlot != null)
                {
                    _districtSlotList.Add(districtSlot);
                    districtSlot.InitBaseInfo(kvp.Value);
                    element.transform.SetParent(transform, false);
                    element.name = kvp.Key.ToString();
                }
                else
                {
                    break;
                }
            }
        }
Esempio n. 26
0
        void RefreshPartCost()
        {
            var _partCostTrans = transform.FindTransfrom("Content/PartCost/Content");

            _partCostTrans.SafeSetActiveAllChild(false);

            var costList = AssembleModule.GetPartMaterialCost(_model.ID);

            for (int i = 0; i < costList.Count; i++)
            {
                if (i > Config.GlobalConfigData.Assemble_MaterialCost_MaxNum)
                {
                    break;
                }
                var cmpt = UIUtility.SafeGetComponent <MaterialCostCmpt>(_partCostTrans.GetChild(i));
                if (cmpt != null)
                {
                    cmpt.SetUpItem(costList[i]);
                    cmpt.gameObject.SetActive(true);
                }
            }
        }
Esempio n. 27
0
        void RefreshMaterialCost()
        {
            var _materialCostTrans = transform.FindTransfrom("Content/PartCost/Content");

            _materialCostTrans.SafeSetActiveAllChild(false);

            var costList = _model.PresetInfo.shipCostBase;

            for (int i = 0; i < costList.Count; i++)
            {
                if (i > Config.GlobalConfigData.Assemble_MaterialCost_MaxNum)
                {
                    break;
                }
                var cmpt = UIUtility.SafeGetComponent <MaterialCostCmpt>(_materialCostTrans.GetChild(i));
                if (cmpt != null)
                {
                    cmpt.SetUpItem(costList[i]);
                    cmpt.gameObject.SetActive(true);
                }
            }

            transform.FindTransfrom("Content/PartCost/TimeCost/Text").SafeGetComponent <Text>().text = _model.PresetInfo._metaData.BaseTimeCost.ToString();
        }
Esempio n. 28
0
        void Start()
        {
            FunctionBlockBase blockBase = GetComponentInParent <FunctionBlockBase>();
            var maxSize = blockBase.info.districtInfo.size;

            ArrowRight  = UIUtility.FindTransfrom(transform, "ArrowObj/Right");
            ArrowLeft   = UIUtility.FindTransfrom(transform, "ArrowObj/Left");
            ArrowTop    = UIUtility.FindTransfrom(transform, "ArrowObj/Top");
            ArrowBottom = UIUtility.FindTransfrom(transform, "ArrowObj/Bottom");

            Grid              = UIUtility.SafeGetComponent <SpriteRenderer>(UIUtility.FindTransfrom(transform, "Grid"));
            CanPlaceSprite    = Utility.LoadSprite("SpriteOutput/Map/grid_green");
            CannotPlaceSprite = Utility.LoadSprite("SpriteOutput/Map/grid_red");

            ArrowRight.localPosition = new Vector3(ArrowRight.localPosition.x - (maxSize.y / 2), 0, ArrowRight.localPosition.z);
            ArrowLeft.localPosition  = new Vector3(ArrowLeft.localPosition.x + (maxSize.y / 2), 0, ArrowLeft.localPosition.z);

            ArrowTop.localPosition    = new Vector3(ArrowTop.localPosition.x, 0, ArrowTop.localPosition.z - (maxSize.x / 2));
            ArrowBottom.localPosition = new Vector3(ArrowBottom.localPosition.x, 0, ArrowBottom.localPosition.z + (maxSize.x / 2));

            Grid.size = maxSize;
            Grid.transform.localPosition = new Vector3(0, -transform.localScale.y / 2, 0);
            ShowGrid(false);
        }
Esempio n. 29
0
 private void Awake()
 {
     _name  = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Name"));
     _count = UIUtility.SafeGetComponent <Text>(UIUtility.FindTransfrom(transform, "Value"));
     _icon  = UIUtility.SafeGetComponent <Image>(UIUtility.FindTransfrom(transform, "BG/Icon"));
 }
Esempio n. 30
0
 void Start()
 {
     anim = UIUtility.SafeGetComponent <Animation>(transform);
 }