public static void ModExt_InitBattle(WuxiaBattleManager __instance, IDataProvider data, IResourceProvider resource)
 {
     // 整体替换 SummonProcessStrategy 类
     Traverse.Create(__instance).Field("summonProcess").SetValue(new ModSummonProcessStrategy(__instance, data, resource));
     // 清空自定义战场奖励
     ExtDrops.Clear();
 }
示例#2
0
 public static void ProcessCellNumber(WuxiaBattleManager m, ref int num)
 {
     try
     {
         if (num == -1)
         {
             AddUnitHelper._LastCellNumber = AddUnitHelper.GetAllCells(m).Random <int>();
             num = AddUnitHelper._LastCellNumber;
         }
         else if (num >= 0)
         {
             AddUnitHelper._LastCellNumber = num;
         }
         else if (AddUnitHelper._LastCellNumber <= 0)
         {
             AddUnitHelper._LastCellNumber = AddUnitHelper.GetAllCells(m).Random <int>();
             num = AddUnitHelper._LastCellNumber;
         }
         else
         {
             int range = -num - 1;
             num = AddUnitHelper.GetCellsInRange(m, AddUnitHelper._LastCellNumber, range).Random <int>();
         }
     }
     catch
     {
         Console.WriteLine("这个格子数字错误:" + num);
     }
 }
示例#3
0
        private static List <int> GetAllCells(WuxiaBattleManager m)
        {
            List <int> list = new List <int>();

            foreach (WuxiaCell wuxiaCell in m.GetAllCell())
            {
                if (wuxiaCell.Walkable && wuxiaCell.Unit == null)
                {
                    list.Add(wuxiaCell.CellNumber);
                }
            }
            return(list);
        }
示例#4
0
        private static List <int> GetCellsInRange(WuxiaBattleManager m, int cellNumber, int range)
        {
            WuxiaCell  wuxiaCellByNumber = m.GridGenerator.GetWuxiaCellByNumber(cellNumber);
            List <int> list = new List <int>();

            foreach (WuxiaCell wuxiaCell in m.GetCellRange(wuxiaCellByNumber.Coord, Faction.None, range, true, true))
            {
                if (wuxiaCell.Walkable && wuxiaCell.Unit == null)
                {
                    list.Add(wuxiaCell.CellNumber);
                }
            }
            return(list);
        }
 public static void TimedPatch_Begin(ref WuxiaBattleManager __instance, BattleStateMachine bsm)
 {
     bTimed = initiactiveBattle.Value;   // 总开关
     BM     = __instance;
     FSM    = bsm;
     TimedValue.Clear();
     TimedActives.Clear();
     TimedWaiting.Clear();
     TimedNext.Clear();
     UIWuxiaUnits.Clear();
     UIUnitIndex.Clear();
     UIPortraits.Clear();
     UINameBgs.Clear();
     UINames.Clear();
 }
 // Token: 0x06002C7B RID: 11387 RVA: 0x000F030C File Offset: 0x000EE50C
 public override Status GetValue()
 {
     if (WuxiaBattleManager == null)
     {
         return(Status.Error);
     }
     for (int i = 0; i < Count; i++)
     {
         string pattern = (i == 0) ? Pattern : "*";
         Console.WriteLine("Random Pattern " + pattern);
         Npc npc = Randomizer.GetOneFromData <Npc>(pattern);
         if (npc == null)
         {
             return(Status.Error);
         }
         int       tileNumber = (i == 0) ? CellNumber : -Range - 1;
         WuxiaUnit wuxiaUnit  = WuxiaBattleManager.AddUnit(npc.Id, Faction, tileNumber, !FullHealth);
         WuxiaBattleManager.FacedToNearestEnemy(wuxiaUnit);
     }
     return(Status.Success);
 }
        static bool ModExt_AddUnitOnBattleGround(WuxiaBattleManager __instance, string unitid, int tileNumber, Faction faction, bool isParty, ref WuxiaUnit __result)
        {
            WuxiaUnit result = null;
            int       times  = 0;

            while (result == null && times < 10)
            {
                int tile = tileNumber;
                AddUnitHelper.ProcessCellNumber(__instance, ref tile);
                Console.WriteLine(string.Format("元tile={0}, 新tile={1}", tileNumber, tile));
                try
                {
                    WuxiaUnit wuxiaUnit = __instance.UnitGenerator.CreateUnit(unitid, faction, tile, isParty);
                    wuxiaUnit.UnitDestroyed += __instance.OnUnitDestroyed;
                    result = wuxiaUnit;
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("AddUnit失败: id={0} faction={1} tile={2} isparty={3} error={4},再次尝试", new object[]
                    {
                        unitid,
                        faction,
                        tile,
                        isParty,
                        e.ToString()
                    }));
                    times++;
                    result = null;
                }
            }
            if (result == null)
            {
                UnityEngine.Debug.LogError("尝试10次无果,请彻查地图格子设置");
            }
            __result = result;
            return(false);
        }
 public ModSummonProcessStrategy(WuxiaBattleManager manager, IDataProvider data, IResourceProvider resource) : base(manager, data, resource)
 {
 }