Exemplo n.º 1
0
        /// <summary>
        /// 获取本层的商品id列表
        /// </summary>
        /// <returns>The current level goods.</returns>
        public List <HLHNPCGoods> GetCurrentLevelGoods()
        {
            // 如果已经初始化过,则返回本层的商品记录
            if (isGoodsInitialized)
            {
                return(goodsInSellRecord);
            }

            int ggIndex = Player.mainPlayer.currentLevelIndex / 5;

            goodsInSellRecord.Clear();

            HLHNPCGoodsGroup gg = npcGoodsGroupList[ggIndex];

            GenerateRandomGoods(gg.goodsList_1);
            GenerateRandomGoods(gg.goodsList_2);
            GenerateRandomGoods(gg.goodsList_3);
            GenerateRandomGoods(gg.goodsList_4);
            GenerateRandomGoods(gg.goodsList_5);

            isGoodsInitialized = true;

            return(goodsInSellRecord);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        private void DrawGoods()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("***编辑商品信息", new GUILayoutOption[] {
                GUILayout.Height(20),
                GUILayout.Width(120)
            });

            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();
            bool unfoldAll = GUILayout.Button("全部展开", buttonLayouts);
            bool foldAll   = GUILayout.Button("全部合上", buttonLayouts);

            EditorGUILayout.EndHorizontal();

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

            if (npc.npcGoodsGroupList.Count < 10)
            {
                npc.npcGoodsGroupList.Clear();
                for (int i = 0; i < 10; i++)
                {
                    HLHNPCGoodsGroup gg = new HLHNPCGoodsGroup();
                    npc.npcGoodsGroupList.Add(gg);
                }
            }

            for (int i = 0; i < 10; i++)
            {
                goodsFoldOutInfoArray [i] = EditorGUILayout.Foldout(goodsFoldOutInfoArray [i], string.Format("{0}-{1}层商品信息", i * 5, (i + 1) * 5));

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

                    EditorGUILayout.BeginVertical();

                    HLHNPCGoodsGroup gg = npc.npcGoodsGroupList [i];

                    EditorGUILayout.BeginHorizontal();

                    ShowGoods(gg.goodsList_1);
                    ShowGoods(gg.goodsList_2);
                    ShowGoods(gg.goodsList_3);
                    ShowGoods(gg.goodsList_4);
                    ShowGoods(gg.goodsList_5);

                    EditorGUILayout.EndHorizontal();

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

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

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