Ejemplo n.º 1
0
 public bool Create(int id)
 {
     if (TechnologyModule.GetTechDataByID(id) != null)
     {
         _id = id;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
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.º 3
0
 public void SetUpItem(GeneralRewardItem item)
 {
     _item = item;
     if (item.type == GeneralRewardItem.RewardType.Material)
     {
         if (MaterialModule.GetMaterialByMaterialID(item.ItemID) != null)
         {
             var icon = MaterialModule.GetMaterialSprite(item.ItemID);
             _icon.sprite = icon;
             _count.text  = item.count.ToString();
         }
     }
     else if (item.type == GeneralRewardItem.RewardType.Tech_Unlock)
     {
         if (TechnologyModule.GetTechDataByID(item.ItemID) != null)
         {
             var icon = TechnologyModule.GetTechIcon(item.ItemID);
             _icon.sprite = icon;
         }
     }
 }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 事件触发前置
        /// </summary>
        /// <param name="eventID"></param>
        /// <returns></returns>
        public static bool CheckEventTrigger(int eventID)
        {
            var playerData = GetExploreEventConfigData(eventID).trigger.player;
            ///Check GlobalFlag
            var trigger = GetExploreEventGlobalFlag(eventID);

            if (trigger != null)
            {
                foreach (KeyValuePair <string, bool> kvp in trigger)
                {
                    if (!GlobalEventManager.Instance.CheckGlobalFlagExist(kvp.Key) == kvp.Value)
                    {
                        return(false);
                    }
                }
            }
            ///Currency
            if (playerData != null)
            {
                if (!string.IsNullOrEmpty(playerData.CurrencyCompare))
                {
                    if (!Utility.ParseGeneralCompare(playerData.CurrencyValue, playerData.CurrencyCompare))
                    {
                        return(false);
                    }
                }
                if (playerData.Material != null)
                {
                    foreach (KeyValuePair <string, string> kvp in playerData.Material)
                    {
                        int materialID = Utility.TryParseInt(kvp.Key);
                        if (MaterialModule.GetMaterialByMaterialID(materialID) != null)
                        {
                            if (!Utility.ParseGeneralCompare(PlayerManager.Instance.GetMaterialStoreCount(materialID), kvp.Value))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (playerData.Technology != null)
                {
                    foreach (KeyValuePair <string, string> kvp in playerData.Technology)
                    {
                        int techID = Utility.TryParseInt(kvp.Value);
                        if (TechnologyModule.GetTechDataByID(techID) != null)
                        {
                            var techData = TechnologyDataManager.Instance.GetTechInfo(techID);
                            if (techData != null)
                            {
                                if (string.Compare(kvp.Value, "Complete") == 0)
                                {
                                    if (techData.currentState != TechnologyState.Done)
                                    {
                                        return(false);
                                    }
                                }
                                else if (string.Compare(kvp.Value, "Lock") == 0)
                                {
                                    if (techData.currentState != TechnologyState.Lock)
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    Debug.LogError("ExploreEvent Tech Format Error! EventID=" + eventID);
                                }
                            }
                        }
                    }
                }
            }
            /// CheckPre Event
            var preList = GetExploreEventConfigData(eventID).trigger.PreEvent;

            if (preList != null)
            {
                for (int i = 0; i < preList.Count; i++)
                {
                    if (ExploreEventManager.Instance.CheckRandomEventFinish(eventID) == false)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }