Exemplo n.º 1
0
        public static bool LoadGameData_Path(ModifierModel __instance)
        {
            // 如果MOD状态是关闭的话
            if (!FormationMod.enable)
            {
                // 执行原本的方法
                return(true);
            }
            __instance.mGameData = Singleton <DataManager> .Instance.Load <ModifierGameData>(__instance.mName, DataType.Game, null);

            bool flag = __instance.mGameData == null;

            if (flag)
            {
                //__instance.mLogService.LogError(__instance.mName + "Model 游戏数据加载失败");
                ILogService mLogService = Traverse.Create(__instance).Field("mLogService").GetValue <ILogService>();
                mLogService.LogError(__instance.mName + "Model 游戏数据加载失败");
            }
            else
            {
                List <string> list = ListPool <string> .Get();

                Singleton <DataManager> .Instance.GetAllDirName(ref list, "ModifierInfo/", DataType.Game, -1);

                for (int i = 0; i < list.Count; i++)
                {
                    string       key          = list[i];
                    ModifierInfo modifierInfo = __instance.LoadModifierInfoByID(key);
                }
                ListPool <string> .Recycle(list);

                //FormationMod.logger.Log($" init ModifierInfoMap");
                for (int i = 0; i < FormationFileLoad.Size; i++)
                {
                    FormationInfo formationInfo = FormationFileLoad.fiList[i];
                    for (int i2 = 0; i2 < formationInfo.Positions.Count; i2++)
                    {
                        ModifierInfo newModifierInfo_0 = __instance.CloneModifierInfo(__instance.ModifierInfoMap["martial-baguaxinfa"], "martial-" + formationInfo.Name + i2);
                        // 需要初始化所有的阵法buff,每个阵型每个位置的buff不同
                        ModifierUtil.setModifierInfo(newModifierInfo_0, formationInfo.NameCN, formationInfo.Name, formationInfo.Positions[i2]);
                    }
                }
                //ModifierInfo newModifierInfo_1 = __instance.CloneModifierInfo(__instance.ModifierInfoMap["martial-baguaxinfa"], "martial-" + ModifierUtil.formationPY[1]);
                //ModifierUtil.setModifierInfo(newModifierInfo_1, ModifierUtil.formationCN[1], ModifierUtil.formationPY[1], "10");
            }
            // 返回false表示不执行原方法
            return(false);
        }
        public static bool Exit_Path(BattleManager __instance)
        {
            // 如果MOD状态是关闭的话
            if (!FormationMod.enable)
            {
                // 执行原本的方法
                return(true);
            }
            // 退出战斗时还原是否组成阵型的状态
            ModifierUtil.resetEnableStatus();

            __instance.DieEntityList.Clear();
            __instance.BrokenEquipmentMap.Clear();

            Dictionary <int, List <int> > mTeamEntities = Traverse.Create(__instance).Field("mTeamEntities").GetValue <Dictionary <int, List <int> > >();

            for (int i = 0; i < 2; i++)
            {
                mTeamEntities[i].Clear();
            }
            Dictionary <int, BattleEntityView> mEntityViewMap = Traverse.Create(__instance).Field("mEntityViewMap").GetValue <Dictionary <int, BattleEntityView> >();

            foreach (KeyValuePair <int, BattleEntityView> keyValuePair in mEntityViewMap)
            {
                BattleEntityView value = keyValuePair.Value;
                Singleton <ResourcesManager> .Instance.ReleaseInstance(value.mContainer.transform.gameObject);
            }
            mEntityViewMap.Clear();
            __instance.Hide();
            SingletonMonoBehaviour <UIManager> .Instance.CloseUnique(PanelEnum.Battle);

            SingletonMonoBehaviour <AudioManager> .Instance.StopAllMusic();

            SingletonMonoBehaviour <AudioManager> .Instance.PlayGameBGM();

            SingletonMonoBehaviour <UIManager> .Instance.ShowAll();

            TimeModel instance = SingletonMonoBehaviour <TimeModel> .Instance;
            int       timeStop = instance.TimeStop;

            instance.TimeStop = timeStop - 1;
            GameTempValue.GameSpeedHotKeyLock--;
            GameTempValue.MapMoveHotKeyLock--;
            GameTempValue.SamllMapKeyLock--;
            GameTempValue.TapKeyLock--;
            GameTempValue.BackpackKeyLock--;
            bool flag = false;

            Dictionary <int, BattleEntity> mEntities = Traverse.Create(__instance).Field("mEntities").GetValue <Dictionary <int, BattleEntity> >();

            foreach (KeyValuePair <int, BattleEntity> keyValuePair2 in mEntities)
            {
                BattleEntity value2 = keyValuePair2.Value;
                bool         flag2  = value2.mChr.GetCurrentValue(CharacterPropertyType.HP) == 0;
                if (flag2)
                {
                    value2.mChr.SetStatRawValue(CharacterPropertyType.HP, 1);
                }
                bool flag3 = !value2.mChr.IsPlayer();
                if (flag3)
                {
                    bool flag4 = value2.DroppedWeapon != null;
                    if (flag4)
                    {
                        value2.mChr.EquipItem(value2.DroppedWeapon);
                    }
                    value2.mChr.RemoveAllMartialModifier();
                }
                else
                {
                    bool flag5 = value2.TakenDamageMap.Count > 0;
                    if (flag5)
                    {
                        flag = true;
                    }
                }
                bool flag6 = value2.Team != 0 || value2.mChr.IsPlayer();
                if (flag6)
                {
                    value2.AddInjury();
                }
                __instance.RecycleEntity(value2);
            }
            mEntities.Clear();
            bool flag7 = flag;

            if (flag7)
            {
                SingletonMonoBehaviour <GuideModel> .Instance.TryGuide(0);
            }
            switch (__instance.BattleType)
            {
            case BattleType.Kill:
            case BattleType.Compete:
                SingletonMonoBehaviour <MapModel> .Instance.BattleEnd(__instance.BattleType, __instance.Result);

                break;

            case BattleType.Invade:
                SingletonMonoBehaviour <SchoolModel> .Instance.BattleEnd(__instance.BattleType, __instance.Result);

                break;

            case BattleType.LunWu:
                SingletonMonoBehaviour <MartialCompeteModel> .Instance.BattleEnd(__instance.BattleType, __instance.Result);

                break;
            }
            // 获取背景
            Traverse           mBackground      = Traverse.Create(__instance).Field("mBackground");
            TransformContainer mBackgroundValue = mBackground.GetValue <TransformContainer>();

            // 释放资源
            Singleton <ResourcesManager> .Instance.ReleaseInstance(mBackgroundValue.transform.gameObject);

            mBackground.SetValue(null);
            // 返回false表示不执行原方法
            return(false);
        }