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 OnPropertyPromotionSelect(int index)
        {
            HLHPropertyPromotion propertyPromotion = npc.propertyPromotionList[index];

            if (Player.mainPlayer.totalGold < propertyPromotion.promotionPrice)
            {
                tintHUD.SetUpSingleTextTintHUD("金币不足");
                return;
            }

            Player.mainPlayer.totalGold -= propertyPromotion.promotionPrice;

            PlayerPropertyChange(propertyPromotion.propertyType, propertyPromotion.promotion);

            string tint = propertyPromotion.GetPropertyPromotionTint();

            tintHUD.SetUpSingleTextTintHUD(tint);

            ExploreManager.Instance.expUICtr.UpdatePlayerStatusBar();
        }
示例#3
0
        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();
        }