示例#1
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);
        }
示例#2
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)));
 }