/// <summary>
        /// 显示npc主界面
        /// </summary>
        private void ShowMainNpcView()
        {
            mainNPCView.gameObject.SetActive(true);
            int randomSeed = Random.Range(0, npc.regularGreetings.Count);

            HLHDialog greeting = npc.regularGreetings[randomSeed];

            dialogText.text = greeting.dialogContent;
        }
        // 初始化npc界面
        public void SetUpNPCView(HLHNPC npc)
        {
            this.npc = npc;

            npcName.text = npc.npcName;

            // 随机npc的问候语序号
            int randomSeed = Random.Range(0, npc.regularGreetings.Count);

            // 获取npc的问候语
            HLHDialog greeting = npc.regularGreetings[randomSeed];

            dialogText.text = greeting.dialogContent;

            // npc交互主界面上的选项卡先全都放入缓存池
            choiceButtonPool.AddChildInstancesToPool(choiceButtonContainer);

            // 有交谈功能的话添加一个交谈选项卡
            if (npc.isChatTriggered)
            {
                AddChoice("交谈", SetUpDialogPlane);
            }
            // 有交易功能的话添加一个交易选项卡
            if (npc.isTradeTriggered)
            {
                AddChoice("交易", SetUpTrade);
            }
            // 有传送功能的话添加一个传送选项卡
            if (npc.isTransportTriggered)
            {
                AddChoice("传送", SetUpTransportLevelSelectView);
            }
            // 有学习技能功能的话添加一个学习技能选项卡
            if (npc.isLearnSkillTriggered)
            {
                AddChoice("学习技能", SetupSkillLearningPlane);
            }
            // 有镶嵌宝石功能的话添加一个镶嵌宝石选项卡
            if (npc.isAddGemStoneTriggered)
            {
                AddChoice("镶嵌宝石", SetUpSpecialOperation);
            }

            // 添加离开选项卡
            AddChoice("离开", QuitNPCPlane);

            // 显示探索场景顶部遮罩【由于npc画布高于探索画布,且正常显示范围在顶部bar以下,所以只在npc画布上设置遮罩会导致探索界面中顶部有部分区域是高亮的】
            ExploreManager.Instance.expUICtr.ShowTopBarMask();


            GetComponent <Canvas>().enabled = true;

            mainNPCView.gameObject.SetActive(true);
        }
Exemplo n.º 3
0
        private void DrawGreeting(HLHDialog dialog)
        {
            dialog.dialogId = 0;


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("\t\t\t\t\t", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(20)
            });
            EditorGUILayout.BeginVertical();

            EditorGUILayout.LabelField("对话ID", dialog.dialogId.ToString(), shortLayouts);

            dialog.dialogContent = EditorGUILayout.TextField("对话内容", dialog.dialogContent, longLayouts);


            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("================================================================", seperatorLayouts);
        }
Exemplo n.º 4
0
        public void NextDialog()
        {
            if (dialogHasFinished)
            {
                return;
            }

            int nextDialogId = ++currentDialogId;

            if (nextDialogId < dialogGroup.dialogs.Count)
            {
                HLHDialog dialog = dialogGroup.dialogs[nextDialogId];

                dialogText.text = dialog.dialogContent;

                return;
            }

            if (dialogGroup.isRewardTriggered)
            {
                HLHNPCReward reward = dialogGroup.reward;

                switch (reward.rewardType)
                {
                case HLHRewardType.Gold:
                    int goldReward = reward.rewardValue;
                    Player.mainPlayer.totalGold += goldReward;
                    tintHUD.SetUpGoldTintHUD(goldReward);
                    break;

                case HLHRewardType.Item:
                    Item rewardItem = Item.NewItemWith(reward.rewardValue, reward.attachValue);

                    if (rewardItem.itemType == ItemType.Equipment)
                    {
                        Equipment equipment = rewardItem as Equipment;

                        if (equipment.defaultQuality.Equals(EquipmentDefaultQuality.Random))
                        {
                            equipment.ResetPropertiesByQuality(EquipmentQuality.Gray);
                        }
                    }

                    ExploreManager.Instance.newMapGenerator.SetUpRewardInMap(rewardItem, ExploreManager.Instance.battlePlayerCtr.transform.position);

                    if (!Player.mainPlayer.CheckBagFull(rewardItem))
                    {
                        Player.mainPlayer.AddItem(rewardItem);
                        simpleItemDetail.SetupSimpleItemDetail(rewardItem);
                        ExploreManager.Instance.expUICtr.UpdateBottomBar();
                    }
                    break;
                }

                if (!dialogGroup.isMultiTimes)
                {
                    List <HLHNPCChatRecord> chatRecords = GameManager.Instance.gameDataCenter.chatRecords;

                    HLHNPCChatRecord chatRecord = new HLHNPCChatRecord(npc.npcId, dialogGroup.dialogGroupId);

                    chatRecords.Add(chatRecord);


                    //GameManager.Instance.persistDataManager.SaveCompletePlayerData();
                }

                dialogHasFinished = true;

                QuitDialogPlane();

                return;
            }

            //if(Player.mainPlayer.currentLevelIndex == CommonData.maxLevel && dialogGroup.triggerLevel == CommonData.maxLevel){

            //             this.gameObject.SetActive(false);

            //	GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.shareCanvasBundleName, "ShareCanvas", delegate
            //             {
            //                 TransformManager.FindTransform("ShareCanvas").GetComponent<ShareViewController>().SetUpShareView(ShareType.WeChat, null, null, null);
            //             });

            //	return;
            //}

            QuitDialogPlane();
        }
Exemplo n.º 5
0
        private void DrawDialogs(HLHDialogGroup dg, bool[,] dgFoldoutInfoArray)
        {
            if (dg.dialogs == null)
            {
                dg.dialogs = new List <HLHDialog> ();
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("***编辑对话数组", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(120)
            });
            EditorGUILayout.BeginVertical();

            //dg.isMultiOff = EditorGUILayout.Toggle ("是否可以反复触发", dg.isMultiOff, middleLayouts);

            EditorGUILayout.BeginHorizontal();
            bool createNewDialog  = GUILayout.Button("添加新的对话", buttonLayouts);
            bool removeLastDialog = GUILayout.Button("删除尾部对话", buttonLayouts);
            bool unfoldAll        = GUILayout.Button("全部展开", buttonLayouts);
            bool foldAll          = GUILayout.Button("全部合上", buttonLayouts);

            EditorGUILayout.EndHorizontal();

            if (unfoldAll)
            {
                for (int i = 0; i < dgFoldoutInfoArray.GetLength(1); i++)
                {
                    dgFoldoutInfoArray[dg.dialogGroupId, i] = true;
                }
            }

            if (foldAll)
            {
                for (int i = 0; i < dgFoldoutInfoArray.GetLength(1); i++)
                {
                    dgFoldoutInfoArray[dg.dialogGroupId, i] = false;
                }
            }


            if (createNewDialog)
            {
                HLHDialog d = new HLHDialog();
                dg.dialogs.Add(d);
            }
            if (removeLastDialog && dg.dialogs.Count > 0)
            {
                dg.dialogs.RemoveAt(dg.dialogs.Count - 1);
            }

            for (int j = 0; j < dg.dialogs.Count; j++)
            {
                HLHDialog d = dg.dialogs [j];

                d.dialogId = j;

                string foldContent = string.Format("编辑对话	\t\t***对话ID:   {0}\t\t\t***对话内容:   {1}", d.dialogId, d.dialogContent);

                dgFoldoutInfoArray [dg.dialogGroupId, j] = EditorGUILayout.Foldout(dgFoldoutInfoArray [dg.dialogGroupId, j], foldContent);

                if (dgFoldoutInfoArray [dg.dialogGroupId, j])
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("\t\t\t\t\t", new GUILayoutOption[] {
                        GUILayout.Height(20),
                        GUILayout.Width(20)
                    });
                    EditorGUILayout.BeginVertical();

                    EditorGUILayout.LabelField("对话ID", d.dialogId.ToString(), shortLayouts);

                    d.dialogContent = EditorGUILayout.TextField("对话内容", d.dialogContent, longLayouts);

                    if (d.choiceIds == null)
                    {
                        d.choiceIds = new List <int> ();
                    }

                    EditorGUILayout.EndVertical();
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("================================================================", seperatorLayouts);
        }
Exemplo n.º 6
0
        private void DrawRegularGreetings()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("***编辑寒暄", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(120)
            });
            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();
            bool createNewDialog  = GUILayout.Button("添加新的寒暄", buttonLayouts);
            bool removeLastDialog = GUILayout.Button("删除尾部寒暄", buttonLayouts);
            bool unfoldAll        = GUILayout.Button("全部展开", buttonLayouts);
            bool foldAll          = GUILayout.Button("全部合上", buttonLayouts);

            EditorGUILayout.EndHorizontal();

            if (createNewDialog)
            {
                HLHDialog dg = new HLHDialog();
                //dg.dialogs = new List<HLHDialog> ();
                //dg.choices = new List<HLHChoice> ();
                npc.regularGreetings.Add(dg);
            }

            if (removeLastDialog && npc.regularGreetings.Count > 0)
            {
                npc.regularGreetings.RemoveAt(npc.regularGreetings.Count - 1);
            }


            if (unfoldAll)
            {
                for (int i = 0; i < regularGreetingDialogFoldOutInfoArray.Length; i++)
                {
                    regularGreetingDialogFoldOutInfoArray[i] = true;
                }
            }

            if (foldAll)
            {
                for (int i = 0; i < regularGreetingDialogFoldOutInfoArray.Length; i++)
                {
                    regularGreetingDialogFoldOutInfoArray[i] = false;
                }
            }

            for (int i = 0; i < npc.regularGreetings.Count; i++)
            {
                regularGreetingDialogFoldOutInfoArray [i] = EditorGUILayout.Foldout(regularGreetingDialogFoldOutInfoArray [i], "npc寒暄:" + npc.regularGreetings[i].dialogContent);


                if (regularGreetingDialogFoldOutInfoArray [i])
                {
                    HLHDialog dialog = npc.regularGreetings [i];

                    dialog.dialogId = i;

                    DrawGreeting(dialog);
                }
            }


            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Separator();

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("================================================================", seperatorLayouts);

//			EditorGUILayout.BeginHorizontal ();
//			EditorGUILayout.LabelField ("***编辑常规寒暄对话", new GUILayoutOption[] {
//				GUILayout.Height (20),
//				GUILayout.Width (120)
//			});
//			EditorGUILayout.BeginVertical ();
//
//			if (npc.regularGreeting == null) {
//				npc.regularGreeting = new HLHDialogGroup ();
//			}
//
//			HLHDialogGroup dg = npc.regularGreeting;
//
//			dg.dialogGroupId = -1;
//
//			dg.isTaskTriggeredDg = false;
//
//			dg.triggerLevel = -1;
//
//			DrawDialogs (dg,regularGreetingDialogFoldOutInfoArray);
//
//			DrawChoices (dg,regularGreetingChoiceFoldOutInfoArray);
//
//
//			EditorGUILayout.EndVertical ();
//			EditorGUILayout.EndHorizontal ();
//
//			EditorGUILayout.Separator ();
//			EditorGUILayout.LabelField ("================================================================", seperatorLayouts);
        }