Пример #1
0
        public static bool CheckCellView(Map Map, Fight fight, double x, double y, bool boolean, Point p1, Point p2, double zDiff, double d)
        {
            var       CellId = GetCellNumber(Map, x, y);
            FightCell cell   = fight.GetCell(CellId);

            if (cell == null)
            {
                return(true);
            }
            double YZMaxDiff  = Math.Max(Math.Abs(p1.Y - y), Math.Abs(p1.X - x));
            var    Gradient   = YZMaxDiff / d * zDiff + p1.Z;
            var    CellHeight = GetCellHeight(Map, CellId);
            var    IsFull     = cell.HasUnWalkableFighter() || (YZMaxDiff == 0 || (boolean || p2.X == x && p2.Y == y)) ? (false) : (true);
            bool   ok         = cell.LineOfSight() && (CellHeight <= Gradient && !cell.HasUnWalkableFighter());

            if (!ok)
            {
                //fight.SendToFight(new FightShowCell(fight.Fighters[0].ActorId, CellId));
                return(boolean);
            }
            else
            {
                return(true);
            }
        }
Пример #2
0
        public static bool CheckView(Map Map, Fight fight, int Cell1, int Cell2)
        {
            Point Cell1_Point = new Point(GetCoordinates(Map, Cell1));
            Point Cell2_Point = new Point(GetCoordinates(Map, Cell2));

            FightCell cell1 = fight.GetCell(Cell1);
            FightCell cell2 = fight.GetCell(Cell2);

            double Cell1_ZSpriteOnID = !cell1.IsWalkable() ? (1.5) : (0);

            Cell1_ZSpriteOnID += cell1.HasUnWalkableFighter() ? (1.5) : (0);
            double Cell2_ZSpriteOnID = !cell2.IsWalkable() ? (1.5) : (0);

            Cell2_ZSpriteOnID += cell2.HasUnWalkableFighter() ? (1.5) : (0);

            Cell1_Point.Z = GetCellHeight(Map, Cell1) + Cell1_ZSpriteOnID;
            Cell2_Point.Z = GetCellHeight(Map, Cell2) + Cell2_ZSpriteOnID;

            double ZDiff     = Cell2_Point.Z - Cell1_Point.Z;
            double YZMaxDiff = Math.Max(Math.Abs(Cell1_Point.Y - Cell2_Point.Y), Math.Abs(Cell1_Point.X - Cell2_Point.X));

            double CoeffDirector      = (Cell1_Point.Y - Cell2_Point.Y) / (Cell1_Point.X - Cell2_Point.X);
            double YTranslation_Cell1 = Cell1_Point.Y - CoeffDirector * Cell1_Point.X;

            int XReport = Cell2_Point.X - Cell1_Point.X < 0 ? (-1) : (1);
            int YReport = Cell2_Point.Y - Cell1_Point.Y < 0 ? (-1) : (1);

            double Cell1_X = Cell1_Point.X;
            double Cell1_Y = Cell1_Point.Y;

            double XTranslation_Cell2 = Cell2_Point.X * XReport;
            double YTranslation_Cell2 = Cell2_Point.Y * YReport;
            double XTranslation_Cell1 = Cell1_Point.X + 0.5 * XReport;

            var _loc26 = Cell1_Y;

            while ((XTranslation_Cell1 += XReport) * XReport <= XTranslation_Cell2)
            {
                var _loc25 = CoeffDirector * XTranslation_Cell1 + YTranslation_Cell1;

                double _loc21 = 0;
                double _loc22 = 0;
                if (YReport > 0)
                {
                    _loc21 = Math.Round(_loc25);
                    _loc22 = Math.Ceiling(_loc25 - 0.5);
                }
                else
                {
                    _loc21 = Math.Ceiling(_loc25 - 0.5);
                    _loc22 = Math.Round(_loc25);
                } // end else if

                _loc26 = Cell1_Y;

                while ((_loc26 += YReport) * YReport <= _loc22 * YReport)
                {
                    if (!CheckCellView(Map, fight, XTranslation_Cell1 - XReport / 2, _loc26, false, Cell1_Point, Cell2_Point, ZDiff, YZMaxDiff))
                    {
                        return(false);
                    }
                }

                Cell1_Y = _loc21;
            }

            _loc26 = Cell1_Y;

            while ((_loc26 += YReport) * YReport <= Cell2_Point.Y * YReport)
            {
                if (!CheckCellView(Map, fight, XTranslation_Cell1 - 0.5 * XReport, _loc26, false, Cell1_Point, Cell2_Point, ZDiff, YZMaxDiff))
                {
                    return(false);
                }
            }

            if (!CheckCellView(Map, fight, XTranslation_Cell1 - 0.5 * XReport, _loc26 - YReport, true, Cell1_Point, Cell2_Point, ZDiff, YZMaxDiff))
            {
                return(false);
            }

            return(true);
        }