Beispiel #1
0
        public bool CanBeSeenOld(short from, short to, bool throughEntities = false)
        {
            bool result;

            if (from == to)
            {
                result = true;
            }
            else
            {
                short[] array = new short[0];
                if (!throughEntities)
                {
                    array = (
                        from x in this.GetAllFighters(true)
                        select x.CellId).ToArray <short>();
                }
                System.Collections.Generic.IEnumerable <MapPoint> cellsInLine = MapPoint.GetPoint(from).GetCellsInLine(MapPoint.GetPoint(to));
                foreach (MapPoint current in cellsInLine.Skip(1))
                {
                    if (to != current.CellId)
                    {
                        short cell = current.CellId;
                        if (!Map.LineOfSight(cell) || (!throughEntities && System.Array.IndexOf <short>(array, current.CellId) != -1))
                        {
                            result = false;
                            return(result);
                        }
                    }
                }
                result = true;
            }

            return(result);
        }
        public bool CanBeSeen(Cell from, Cell to, bool throughEntities = false)
        {
            bool result;

            if (from == null || to == null)
            {
                result = false;
            }
            else
            {
                if (from == to)
                {
                    result = true;
                }
                else
                {
                    short[] array = new short[0];
                    if (!throughEntities)
                    {
                        array = (
                            from x in this.Objects
                            where x.BlockSight
                            select x.Cell.Id).ToArray <short>();
                    }
                    System.Collections.Generic.IEnumerable <MapPoint> cellsInLine = MapPoint.GetPoint(from).GetCellsInLine(MapPoint.GetPoint(to));
                    foreach (MapPoint current in cellsInLine.Skip(1))
                    {
                        if (to.Id != current.CellId)
                        {
                            Cell cell = this.Cells[(int)current.CellId];
                            if (!cell.LineOfSight || (!throughEntities && System.Array.IndexOf <short>(array, current.CellId) != -1))
                            {
                                result = false;
                                return(result);
                            }
                        }
                    }
                    result = true;
                }
            }
            return(result);
        }