Example #1
0
        public bool InitGroup(int index)
        {
            groupIndex = index;
            var config = TechnologyModule.Instance.GetTechGroupConfig(index);
            if (config != null)
            {
                for(int i = 0; i < config.ObjectNum; i++)
                {
                    var element = config.techElementList[i];
                    GameObject obj = ObjectManager.Instance.InstantiateObject(GetElementTypePrefabPath(element));
                    obj.name = "TechObject" + element.Index.ToString();
                    ///Set Pos
                    Vector3 newPos = new Vector3(element.posX, element.posY,0);
                    obj.transform.SetParent(transform, false);
                    var rect = obj.transform.SafeGetComponent<RectTransform>().anchoredPosition = newPos;

                    TechObjectElement objEle = obj.transform.SafeGetComponent<TechObjectElement>();
                    if (objEle != null)
                    {
                        _techObjList.Add(objEle);
                        TechnologyDataModel model = new TechnologyDataModel();
                        if (!model.Create(element.TechID))
                        {
                            return false;
                        }
                        objEle.SetUpTech(model);
                    }
                }
            }
            return true;
        }
Example #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="model"></param>
        public void SetUpTech(TechnologyDataModel model)
        {
            if (model.ID == 0)
            {
                return;
            }
            _dataModel      = model;
            _nameText.text  = _dataModel.Name;
            _nameText.color = _dataModel.Rarity.color;
            _techCost.text  = _dataModel.TechCost.ToString();
            _icon.sprite    = _dataModel.Icon;

            if (TechnologyDataManager.Instance.GetTechInfo(_dataModel.ID).currentState == TechnologyState.Lock)
            {
                SetLockStates(true);
            }

            InitRarity();
            AddBtnClickListener();
        }
Example #3
0
        public void SetUpElement(RequireType type, object[] param, bool showWarning)
        {
            this.type = type;
            if (type == RequireType.Material)
            {
                int materialID            = (int)param[0];
                int count                 = (int)param[1];
                MaterialDataModel maModel = new MaterialDataModel();
                if (maModel.Create(materialID))
                {
                    _model = maModel;
                    SetElementInfo(maModel.Icon, maModel.Name + " X" + count, maModel.Rarity.color);
                    ShowLockWaring(showWarning);
                }
            }
            else if (type == RequireType.PreTech)
            {
                int techID = (int)param[0];
                TechnologyDataModel techModel = new TechnologyDataModel();
                if (techModel.Create(techID))
                {
                    _model = techModel;
                    SetElementInfo(techModel.Icon, techModel.Name, techModel.Rarity.color);
                    ShowLockWaring(showWarning);
                }
            }
            else if (type == RequireType.ResearchPoint)
            {
                ushort count          = (ushort)param[0];
                var    techPointImage = Utility.LoadSprite("SpriteOutput/UI/Main/Technology/TechPage_PointCost_Icon");
                string text           = MultiLanguage.Instance.GetTextValue(Research_Require_TechPoint_Text) + ":" + count.ToString();
                SetElementInfo(techPointImage, text, Color.white);
                ShowLockWaring(showWarning);
            }

            if (anim != null)
            {
                anim.Play();
            }
        }
Example #4
0
        public TechnologyInfo(int techID)
        {
            _model = new TechnologyDataModel();
            if (!_model.Create(techID))
            {
                return;
            }
            this.techID = techID;
            baseType    = TechnologyModule.GetTechBaseType(techID);

            techRequireList      = TechnologyModule.Instance.GetTechRequireList(techID);
            techFinishEffectList = TechnologyModule.Instance.GetTechCompleteEffect(techID);

            if (TechnologyModule.GetTechDataByID(techID).Unlock)
            {
                currentState = TechnologyState.Unlock;
            }
            else
            {
                currentState = TechnologyState.Lock;
            }
        }