void SetData(int missionId)
    {
        mMissionId = missionId;
        // 任务基本
        Tab_MissionBase mission = TableManager.GetMissionBaseByID(mMissionId, 0);

        if (mission == null)
        {
            Debug.LogError("No MissionBase Error, id = " + mMissionId);
            return;
        }

        // 任务字典
        Tab_MissionDictionary missionDic = TableManager.GetMissionDictionaryByID(mMissionId, 0);

        if (missionDic == null)
        {
            Debug.LogError("No MissionDictionary Error, id = " + mMissionId);
            return;
        }
        lblMissionName.text = string.Format(missionDic.MissionName, "", "");
        lblMissionDesc.text = StrDictionary.GetClientString_WithNameSex(missionDic.MissionDesc);

        // 任务奖励
        Utils.CleanGrid(rewardList);
        Tab_MissionBonus missionBonus = TableManager.GetMissionBonusByID(mission.BonusID, 0);

        if (missionBonus == null)
        {
            Debug.LogError("No Tab_MissionBonus Error, mission id = " + mMissionId + ", bonus id = " + mission.BonusID);
            return;
        }
        // 经验
        if (missionBonus.Exp > 0)
        {
            AddRewardItem(ItemType.ITEM_EXP, -1, missionBonus.Exp);
        }
        // 金币
        if (missionBonus.Money > 0)
        {
            AddRewardItem(ItemType.ITEM_MONEY, -1, missionBonus.Money);
        }
        // 绑定元宝
        if (missionBonus.BindYuanBao > 0)
        {
            AddRewardItem(ItemType.ITEM_YUANBAO, -1, missionBonus.BindYuanBao);
        }
        // 物品
        for (int i = 0; i < missionBonus.getToolIDCount(); i++)
        {
            int itemId    = missionBonus.GetToolIDbyIndex(i);
            int itemCount = missionBonus.GetToolNumbyIndex(i);
            if (itemCount <= 0)
            {
                continue;
            }
            AddRewardItem(ItemType.ITEM_ITEM, itemId, itemCount);
        }
        // 职业奖励
        int nProfess = Singleton <ObjManager> .GetInstance().MainPlayer.Profession;

        if (nProfess >= 0 && nProfess < missionBonus.getProfessionItemIDCount())
        {
            AddRewardItem(ItemType.ITEM_ITEM, missionBonus.GetProfessionItemIDbyIndex(nProfess), missionBonus.GetProfessionNumbyIndex(nProfess));
        }
        // 多选物品
        int nChoosedItemdNum = missionBonus.ChoosedItemNum;

        if (nChoosedItemdNum > 0 && nChoosedItemdNum <= missionBonus.getItemIDCount())
        {
            AddRewardItem(ItemType.ITEM_ITEM, missionBonus.GetItemIDbyIndex(nChoosedItemdNum - 1), missionBonus.GetItemNumbyIndex(nChoosedItemdNum - 1));
        }
        rewardList.GetComponent <UIGrid>().Reposition();
    }
Esempio n. 2
0
    // 接任务和交任务UI
    public void MissionUI(int nMissionID, MissionUIType type)
    {
        // 先清理
        CleanUp();

        if (nMissionID < 0)
        {
            LogModule.ErrorLog("MissionID: {0} can not less then 0", nMissionID);
            return;
        }
        m_CurMissionID = nMissionID;
        Tab_MissionDictionary MDLine = TableManager.GetMissionDictionaryByID(nMissionID, 0);

        if (MDLine == null)
        {
            LogModule.ErrorLog("Can not find MissionDictionary {0}", nMissionID);
            return;
        }

        m_MissionType = type;
        if (type == MissionUIType.TYPE_ACCETP)
        {
            m_AcceptButton.SetActive(true);
            m_CompleteButton.SetActive(false);
            m_MissionInfoAward.SetActive(true);

            StoryDialogLogic.ShowMissionStory(StrDictionary.GetClientString_WithNameSex(MDLine.MissionDesc), false, false);

            m_CurTalkID = MDLine.AcceptTalkID;
            GameManager.gameManager.SoundManager.PlaySoundEffect(m_CurTalkID);
        }
        else if (type == MissionUIType.TYPE_COMPLETE)
        {
            m_AcceptButton.SetActive(false);
            m_CompleteButton.SetActive(true);
            m_MissionInfoAward.SetActive(true);

            StoryDialogLogic.ShowMissionStory(StrDictionary.GetClientString_WithNameSex(MDLine.MissionDoneDesc), false, false);
        }

        Tab_MissionBase misLine = TableManager.GetMissionBaseByID(nMissionID, 0);

        if (misLine == null)
        {
            LogModule.ErrorLog("Can not find missionBase {0}", nMissionID);
            return;
        }

        if (misLine.MissionType == (int)MISSIONTYPE.MISSION_BRANCH && type == MissionUIType.TYPE_ACCETP)
        {
            m_NoAcceptButton.SetActive(true);
        }
        else
        {
            m_NoAcceptButton.SetActive(false);
        }

        if (misLine.BonusID > -1)
        {
            //显示奖励内容
            Tab_MissionBonus bonusTab = TableManager.GetMissionBonusByID(misLine.BonusID, 0);
            if (bonusTab == null)
            {
                LogModule.ErrorLog("Can not find missionBonus {0}", misLine.BonusID);
            }
            else
            {
                // 最多一共7个奖励 按顺序显示 物品(最多4个) 玩家经验 宠物经验 金钱

                int currentAwardItemIdx = 0;

                // 物品
                if (bonusTab.getToolIDCount() > 0)
                {
                    for (int i = 0; i < bonusTab.getToolIDCount(); i++)
                    {
                        Tab_CommonItem commonItem = TableManager.GetCommonItemByID(bonusTab.GetToolIDbyIndex(i), 0);
                        if (commonItem != null && bonusTab.GetToolNumbyIndex(i) > 0 && currentAwardItemIdx < m_MissionBonusItemSlot.Length)
                        {
                            int nItemCount = bonusTab.GetToolNumbyIndex(i);
                            m_MissionBonusItemSlot[currentAwardItemIdx].gameObject.SetActive(true);
                            m_MissionBonusItemSlot[currentAwardItemIdx].InitInfo_Item(commonItem.Id, ItemSlotLogic.OnClickOpenTips, nItemCount > 1 ? nItemCount.ToString() : "", nItemCount > 1);
                            currentAwardItemIdx += 1;
                        }
                    }
                }

                // 玩家经验
                if (bonusTab.Exp > 0 && currentAwardItemIdx < m_MissionBonusItemSlot.Length)
                {
                    m_MissionBonusItemSlot[currentAwardItemIdx].gameObject.SetActive(true);
                    m_MissionBonusItemSlot[currentAwardItemIdx].InitInfo_PlayerExp(bonusTab.Exp.ToString());
                    currentAwardItemIdx += 1;
                }

                // 宠物经验
                if (bonusTab.FellowExp > 0 && currentAwardItemIdx < m_MissionBonusItemSlot.Length)
                {
                    m_MissionBonusItemSlot[currentAwardItemIdx].gameObject.SetActive(true);
                    m_MissionBonusItemSlot[currentAwardItemIdx].InitInfo_FellowExp(bonusTab.FellowExp.ToString());
                    currentAwardItemIdx += 1;
                }

                // 金钱 金币和绑定点券 一般不会共存
                if (bonusTab.Money > 0 && currentAwardItemIdx < m_MissionBonusItemSlot.Length)
                {
                    m_MissionBonusItemSlot[currentAwardItemIdx].gameObject.SetActive(true);
                    m_MissionBonusItemSlot[currentAwardItemIdx].InitInfo_Coin(null, bonusTab.Money.ToString(), true);
                    currentAwardItemIdx += 1;
                }
                if (bonusTab.BindYuanBao > 0 && currentAwardItemIdx < m_MissionBonusItemSlot.Length)
                {
                    m_MissionBonusItemSlot[currentAwardItemIdx].gameObject.SetActive(true);
                    m_MissionBonusItemSlot[currentAwardItemIdx].InitInfo_YuanbaoBind(null, bonusTab.BindYuanBao.ToString(), true);
                    currentAwardItemIdx += 1;
                }

                if (m_MissionItemGrid)
                {
                    m_MissionItemGrid.Reposition();
                }
            }
        }

        GameManager.gameManager.SoundManager.PlaySoundEffect(128);
#if BOBJOYSTICK
        RefreshJoyGUI(type);
#endif
    }