예제 #1
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);
     }
 }
예제 #2
0
        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);
        }