예제 #1
0
        public bool CanLevelUp(SkillItem skillItem)
        {
            ItemDTO reduceDTO = GetSkillUpdateItem();

            if (reduceDTO == null)
            {
                return(false);
            }
            int       level       = GetSkillLevel(skillItem.id);
            SkillItem skillConfig = Global.gApp.gGameData.SkillData.Get(skillItem.id);

            Skill_dataItem levelData = Global.gApp.gGameData.SkillDataConfig.Get(level + 1);

            float[] param = null;
            try
            {
                param = ReflectionUtil.GetValueByProperty <Skill_dataItem, float[]>(skillItem.id, levelData);
            }
            catch (Exception e)
            {
                Debug.LogError(skillItem.id + "在等级表中不存在");
            }

            return(skillConfig.weight > 0 && param != null && param.Length > 0 && GameItemFactory.GetInstance().GetItem(reduceDTO.itemId) >= reduceDTO.num);
        }
예제 #2
0
        public void AfterInit()
        {
            int step = 0;

            if (m_Data.curStepFinished)
            {
                foreach (CampStepItem config in Global.gApp.gGameData.CampStepConfig.items)
                {
                    if (step <= m_Data.curStep && config.brageId > 0)
                    {
                        if (GameItemFactory.GetInstance().GetItem(config.brageId) == 0)
                        {
                            ItemDTO itemDTO = new ItemDTO(config.brageId, 1, BehaviorTypeConstVal.OPT_CAMP_GENBADGE);
                            GameItemFactory.GetInstance().AddItem(itemDTO);
                        }
                    }
                    step++;
                }
            }
            else
            {
                foreach (CampStepItem config in Global.gApp.gGameData.CampStepConfig.items)
                {
                    if (step < m_Data.curStep && config.brageId > 0)
                    {
                        if (GameItemFactory.GetInstance().GetItem(config.brageId) == 0)
                        {
                            ItemDTO itemDTO = new ItemDTO(config.brageId, 1, BehaviorTypeConstVal.OPT_CAMP_GENBADGE);
                            GameItemFactory.GetInstance().AddItem(itemDTO);
                        }
                    }
                    step++;
                }
            }
        }
예제 #3
0
        public bool ReceiveQuest(int questId, int times, int behaviorType, Vector3 position)
        {
            QuestItemDTO data = GetQuestItemDTO(questId);

            if (data.state != QuestStateConstVal.CAN_RECEIVE)
            {
                Global.gApp.gMsgDispatcher.Broadcast <int>(MsgIds.ShowGameTipsByID, 3036);
                return(false);
            }
            QuestItem config  = Global.gApp.gGameData.QuestData.Get(questId);
            ItemDTO   itemDTO = new ItemDTO(Convert.ToInt32(config.award[0]), config.award[1] * times, behaviorType);

            itemDTO.paramStr1 = questId.ToString();
            itemDTO.paramStr2 = times.ToString();
            ItemItem awardCfg = Global.gApp.gGameData.ItemData.Get(itemDTO.itemId);

            //无法播放特效的不播
            if (ItemTypeConstVal.isWeapon(awardCfg.showtype))
            {
                return(ReceiveQuest(questId, times, behaviorType));
            }

            data.state = QuestStateConstVal.RECEIVED;
            //发送奖励

            //Global.gApp.gMsgDispatcher.Broadcast<float>(MsgIds.GainDelayShow, 1.8f);
            Global.gApp.gMsgDispatcher.Broadcast <int, int, Vector3>(MsgIds.ShowRewardGetEffect, itemDTO.itemId, (int)itemDTO.num, position);
            GameItemFactory.GetInstance().AddItem(itemDTO);

            SaveData();
            return(true);
        }
예제 #4
0
        public bool NotHaveShowTimeGift(string key)
        {
            GeneralConfigItem timeGift1Cfg = Global.gApp.gGameData.GeneralConfigData.Get(key);

            string[] timeGift1Prm  = timeGift1Cfg.content.Split('.');
            ItemItem timeGift1Item = Global.gApp.gGameData.ItemData.Get(int.Parse(timeGift1Prm[2]));

            if (ItemTypeConstVal.isWeapon(timeGift1Item.showtype))
            {
                return(GameItemFactory.GetInstance().GetItem(timeGift1Item.id) == 0d);
            }
            else
            {
                int times1 = 0;
                Global.gApp.gSystemMgr.GetMiscMgr().PurchaseTimesDic.TryGetValue(Global.gApp.gGameData.GeneralConfigData.Get(key).content, out times1);

                return(times1 == 0);
            }
        }
예제 #5
0
        //检查武器状态是否可以升级
        public bool CanUpdateWeapon(ItemItem itemConfig)
        {
            GetWeaponOpenState(itemConfig);
            int level     = GetWeaponLevel(itemConfig.name);
            int state     = GetWeaponOpenState(itemConfig.name);
            int errorCode = itemConfig.showtype == ItemTypeConstVal.BASE_MAIN_WEAPON ? CanLevelUp(itemConfig.name) : CanLevelUpSub(itemConfig.name);

            //未到可升级等级
            if (errorCode > 0)
            {
                return(false);
            }

            double[] costValue = itemConfig.showtype == ItemTypeConstVal.BASE_MAIN_WEAPON ? ReflectionUtil.GetValueByProperty <Guns_dataItem, double[]>(itemConfig.name + "_cost", Global.gApp.gGameData.GunDataConfig.Get(level))
                : ReflectionUtil.GetValueByProperty <GunsSub_dataItem, double[]>("base_cost_" + itemConfig.qualevel, Global.gApp.gGameData.GunSubDataConfig.Get(level));
            if (GameItemFactory.GetInstance().GetItem((int)costValue[0]) < costValue[1])
            {
                return(false);
            }
            return(true);
        }
예제 #6
0
        public bool ReceiveQuest(int questId, int times, int behaviorType)
        {
            QuestItemDTO data = GetQuestItemDTO(questId);

            if (data.state != QuestStateConstVal.CAN_RECEIVE)
            {
                Global.gApp.gMsgDispatcher.Broadcast <int>(MsgIds.ShowGameTipsByID, 3036);
                return(false);
            }
            data.state = QuestStateConstVal.RECEIVED;
            //发送奖励
            QuestItem config  = Global.gApp.gGameData.QuestData.Get(questId);
            ItemDTO   itemDTO = new ItemDTO(Convert.ToInt32(config.award[0]), config.award[1] * times, behaviorType);

            itemDTO.paramStr1 = questId.ToString();
            itemDTO.paramStr2 = times.ToString();
            GameItemFactory.GetInstance().AddItem(itemDTO);

            SaveData();
            return(true);
        }
예제 #7
0
        public void UpdateQualityLv(ItemItem itemConfig, Action <int> resultCallBack)
        {
            WeaponItemDTO itemDTO;

            if (m_Data.weaponMap.TryGetValue(itemConfig.name, out itemDTO))
            {
                if (itemDTO.qualityLv == 0)
                {
                    bool isSucess = true;
                    for (int i = 0; i < 2; i++)
                    {
                        float[] condition = new float[]
                        {
                            itemConfig.supercondition[0],
                            itemConfig.supercondition[i * 2 + 1],
                            itemConfig.supercondition[i * 2 + 2],
                        };
                        isSucess = isSucess && FilterFactory.GetInstance().Filter(condition);
                        if (!isSucess)
                        {
                            ItemItem reduceCfg = Global.gApp.gGameData.ItemData.Get(Convert.ToInt32(condition[1]));
                            Global.gApp.gMsgDispatcher.Broadcast <int, string>(MsgIds.ShowGameTipsByIDAndParam, 1008, Global.gApp.gGameData.GetTipsInCurLanguage(reduceCfg.sourceLanguage));
                            break;
                        }
                    }
                    if (isSucess)
                    {
                        ItemDTO reduceItemDTO = new ItemDTO(Convert.ToInt32(itemConfig.supercondition[1]), itemConfig.supercondition[2], BehaviorTypeConstVal.OPT_CAMP_UPGRADE_QUALITY);
                        reduceItemDTO.paramStr1 = itemConfig.name;
                        reduceItemDTO.paramStr2 = itemDTO.qualityLv.ToString();
                        GameItemFactory.GetInstance().ReduceItem(reduceItemDTO);
                        if (reduceItemDTO.result)
                        {
                            ItemDTO reduceItemDTO2 = new ItemDTO(Convert.ToInt32(itemConfig.supercondition[3]), itemConfig.supercondition[4], BehaviorTypeConstVal.OPT_CAMP_UPGRADE_QUALITY);
                            reduceItemDTO2.paramStr1 = itemConfig.name;
                            reduceItemDTO.paramStr2  = itemDTO.qualityLv.ToString();
                            GameItemFactory.GetInstance().ReduceItem(reduceItemDTO2);
                            if (reduceItemDTO2.result)
                            {
                                itemDTO.qualityLv++;
                                SaveData();
                                resultCallBack(0);
                            }
                            else
                            {
                                resultCallBack(1008);
                            }
                        }
                        else
                        {
                            resultCallBack(1008);
                        }
                    }
                    else
                    {
                        resultCallBack(1008);
                    }
                }
                else
                {
                    resultCallBack(1008);
                }
            }
            else
            {
                resultCallBack(1008);
            }
        }