Пример #1
0
 private static bool UpdateHitShieldCellAndReturnIfItIsFromTarget(SmartEntity target, BoardCell cell, ref BoardCell hitShieldCell)
 {
     if ((cell.Flags & 8u) != 0u)
     {
         if (hitShieldCell == null)
         {
             hitShieldCell = cell;
         }
         if (BoardUtils.CheckIfCellShieldBorderIsFromShieldTarget(target, cell))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
        private int ClampToDeployableBoard(int absValue, int troopWidth)
        {
            int halfWidthForOffset = BoardUtils.GetHalfWidthForOffset(troopWidth);
            int num = this.boardSize - 1 - halfWidthForOffset;

            if (absValue > num)
            {
                return(num);
            }
            if (absValue < halfWidthForOffset)
            {
                return(halfWidthForOffset);
            }
            return(absValue);
        }
Пример #3
0
        public static bool HasLineOfSight(Board board, int x0, int y0, int x1, int y1, SmartEntity troop, SmartEntity target, out BoardCell hitShieldCell)
        {
            bool overWalls = troop.ShooterComp.ShooterVO.OverWalls;
            bool isFlying  = troop.TroopComp.TroopType.IsFlying;

            hitShieldCell = null;
            int num  = (x1 <= x0) ? -1 : 1;
            int num2 = (x1 - x0) * num;
            int num3 = (y1 <= y0) ? -1 : 1;
            int num4 = (y1 - y0) * num3;

            if (num2 > num4)
            {
                int num5 = num4 * 2 - num2;
                int num6 = num4 * 2;
                int num7 = (num4 - num2) * 2;
                int num8 = x0;
                int num9 = y0;
                while (num8 != x1)
                {
                    if (num5 <= 0)
                    {
                        num5 += num6;
                        num8 += num;
                    }
                    else
                    {
                        num5 += num7;
                        num8 += num;
                        num9 += num3;
                    }
                    BoardCell cellAt = board.GetCellAt(num8, num9);
                    if (BoardUtils.UpdateHitShieldCellAndReturnIfItIsFromTarget(target, cellAt, ref hitShieldCell))
                    {
                        return(true);
                    }
                    if (num8 == x1)
                    {
                        return(true);
                    }
                    if (BoardUtils.IsCellBlockingLineOfSight(cellAt, overWalls, isFlying))
                    {
                        return(BoardUtils.CheckIfCellContainsTarget(target, cellAt));
                    }
                }
            }
            else
            {
                int num10 = num2 * 2 - num4;
                int num11 = num2 * 2;
                int num12 = (num2 - num4) * 2;
                int num13 = x0;
                int num14 = y0;
                while (num14 != y1)
                {
                    if (num10 <= 0)
                    {
                        num10 += num11;
                        num14 += num3;
                    }
                    else
                    {
                        num10 += num12;
                        num13 += num;
                        num14 += num3;
                    }
                    BoardCell cellAt = board.GetCellAt(num13, num14);
                    if (BoardUtils.UpdateHitShieldCellAndReturnIfItIsFromTarget(target, cellAt, ref hitShieldCell))
                    {
                        return(true);
                    }
                    if (num14 == y1)
                    {
                        return(true);
                    }
                    if (BoardUtils.IsCellBlockingLineOfSight(cellAt, overWalls, isFlying))
                    {
                        return(BoardUtils.CheckIfCellContainsTarget(target, cellAt));
                    }
                }
            }
            return(true);
        }
Пример #4
0
 public unsafe static long $Invoke5(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BoardUtils.IsCellBlockingLineOfSight((BoardCell <Entity>)GCHandledObjects.GCHandleToObject(*args), *(sbyte *)(args + 1) != 0, *(sbyte *)(args + 2) != 0)));
 }
Пример #5
0
 public unsafe static long $Invoke4(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BoardUtils.HasLineOfClearance((Board <Entity>)GCHandledObjects.GCHandleToObject(*args), *(int *)(args + 1), *(int *)(args + 2), *(int *)(args + 3), *(int *)(args + 4), *(int *)(args + 5))));
 }
Пример #6
0
 public unsafe static long $Invoke3(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BoardUtils.GetHalfWidthForOffset(*(int *)args)));
 }
Пример #7
0
 public unsafe static long $Invoke2(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BoardUtils.GetChessboardDistance(*(int *)args, *(int *)(args + 1), *(int *)(args + 2), *(int *)(args + 3))));
 }
Пример #8
0
 public unsafe static long $Invoke1(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BoardUtils.CheckIfCellShieldBorderIsFromShieldTarget((SmartEntity)GCHandledObjects.GCHandleToObject(*args), (BoardCell <Entity>)GCHandledObjects.GCHandleToObject(args[1]))));
 }
Пример #9
0
 public unsafe static long $Invoke0(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BoardUtils.CheckIfCellContainsTarget((SmartEntity)GCHandledObjects.GCHandleToObject(*args), (BoardCell <Entity>)GCHandledObjects.GCHandleToObject(args[1]))));
 }