Ejemplo n.º 1
0
        private void HandleTechCompleteEvent(int techID)
        {
            var effect = TechnologyModule.Instance.GetTechCompleteEffect(techID);

            for (int i = 0; i < effect.Count; i++)
            {
                var type = TechnologyModule.Instance.GetTechCompleteType(effect[i]);
                switch (type)
                {
                case TechCompleteEffect.Unlock_Tech:
                    var techList = TechnologyModule.ParseTechParam_Unlock_Tech(effect[i].effectParam);
                    for (int j = 0; j < techList.Count; j++)
                    {
                        var info = GetTechInfo(techList[j]);
                        info.currentState = TechnologyState.Unlock;
                    }
                    break;

                case TechCompleteEffect.Unlock_Block:
                    var blockList = TechnologyModule.ParseTechParam_Unlock_Block(effect[i].effectParam);
                    for (int j = 0; j < blockList.Count; j++)
                    {
                        var buildData = PlayerModule.GetBuildingPanelDataByKey(blockList[j]);
                        if (buildData != null)
                        {
                            PlayerManager.Instance.AddUnLockBuildData(buildData);
                        }
                    }
                    break;

                case TechCompleteEffect.Unlock_Assemble_Part_Preset:
                    var partList = TechnologyModule.ParseTechParam_Unlock_Assemble_Part(effect[i].effectParam);
                    for (int j = 0; j < partList.Count; j++)
                    {
                        PlayerManager.Instance.AddUnlockAssemblePartID(partList[j]);
                    }
                    break;

                case TechCompleteEffect.Unlock_Assemble_Ship_Preset:
                    var shipList = TechnologyModule.ParseTechParam_Unlock_Assemble_Ship(effect[i].effectParam);
                    for (int j = 0; j < shipList.Count; j++)
                    {
                        PlayerManager.Instance.AddUnlockAssembleShipID(shipList[j]);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 检查研究前置条件
        /// </summary>
        /// <param name="techID"></param>
        /// <returns></returns>
        public bool CheckTechCanResearch(int techID)
        {
            bool canResearch = true;

            var requireList = TechnologyModule.Instance.GetTechRequireList(techID);

            for (int i = 0; i < requireList.Count; i++)
            {
                var type = TechnologyModule.Instance.GetTechRequireType(requireList[i]);
                switch (type)
                {
                case TechRequireType.PreTech:
                    var techList = TechnologyModule.ParseTechParam_Unlock_Tech(requireList[i].Param);
                    for (int j = 0; j < techList.Count; j++)
                    {
                        var info = GetTechInfo(techList[j]);
                        if (info.currentState == TechnologyState.Lock)
                        {
                            canResearch = false;
                        }
                    }
                    continue;

                case TechRequireType.Material:
                    var materialDic = TechnologyModule.parseTechParam_Require_Material(requireList[i].Param);
                    foreach (KeyValuePair <int, int> kvp in materialDic)
                    {
                        if (PlayerManager.Instance.GetMaterialStoreCount(kvp.Key) < kvp.Value)
                        {
                            canResearch = false;
                        }
                    }
                    continue;
                }
            }

            return(canResearch);
        }