public void SetUpDialogView(HLHNPC npc, HLHDialogGroup dialogGroup, CallBack quitCallBack) { this.npc = npc; this.dialogGroup = dialogGroup; this.quitCallBack = quitCallBack; bool hasNpcIcon = false; if (npc.npcName.Equals("智者·艾尔文")) { hasNpcIcon = true; npcIcon.sprite = wiseManSprite; } //if(npc.npcName.Equals("游侠·安科尔")){ // hasNpcIcon = true; // npcIcon.sprite = youXiaSprite; //} npcIcon.enabled = hasNpcIcon; npcName.text = npc.npcName; dialogText.text = dialogGroup.dialogs[0].dialogContent; currentDialogId = 0; dialogHasFinished = false; this.gameObject.SetActive(true); }
/// <summary> /// 加载指定id的npc数据 /// </summary> /// <returns>The npc.</returns> /// <param name="npcId">Npc identifier.</param> public HLHNPC LoadNpc(int npcId) { string npcDataPath = string.Format("{0}/NPC_{1}.json", CommonData.npcsDataDirPath, npcId); HLHNPC npc = DataHandler.LoadDataToSingleModelWithPath <HLHNPC> (npcDataPath); return(npc); }
public void EnterNPC(HLHNPC npc) { ExploreManager.Instance.MapWalkableEventsStopAction(); GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.npcCanvasBundleName, "NPCCanvas", delegate { TransformManager.FindTransform("NPCCanvas").GetComponent <NPCViewController>().SetUpNPCView(npc); }); }
public void SetUpSkillLearningView(HLHNPC npc, CallBack quitCallBack) { this.currentNpc = npc; GameManager.Instance.soundManager.PlayAudioClip(CommonData.merchantAudioName); gameObject.SetActive(true); this.skillGoodsIds = npc.npcSkillIds; this.quitCallBack = quitCallBack; skillGoodsPool.AddChildInstancesToPool(skillGoodsContainer); for (int i = 0; i < skillGoodsIds.Count; i++) { SkillGoodsInTrade skillGoodsDetail = skillGoodsPool.GetInstance <SkillGoodsInTrade>(skillGoodsModel.gameObject, skillGoodsContainer); Skill skill = GameManager.Instance.gameDataCenter.allSkills.Find(delegate(Skill obj) { return(obj.skillId == skillGoodsIds[i]); }); skillGoodsDetail.SetupSkillDetailInNPC(skill, SkillGoodsSelectCallBack); skillGoodsDetail.SetUpSelectedIcon(false); allSkillGoods.Add(skillGoodsDetail); } skillNumLeftText.text = string.Format("剩余技能点: {0}", Player.mainPlayer.skillNumLeft); for (int i = 0; i < allLearnedSkillDetails.Length; i++) { SimpleSkillDetail learnedSkillDetail = allLearnedSkillDetails[i]; if (i < Player.mainPlayer.allLearnedSkills.Count) { Skill learnedSkill = Player.mainPlayer.allLearnedSkills[i]; learnedSkillDetail.SetUpSimpleSkillDetail(learnedSkill, LearnedSkillSelectCallBack); } else { learnedSkillDetail.ClearSimpleSkillDetail(); } learnedSkillDetail.SetUpSelectedIcon(false); } //skillDetailInTrade.InitskilldetailInTrade(UpdateLearnedSkillsPlane); skillDetailInTrade.ClearSkillDetailInTrade(); EnterSkillGoodsTradeViewDisplay(); }
// 初始化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); }
/// <summary> /// 退出npc交互界面 /// </summary> public void QuitNPCPlane() { ExploreManager.Instance.expUICtr.HideTopBarMask(); ExploreManager.Instance.expUICtr.rejectNewUI = false; if (npc == null) { return; } for (int i = 0; i < GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcArray.Length; i++) { HLHNPC tempNpc = GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcArray[i]; if (tempNpc != null && tempNpc.npcId == npc.npcId) { GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcArray[i] = npc; break; } } dialogText.text = string.Empty; npc = null; MapNPC mn = ExploreManager.Instance.currentEnteredMapEvent as MapNPC; ExploreManager.Instance.battlePlayerCtr.isInEvent = false; ExploreManager.Instance.battlePlayerCtr.boxCollider.enabled = true; mn.isTriggered = false; ExploreManager exploreManager = ExploreManager.Instance; exploreManager.MapWalkableEventsStartAction(); mn.RefreshWalkableInfoWhenQuit(false); exploreManager.EnableExploreInteractivity(); GameManager.Instance.UIManager.HideCanvas("NPCCanvas"); }
public void SetUpPropertyPromotionView(HLHNPC npc, CallBack quitCallBack) { this.npc = npc; this.quitCallBack = quitCallBack; HLHPropertyPromotion propertyPromotion_1 = npc.propertyPromotionList[0]; HLHPropertyPromotion propertyPromotion_2 = npc.propertyPromotionList[1]; propertyPromotionText_1.text = propertyPromotion_1.GetPropertyPromotionTint(); propertyPromotionText_2.text = propertyPromotion_2.GetPropertyPromotionTint(); propertyPromotionPriceText_1.text = propertyPromotion_1.promotionPrice.ToString(); propertyPromotionPriceText_2.text = propertyPromotion_2.promotionPrice.ToString(); propertyPromotionIcon_1.sprite = GetPropertySprite(propertyPromotion_1.propertyType); propertyPromotionIcon_2.sprite = GetPropertySprite(propertyPromotion_2.propertyType); this.gameObject.SetActive(true); }
public void SetUpAddGemstoneView(HLHNPC npc, CallBack quitCallBack) { //this.npc = npc; this.quitCallBack = quitCallBack; GameManager.Instance.soundManager.PlayAudioClip(CommonData.merchantAudioName); itemDetail.ClearItemDetails(); #if UNITY_IOS bagItemsDisplay.InitBagItemsDisplayPlane(OnItemInBagClickInSpecialOperation, PurchaseBagCallBack, buyGoldView.SetUpBuyGoldView); #elif UNITY_ANDROID bagItemsDisplay.InitBagItemsDisplayPlane(OnItemInBagClickInSpecialOperation, PurchaseBagCallBack, EnterGoldWatchAdOnAndroid); #elif UNITY_EDITOR UnityEditor.BuildTarget buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget; switch (buildTarget) { case UnityEditor.BuildTarget.Android: bagItemsDisplay.InitBagItemsDisplayPlane(OnItemInBagClickInSpecialOperation, PurchaseBagCallBack, EnterGoldWatchAdOnAndroid); break; case UnityEditor.BuildTarget.iOS: bagItemsDisplay.InitBagItemsDisplayPlane(OnItemInBagClickInSpecialOperation, PurchaseBagCallBack, buyGoldView.SetUpBuyGoldView); break; } #endif bagItemsDisplay.SetUpBagItemsPlane(0); specialOperationHUD.InitSpecialOperationHUD(RefreshCurrentSelectItemDetailDisplay, AddGemstoneCallBack); EnterSpecialOperationDisplay(); quitTradeButton.gameObject.SetActive(false); quitAddGemstoneButton.gameObject.SetActive(true); }
/// <summary> /// 初始化地图npc /// </summary> /// <param name="mapIndex">Map index.</param> /// <param name="attachedInfo">Attached info.</param> public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo) { transform.position = attachedInfo.position; this.moveOrigin = attachedInfo.position; this.moveDestination = attachedInfo.position; baCtr.SetSortingOrder(-(int)transform.position.y); npc = null; for (int i = 0; i < GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray.Length; i++) { Vector2 pos = GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray[i]; if (MyTool.ApproximatelySameIntPosition2D(pos, attachedInfo.position)) { npc = GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcArray[i]; break; } } if (npc == null) { npc = GameManager.Instance.gameDataCenter.LoadNpc(npcId); for (int i = 0; i < GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray.Length; i++) { Vector2 pos = GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray[i]; if (pos == -Vector2.one) { GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray[i] = transform.position; GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcArray[i] = npc; break; } } } bc2d.enabled = true; gameObject.SetActive(true); baCtr.PlayRoleAnim(CommonData.roleIdleAnimName, 0, null); bc2d.enabled = true; isTriggered = false; isInAutoWalk = false; needPosFix = false; Sprite miniMapNpcSprite = GameManager.Instance.gameDataCenter.allMiniMapSprites.Find(delegate(Sprite obj) { return(obj.name == string.Format("MiniMapNPC_{0}", npc.npcId)); }); miniMapInstance.GetComponent <SpriteRenderer>().sprite = miniMapNpcSprite; }
public void OnGUI() { Rect windowRect = npcEditor.position; scrollPos = EditorGUILayout.BeginScrollView(scrollPos, new GUILayoutOption[] { GUILayout.Height(windowRect.height), GUILayout.Width(windowRect.width) }); EditorGUILayout.LabelField("please input information of npc"); EditorGUILayout.LabelField("npc数据源", longLayouts); EditorGUILayout.BeginHorizontal(); rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(300)); npcDataPath = EditorGUI.TextField(rect, npcDataPath); switch (dataResult) { case -1: EditorGUILayout.LabelField("加载失败,目标文件不存在", shortLayouts); break; case 0: EditorGUILayout.LabelField("加载完成", shortLayouts); break; case 1: EditorGUILayout.LabelField("保存完成", shortLayouts); break; case -2: EditorGUILayout.LabelField("保存失败", shortLayouts); break; } EditorGUILayout.EndHorizontal(); //如果鼠标正在拖拽中或拖拽结束时,并且鼠标所在位置在文本输入框内 if ((UnityEngine.Event.current.type == UnityEngine.EventType.DragUpdated || UnityEngine.Event.current.type == UnityEngine.EventType.DragExited) && rect.Contains(UnityEngine.Event.current.mousePosition)) { //改变鼠标的外表 DragAndDrop.visualMode = DragAndDropVisualMode.Generic; if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0) { npcDataPath = DragAndDrop.paths [0]; } } bool loadNpcData = GUILayout.Button("加载npc数据", buttonLayouts); bool saveNpcData = GUILayout.Button("保存npc数据", buttonLayouts); if (loadNpcData) { if (File.Exists(npcDataPath)) { string npcData = File.ReadAllText(npcDataPath); if (npcData == string.Empty) { npc = new HLHNPC(); //npc.monsterData = new MonsterData (); // npc.regularGreeting = new HLHDialogGroup (); for (int i = 0; i < 10; i++) { HLHNPCGoodsGroup gg = new HLHNPCGoodsGroup(); npc.npcGoodsGroupList.Add(gg); } } else { npc = JsonUtility.FromJson <HLHNPC> (npcData); } dataResult = 0; } else { dataResult = -1; } } if (saveNpcData) { if (File.Exists(npcDataPath)) { string npcData = JsonUtility.ToJson(npc); File.WriteAllText(npcDataPath, npcData); dataResult = 1; } else { dataResult = -2; } } npc.npcName = EditorGUILayout.TextField("npc名称:", npc.npcName, middleLayouts); npc.npcId = EditorGUILayout.IntField("npc ID:", npc.npcId, shortLayouts); npc.saveOnChange = EditorGUILayout.Toggle("数据变化时是否保存", npc.saveOnChange, shortLayouts); npc.isChatTriggered = EditorGUILayout.Toggle("触发聊天", npc.isChatTriggered, shortLayouts); if (npc.isChatTriggered) { DrawRegularDialogGroups(npc.levelDefiniteDialogGroups, levelDefiniteDialogGroupFoldOutInfoArray, levelDefiniteDialogFoldOutInfoArray); DrawRegularDialogGroups(npc.levelUndefiniteDialogGroups, levelUndefiniteDialogGroupFoldOutInfoArray, levelUndefiniteDialogFoldOutInfoArray); } npc.isTradeTriggered = EditorGUILayout.Toggle("触发交易", npc.isTradeTriggered, shortLayouts); if (npc.isTradeTriggered) { DrawGoods(); } npc.isTransportTriggered = EditorGUILayout.Toggle("触发传送", npc.isTransportTriggered, shortLayouts); if (npc.isTransportTriggered) { List <int> transportLevelList = npc.transportLevelList; EditorGUILayout.LabelField("编辑在当前npc处可以传送到的关卡id列表", longLayouts); EditorGUILayout.BeginHorizontal(); bool addNewLevel = GUILayout.Button("添加关卡", buttonLayouts); bool removeLastLevel = GUILayout.Button("删除尾部关卡", buttonLayouts); EditorGUILayout.EndHorizontal(); if (addNewLevel) { transportLevelList.Add(0); } if (removeLastLevel && transportLevelList.Count > 0) { transportLevelList.RemoveAt(transportLevelList.Count - 1); } for (int i = 0; i < transportLevelList.Count; i++) { transportLevelList[i] = EditorGUILayout.IntField("关卡id", transportLevelList[i], shortLayouts); } EditorGUILayout.LabelField("================================================================", seperatorLayouts); } npc.isLearnSkillTriggered = EditorGUILayout.Toggle("触发学习技能", npc.isLearnSkillTriggered, shortLayouts); if (npc.isLearnSkillTriggered) { List <int> npcSkillIds = npc.npcSkillIds; if (npcSkillIds == null || npcSkillIds.Count == 0) { npcSkillIds.Add(0); npcSkillIds.Add(0); npcSkillIds.Add(0); npcSkillIds.Add(0); } if (npcSkillIds.Count == 3) { npcSkillIds.Add(0); } EditorGUILayout.LabelField("编辑可以在当前npc处购买学习的技能id数组", longLayouts); npcSkillIds[0] = EditorGUILayout.IntField("技能1:", npcSkillIds[0], shortLayouts); npcSkillIds[1] = EditorGUILayout.IntField("技能2:", npcSkillIds[1], shortLayouts); npcSkillIds[2] = EditorGUILayout.IntField("技能3:", npcSkillIds[2], shortLayouts); npcSkillIds[3] = EditorGUILayout.IntField("技能4:", npcSkillIds[3], shortLayouts); EditorGUILayout.LabelField("================================================================", seperatorLayouts); } npc.isPropertyPromotionTriggered = EditorGUILayout.Toggle("触发属性提升", npc.isPropertyPromotionTriggered, shortLayouts); if (npc.isPropertyPromotionTriggered) { List <HLHPropertyPromotion> propertyPromotions = npc.propertyPromotionList; EditorGUILayout.LabelField("================================================================", seperatorLayouts); EditorGUILayout.LabelField("编辑可以在当前npc处提升的属性列表 注:闪避,暴击,暴击倍率使用x1000以后的数值", longLayouts); EditorGUILayout.LabelField("0:最大生命 1:最大魔法 2:物攻 3:魔攻 4:移速 5:护甲 6:抗性 7:护甲穿透 8:抗性穿透 9:暴击 10:闪避 11:暴击倍率 12:物伤倍率 13:法伤倍率 14:额外金钱 15:额外经验 16:生命回复 17:魔法回复", longLayouts); EditorGUILayout.BeginHorizontal(); bool addPropertyPromotion = GUILayout.Button("添加属性", buttonLayouts); bool removeLastPropertyPromotion = GUILayout.Button("移除尾部属性", buttonLayouts); EditorGUILayout.EndHorizontal(); if (addPropertyPromotion) { propertyPromotions.Add(new HLHPropertyPromotion()); } if (removeLastPropertyPromotion && propertyPromotions.Count > 0) { propertyPromotions.RemoveAt(propertyPromotions.Count - 1); } EditorGUILayout.BeginHorizontal(); for (int i = 0; i < propertyPromotions.Count; i++) { EditorGUILayout.BeginVertical(); HLHPropertyPromotion propertyPromotion = propertyPromotions[i]; PropertyType propertyType = (PropertyType)(EditorGUILayout.IntField("属性类型:", (int)(propertyPromotion.propertyType), shortLayouts)); int promotion = EditorGUILayout.IntField("提升值:", propertyPromotion.promotion, shortLayouts); int promotionPrice = EditorGUILayout.IntField("提升价格:", propertyPromotion.promotionPrice, shortLayouts); HLHPropertyPromotion newPropertyPromotion = new HLHPropertyPromotion(propertyType, promotion, promotionPrice); propertyPromotions[i] = newPropertyPromotion; EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("================================================================", seperatorLayouts); } npc.isAddGemStoneTriggered = EditorGUILayout.Toggle("触发镶嵌宝石", npc.isAddGemStoneTriggered, shortLayouts); DrawRegularGreetings(); EditorGUILayout.EndScrollView(); }
public void SetUpSkillLearnQuizView(HLHNPC npc, Skill skill, CallBack quitSkillLearnQuizCallBack) { this.npc = npc; this.currentLearningSkill = skill; this.quitSkillLearnQuizCallBack = quitSkillLearnQuizCallBack; testedWords.Clear(); if (skill.wordCountToLearn == 0) { skill.wordCountToLearn = 10; } sourceWords = GetUnlearnedWordsOfCount(skill.wordCountToLearn); for (int i = 0; i < sourceWords.Length; i++) { HLHWord word = sourceWords[i]; GameManager.Instance.pronounceManager.DownloadPronounceCache(word); } if (sourceWords.Length == 0) { Debug.LogError("获取单词失败"); return; } currentWordIndex = 0; if (Application.internetReachability == NetworkReachability.NotReachable) { pronounceNotAvalableHintTextInExplain.enabled = true; } else { pronounceNotAvalableHintTextInExplain.enabled = false; } HLHWord[] quizWords = GetQuizWordArray(sourceWords, 3, currentWordIndex, out correctChoiceIndex); SetUpQuiz(quizWords, correctChoiceIndex); learnProgressBar.InitHLHFillBar(skill.wordCountToLearn, 0); skillIcon.sprite = GameManager.Instance.gameDataCenter.allSkillSprites.Find(delegate(Sprite obj) { return(obj.name == skill.skillIconName); }); skillIcon.enabled = true; skillLearnQuizContainer.gameObject.SetActive(true); queryRefreshHUD.gameObject.SetActive(false); learnedSkillFromQuizHUD.gameObject.SetActive(false); if (waitAndShowNextCoroutine != null) { StopCoroutine(waitAndShowNextCoroutine); } learnTintText.text = string.Format("连续完成测试后可以掌握<color=orange>{0}</color>", skill.skillName); gameObject.SetActive(true); GameManager.Instance.soundManager.PlayAudioClip(CommonData.paperAudioName); }
public void SetUpLevelTransportView(HLHNPC npc, LevelTransportSelectCallBack levelSelectCallBack, CallBack quitCallBack) { this.levelSelectCallBack = levelSelectCallBack; this.quitCallBack = quitCallBack; this.gameObject.SetActive(true); List <int> validTravelLevelIds = npc.GetValidTravelLevelIds(); levelChoiceContainer.localPosition = Vector3.zero; levelChoicePool.AddChildInstancesToPool(levelChoiceContainer); bool hasValidTranportLevel = validTravelLevelIds.Count > 0; for (int i = 0; i < validTravelLevelIds.Count; i++) { int transportLevel = validTravelLevelIds[i]; Button levelChoice = levelChoicePool.GetInstance <Button>(levelChoiceModel.gameObject, levelChoiceContainer); levelChoice.GetComponentInChildren <Text>().text = string.Format("第{0}层", transportLevel + 1); levelChoice.onClick.RemoveAllListeners(); levelChoice.onClick.AddListener(delegate { if (Player.mainPlayer.totalGold < transportCost) { tintHUD.SetUpSingleTextTintHUD("金币不足"); return; } Player.mainPlayer.totalGold -= transportCost; GameManager.Instance.gameDataCenter.currentMapEventsRecord.Reset(); GameManager.Instance.persistDataManager.ClearCurrentMapWordsRecordAndSave(); if (levelSelectCallBack != null) { levelSelectCallBack(transportLevel); } this.gameObject.SetActive(false); }); } noValidLevelHint.enabled = !hasValidTranportLevel; //upButton.gameObject.SetActive(hasValidTranportLevel); //downButton.gameObject.SetActive(hasValidTranportLevel); if (zoomCoroutine != null) { StopCoroutine(zoomCoroutine); } zoomCoroutine = HUDZoomIn(); StartCoroutine(zoomCoroutine); }