Exemplo n.º 1
0
 /// <summary>
 /// 任务需求中与NPC谈话内容,只有一句
 /// </summary>
 /// <param name="quest"></param>
 public void TalkInMission(Model_Quest.QuestNPC quest)
 {
     Complete.gameObject.SetActive(true);                               //显示完成按钮
     Accept.gameObject.SetActive(false);                                //隐藏接受按钮
     Abandon.gameObject.SetActive(false);                               //隐藏取消按钮
     questContent.text        = quest.questDialogueNpc[0];              //NPC说话内容
     QuestReleaseNpcText.text = GlobalParametr.GetNpcName(quest.npcId); //对话显示角色
 }
Exemplo n.º 2
0
    /// <summary>
    /// 初始化
    /// </summary>
    public void InitQuest()
    {
        questBriefIntroduction.text = quest.questBriefIntroduction;
        questSescribe.text          = quest.questSescribe;
        ClearQuestDemandAndReward();
        //击杀需求
        foreach (Model_Quest.QuestEnemy enemy in quest.questKillEnemy)
        {
            //没有击杀任务,跳过
            if (enemy.enemyNumber != 0)
            {
                GameObject MissionRequired = Resources.Load <GameObject>("Prefabs/UI/Quest/MissionRequired");
                View_QuestMissionRequired missionRequired =
                    MissionRequired.GetComponent <View_QuestMissionRequired>();
                missionRequired.CurrentCount.text = enemy.currentEnemyNumber.ToString();
                missionRequired.QuestCount.text   = enemy.enemyNumber.ToString();
                missionRequired.QuestName.text    = GlobalParametr.GetEnemyName(enemy.enemyId);
                missionRequired.HideMark();
                missionRequired.transform.localScale          = new Vector3(0.5f, 0.5f, 0.5f);
                Instantiate(MissionRequired).transform.parent = questDemandTransform;
            }
        }

        //对话内容
        foreach (Model_Quest.QuestNPC questNpc in quest.questTalkNPC)
        {
            if (questNpc.npcId != -1)
            {
                GameObject MissionRequired = Resources.Load <GameObject>("Prefabs/UI/Quest/MissionRequired");
                View_QuestMissionRequired missionRequired =
                    MissionRequired.GetComponent <View_QuestMissionRequired>();
                missionRequired.CurrentCount.text = questNpc.isTalk ? "1" : "0";
                missionRequired.QuestCount.text   = "1";
                missionRequired.QuestName.text    = GlobalParametr.GetNpcName(questNpc.npcId);
                missionRequired.ShowMark();
                missionRequired.transform.localScale          = new Vector3(0.5f, 0.5f, 0.5f);
                Instantiate(MissionRequired).transform.parent = questDemandTransform;
            }
        }

        //物品需求
        foreach (Model_Quest.QuestItem questItem in quest.questItem)
        {
            if (questItem.itemId != -1)
            {
                GameObject MissionRequired = Resources.Load <GameObject>("Prefabs/UI/Quest/MissionRequired");
                View_QuestMissionRequired missionRequired =
                    MissionRequired.GetComponent <View_QuestMissionRequired>();
                missionRequired.CurrentCount.text = Ctrl_InventoryManager.Instance
                                                    .GetItemCount(questItem.itemId).ToString();
                missionRequired.QuestCount.text = questItem.itemNumber.ToString();
                missionRequired.QuestName.text  = Ctrl_InventoryManager.Instance.GetItemById(questItem.itemId).itemName;
                missionRequired.HideMark();
                missionRequired.transform.localScale          = new Vector3(0.5f, 0.5f, 0.5f);
                Instantiate(MissionRequired).transform.parent = questDemandTransform;
            }
        }

        #region 任务奖励

        if (quest.questReward.gold > 0)
        {
            GameObject QuestRewardSlot = Resources.Load <GameObject>("Prefabs/UI/Quest/QuestRewardSlot");
            QuestRewardSlot.GetComponent <Ctrl_QuestRewardSlot>().ShowGoldView(quest.questReward.gold);
            QuestRewardSlot.transform.localScale          = new Vector3(0.5f, 0.5f, 0.5f);
            Instantiate(QuestRewardSlot).transform.parent = questRewardTransform;
        }

        if (quest.questReward.diamod > 0)
        {
            GameObject QuestRewardSlot = Resources.Load <GameObject>("Prefabs/UI/Quest/QuestRewardSlot");
            QuestRewardSlot.GetComponent <Ctrl_QuestRewardSlot>().ShowDiamodView(quest.questReward.diamod);
            QuestRewardSlot.transform.localScale          = new Vector3(0.5f, 0.5f, 0.5f);
            Instantiate(QuestRewardSlot).transform.parent = questRewardTransform;
        }

        if (quest.questReward.exp > 0)
        {
            GameObject QuestRewardSlot = Resources.Load <GameObject>("Prefabs/UI/Quest/QuestRewardSlot");
            QuestRewardSlot.GetComponent <Ctrl_QuestRewardSlot>().ShowExpView(quest.questReward.exp);
            QuestRewardSlot.transform.localScale          = new Vector3(0.5f, 0.5f, 0.5f);
            Instantiate(QuestRewardSlot).transform.parent = questRewardTransform;
        }

        if (quest.questReward.questRewardItem.Length >= 1)
        {
            foreach (Model_Quest.QuestItem item in quest.questReward.questRewardItem)
            {
                GameObject QuestRewardSlot = Resources.Load <GameObject>("Prefabs/UI/Quest/QuestRewardSlot");
                QuestRewardSlot = Instantiate(QuestRewardSlot);
                QuestRewardSlot.GetComponent <Ctrl_QuestRewardSlot>().Item =
                    Ctrl_InventoryManager.Instance.GetItemById(item.itemId);
                QuestRewardSlot.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
                QuestRewardSlot.transform.parent     = questRewardTransform;
            }
        }

        if (Quest.questState)
        {
            overQuest.SetActive(true);
        }
        else
        {
            overQuest.SetActive(false);
        }

        #endregion
    }