public static bool Patch_MovieLoadJson(ref object __result, JsonReader reader)
 {
     if (reader.TokenType == JsonToken.String)
     {
         __result = OutputNodeConvert.Deserialize(reader.Value.ToString());
     }
     else
     {
         // 增加json加载
         //Console.WriteLine("检测到Json模式Node!");
         __result = ModJson.FromReaderMod <OutputNode>(reader);
     }
     return(false);
 }
Beispiel #2
0
        public void OnUpdate()
        {
            if (!DebugOn.Value)
            {
                return;
            }
            if (Input.GetKeyDown(NodeDocKey.Value))
            {
                string target = DebugOutDir.Value + "游戏指令(OutputNode)文档.json";
                ModOutputNodeConverter.ExportDoc(target);
                target = DebugOutDir.Value + "txt表格(Item)文档.json";
                ItemDocConverter.ExportDoc(target);
            }
            if (Input.GetKeyDown(NodeFileKey.Value) && !string.IsNullOrEmpty(NodeContent.Value))
            {
                // OutputNode
                string     target     = DebugOutDir.Value + NodeFilePath.Value;
                OutputNode obj        = OutputNodeConvert.Deserialize(NodeContent.Value);
                var        strJsonMod = ModJson.ToJsonMod(obj, typeof(OutputNode), JsonPritty.Value);
                Console.WriteLine("Json版 = " + strJsonMod);
                GlobalLib.ToFile(strJsonMod, target);
            }
            if (Input.GetKeyDown(MovieFileKey.Value) && !string.IsNullOrEmpty(MovieFileId.Value))
            {
                // movie
                string source = string.Format(MovieFileType.Value == MovieType.Cinematic ? GameConfig.CinematicPath : GameConfig.SchedulerPath, MovieFileId.Value);
                string target = string.Format(DebugOutDir.Value + MovieFilePath.Value, MovieFileId.Value);
                var    obj    = ModJson.FromJsonResource <ScheduleGraph.Bundle>(source);
                if (JsonFormat.Value)
                {
                    var strJsonMod = ModJson.ToJsonMod(obj, typeof(ScheduleGraph.Bundle), JsonPritty.Value);
                    Console.WriteLine("Json版 = " + strJsonMod);
                    GlobalLib.ToFile(strJsonMod, target);

                    // 测试读取并对比重新通过Json构建的是否有差
                    var obj2 = ModJson.FromJsonMod <ScheduleGraph.Bundle>(strJsonMod);
                    JsonSerializerSettings originalSetting = new JsonSerializerSettings
                    {
                        Converters = new JsonConverter[]
                        {
                            new OutputNodeJsonConverter()
                        }
                    };
                    string str2 = ModJson.ToJson(obj2, typeof(ScheduleGraph.Bundle), originalSetting, JsonPritty.Value);
                    Console.WriteLine("重构脚本 = " + str2);
                }
                else
                {
                    GlobalLib.ToFile(Game.Resource.LoadString(source), target);
                }
            }
            if (Input.GetKeyDown(BattleFileKey.Value) && !string.IsNullOrEmpty(BattleFileId.Value))
            {
                // battle schedule
                string source = string.Format(GameConfig.BattleSchedulePath, GameConfig.Language, BattleFileId.Value + ".json");
                string target = string.Format(DebugOutDir.Value + BattleFilePath.Value, BattleFileId.Value);
                if (JsonFormat.Value)
                {
                    BattleSchedule obj        = ModJson.FromJsonResource <BattleSchedule>(source);
                    var            strJsonMod = ModJson.ToJsonMod(obj, typeof(BattleSchedule), JsonPritty.Value);
                    Console.WriteLine("Json版 = " + strJsonMod);
                    GlobalLib.ToFile(strJsonMod, target);
                }
                else
                {
                    GlobalLib.ToFile(Game.Resource.LoadString(source), target);
                }
            }
            if (Input.GetKeyDown(BuffFileKey.Value) && !string.IsNullOrEmpty(BuffFileId.Value))
            {
                // buff
                string source = string.Format(GameConfig.ButtleBufferPath, GameConfig.Language, BuffFileId.Value + ".json");
                string target = string.Format(DebugOutDir.Value + BuffFilePath.Value, BuffFileId.Value);
                if (JsonFormat.Value)
                {
                    Heluo.Data.Buffer obj = ModJson.FromJsonResource <Heluo.Data.Buffer>(source);
                    var strJsonMod        = ModJson.ToJsonMod(obj, typeof(Heluo.Data.Buffer), true);
                    Console.WriteLine("Json版 = " + strJsonMod);
                    GlobalLib.ToFile(strJsonMod, target);
                }
                else
                {
                    GlobalLib.ToFile(Game.Resource.LoadString(source), target);
                }
            }
        }
        static void ModExt_NewProps_DefaultData(DataManager __instance)
        {
            // 为每种心法和招式添加对应秘籍
            var DictProps  = __instance.Get <Props>();
            var DictSkill  = __instance.Get <Skill>();
            var DictMantra = __instance.Get <Mantra>();

            foreach (Skill skill in DictSkill.Values)
            {
                Props props = new Props
                {
                    Id            = "p_scroll_" + skill.Id,
                    Description   = skill.Description,
                    PropsType     = PropsType.Medicine,
                    PropsCategory = GlobalLib.GetScrollType(skill.Type),
                    Name          = skill.Name + "秘籍",
                    PropsEffect   = new List <PropsEffect>
                    {
                        new PropsLearnSkill(skill.Id)
                    },
                    PropsEffectDescription = "学会招式:" + skill.Name
                };
                DictProps.Add(props.Id, props);
            }
            foreach (Mantra mantra in DictMantra.Values)
            {
                Props props2 = new Props
                {
                    Id            = "p_scroll_" + mantra.Id,
                    Description   = mantra.Description,
                    PropsType     = PropsType.Medicine,
                    PropsCategory = PropsCategory.InternalStyle_Secret_Scroll,
                    Name          = mantra.Name + "秘籍",
                    PropsEffect   = new List <PropsEffect>
                    {
                        new PropsLearnMantra(mantra.Id)
                    },
                    PropsEffectDescription = "学会心法:" + mantra.Name
                };
                DictProps.Add(props2.Id, props2);
            }
            // 为每个NPC添加人物加入道具
            var DictNpc    = __instance.Get <Npc>();
            var DictReward = __instance.Get <Reward>();

            foreach (Npc npc in DictNpc.Values)
            {
                Props props3 = new Props
                {
                    Id            = "p_npcj_" + npc.Id,
                    Description   = npc.Name + "加入",
                    PropsType     = PropsType.Quest,
                    PropsCategory = PropsCategory.Other_Quest,
                    Name          = npc.Name + "加入",
                    PropsEffect   = new List <PropsEffect>
                    {
                        new PropsReward("re_npcj_" + npc.Id)
                    },
                    PropsEffectDescription = "加入队友:" + npc.Name
                };
                DictProps.Add(props3.Id, props3);
                string s      = "{\"LogicalNode\":[{\"CommunityAction\":\"" + npc.Id + "\",True}],0}";
                Reward reward = new Reward
                {
                    Id            = "re_npcj_" + npc.Id,
                    Description   = npc.Name + "加入",
                    IsShowMessage = true,
                    Rewards       = new BaseFlowGraph(OutputNodeConvert.Deserialize(s))
                };
                DictReward.Add(reward.Id, reward);
            }
        }