Exemplo n.º 1
0
        public void InitSurface(bool bDoInit, FieldObj inFieldObj, int inFakeSightRange)
        {
            this.UninitSurface();
            GC.Collect();
            this.m_pFieldObj = inFieldObj;
            this.m_halfSizeX = this.m_pFieldObj.PaneX / 2 - 100;
            this.m_halfSizeY = this.m_pFieldObj.PaneY / 2 - 100;
            DebugHelper.Assert(this.m_halfSizeX > 0);
            DebugHelper.Assert(this.m_halfSizeY > 0);
            if (Application.isPlaying)
            {
                Player hostPlayer = Singleton <GamePlayerCenter> .get_instance().GetHostPlayer();

                DebugHelper.Assert(hostPlayer != null, "InitSurface hostPlayer is null");
                if (hostPlayer != null)
                {
                    this.m_hostPlayerCamp = hostPlayer.PlayerCamp;
                }
                this.SetCallBack();
                GameFowManager.InitGameFowMapData(this.m_pFieldObj.NumX, this.m_pFieldObj.NumY, 0, 255, this.InterpolateFrameInterval, inFakeSightRange, this.m_hostPlayerCamp);
                this.m_commitBitMap = new byte[this.m_pFieldObj.NumX * this.m_pFieldObj.NumY];
                this.m_collector    = new GameFowCollector();
                this.m_collector.InitSurface();
            }
            this.m_los = new FowLos();
            this.m_los.Init();
            this.m_gpuInterpFrameInterval = (uint)MonoSingleton <GlobalConfig> .get_instance().GPUInterpolateFrameInterval;

            this.m_gpuInterpReciprocal = 1f / this.m_gpuInterpFrameInterval;
        }
Exemplo n.º 2
0
        public static bool VisitFowVisibilityCheck(VCollisionBox box, PoolObjHandle <ActorRoot> inActor, COM_PLAYERCAMP inHostCamp, GameFowManager fowMgr)
        {
            VInt2 zero = VInt2.zero;

            if (fowMgr.WorldPosToGrid(new VInt3(box.WorldPos.x, box.WorldPos.z, 0), out zero.x, out zero.y))
            {
                FieldObj pFieldObj = fowMgr.m_pFieldObj;
                int      num       = 0;
                int      num2;
                pFieldObj.UnrealToGridX(box.WorldExtends.x, out num2);
                pFieldObj.UnrealToGridX(box.WorldExtends.z, out num);
                int num3 = zero.x - num2;
                num3 = Math.Max(0, num3);
                int num4 = zero.x + num2;
                num4 = Math.Min(num4, pFieldObj.NumX - 1);
                int num5 = zero.y - num;
                num5 = Math.Max(0, num5);
                int num6 = zero.y + num;
                num6 = Math.Min(num6, pFieldObj.NumY - 1);
                for (int i = num3; i <= num4; i++)
                {
                    for (int j = num5; j <= num6; j++)
                    {
                        bool flag = Singleton <GameFowManager> .get_instance().IsVisible(i, j, inHostCamp);

                        if (flag)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
        public static bool VisitFowVisibilityCheck(VCollisionCylinderSector cylinder, PoolObjHandle <ActorRoot> inActor, COM_PLAYERCAMP inHostCamp, GameFowManager fowMgr)
        {
            VInt2 zero = VInt2.zero;

            fowMgr.WorldPosToGrid(new VInt3(cylinder.WorldPos.x, cylinder.WorldPos.z, 0), out zero.x, out zero.y);
            float num = (float)cylinder.Radius;

            num *= 0.001f;
            num *= num;
            Vector3 vector = (Vector3)cylinder.WorldPos;
            float   num2   = (float)cylinder.Degree;

            num2 *= 0.5f;
            num2  = Mathf.Cos(num2);
            Vector3  vector2   = (Vector3)cylinder.WorldPos;
            Vector3  vector3   = (Vector3)inActor.handle.forward;
            FieldObj pFieldObj = fowMgr.m_pFieldObj;
            int      num3      = 0;

            pFieldObj.UnrealToGridX(cylinder.Radius, out num3);
            int num4 = zero.x - num3;

            num4 = Math.Max(0, num4);
            int num5 = zero.x + num3;

            num5 = Math.Min(num5, pFieldObj.NumX - 1);
            int num6 = zero.y - num3;

            num6 = Math.Max(0, num6);
            int num7 = zero.y + num3;

            num7 = Math.Min(num7, pFieldObj.NumY - 1);
            for (int i = num4; i <= num5; i++)
            {
                for (int j = num6; j <= num7; j++)
                {
                    bool flag = Singleton <GameFowManager> .instance.IsVisible(i, j, inHostCamp);

                    if (flag && GameFowCollector.IsPointInCircularSector2(vector.x, vector.z, vector3.x, vector3.z, num, num2, vector2.x, vector2.z))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 4
0
        private Dictionary <byte, FowLos.SBlockContext> CreateBlockMap()
        {
            Dictionary <byte, FowLos.SBlockContext> dictionary = new Dictionary <byte, FowLos.SBlockContext>();

            FieldObj.FOGridInfo gridInfo = this.LevelGrid.GridInfo;
            int cellNumX = gridInfo.CellNumX;
            int cellNumY = gridInfo.CellNumY;
            int num      = cellNumX * cellNumY;
            Dictionary <byte, List <int> > dictionary2 = new Dictionary <byte, List <int> >();

            for (int i = 0; i < num; i++)
            {
                FieldObj.FOGridCell fOGridCell = this.LevelGrid.GridCells[i];
                byte viewBlockId = fOGridCell.m_viewBlockId;
                if (this.IsAreaViewBlocking(viewBlockId))
                {
                    List <int> list = null;
                    if (dictionary2.TryGetValue(viewBlockId, ref list))
                    {
                        list.Add(i);
                    }
                    else
                    {
                        list = new List <int>();
                        list.Add(i);
                        dictionary2.Add(viewBlockId, list);
                    }
                }
            }
            Dictionary <byte, List <int> > .Enumerator enumerator = dictionary2.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <byte, List <int> > current = enumerator.get_Current();
                List <int> value = current.get_Value();
                KeyValuePair <byte, List <int> > current2 = enumerator.get_Current();
                byte       key   = current2.get_Key();
                List <int> list2 = new List <int>();
                int        num2  = 2147483647;
                int        num3  = 2147483647;
                int        num4  = -2147483647;
                int        num5  = -2147483647;
                int        count = value.get_Count();
                for (int j = 0; j < count; j++)
                {
                    int num6 = value.get_Item(j);
                    FieldObj.FOGridCell fOGridCell2 = this.LevelGrid.GridCells[num6];
                    int cellX = (int)fOGridCell2.CellX;
                    int cellY = (int)fOGridCell2.CellY;
                    if (num2 > cellX)
                    {
                        num2 = cellX;
                    }
                    if (num4 < cellX)
                    {
                        num4 = cellX;
                    }
                    if (num3 > cellY)
                    {
                        num3 = cellY;
                    }
                    if (num5 < cellY)
                    {
                        num5 = cellY;
                    }
                    List <int> list3 = new List <int>();
                    bool       flag  = false;
                    if (cellX > 0)
                    {
                        list3.Add(num6 - 1);
                    }
                    else
                    {
                        list2.Add(num6);
                        flag = true;
                    }
                    if (!flag)
                    {
                        if (cellX < cellNumX - 1)
                        {
                            list3.Add(num6 + 1);
                        }
                        else
                        {
                            list2.Add(num6);
                            flag = true;
                        }
                        if (!flag)
                        {
                            if (cellY > 0)
                            {
                                list3.Add(num6 - cellNumX);
                            }
                            else
                            {
                                list2.Add(num6);
                                flag = true;
                            }
                            if (!flag)
                            {
                                if (cellY < cellNumY - 1)
                                {
                                    list3.Add(num6 + cellNumX);
                                }
                                else
                                {
                                    list2.Add(num6);
                                    flag = true;
                                }
                                if (!flag)
                                {
                                    int count2 = list3.get_Count();
                                    for (int k = 0; k < count2; k++)
                                    {
                                        int num7 = list3.get_Item(k);
                                        if (!value.Contains(num7))
                                        {
                                            list2.Add(num6);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                FowLos.SBlockContext sBlockContext = default(FowLos.SBlockContext);
                sBlockContext.ParamlessConstruct();
                sBlockContext.m_areaId = (int)key;
                int num8  = gridInfo.GridPos.x + gridInfo.CellSizeX * (num4 + 1);
                int num9  = gridInfo.GridPos.y + gridInfo.CellSizeY * (num5 + 1);
                int num10 = gridInfo.GridPos.x + gridInfo.CellSizeX * num2;
                int num11 = gridInfo.GridPos.y + gridInfo.CellSizeY * num3;
                sBlockContext.m_bounds.Origin.x    = (num8 + num10) / 2;
                sBlockContext.m_bounds.Origin.y    = (num9 + num11) / 2;
                sBlockContext.m_bounds.Origin.z    = 0;
                sBlockContext.m_bounds.BoxExtent.x = (num8 - num10) / 2;
                sBlockContext.m_bounds.BoxExtent.y = (num9 - num11) / 2;
                sBlockContext.m_bounds.BoxExtent.z = 1000;
                DebugHelper.Assert(num2 <= 255);
                DebugHelper.Assert(num4 <= 255);
                DebugHelper.Assert(num3 <= 255);
                DebugHelper.Assert(num5 <= 255);
                sBlockContext.m_xMin = (byte)num2;
                sBlockContext.m_xMax = (byte)num4;
                sBlockContext.m_yMin = (byte)num3;
                sBlockContext.m_yMax = (byte)num5;
                int count3 = list2.get_Count();
                List <FowLos.SPolylineSegment> list4 = new List <FowLos.SPolylineSegment>();
                for (int l = num3; l <= num5; l++)
                {
                    Dictionary <int, int> dictionary3 = new Dictionary <int, int>();
                    for (int m = 0; m < count3; m++)
                    {
                        int num12 = list2.get_Item(m);
                        FieldObj.FOGridCell fOGridCell3 = this.LevelGrid.GridCells[num12];
                        int cellX2 = (int)fOGridCell3.CellX;
                        int cellY2 = (int)fOGridCell3.CellY;
                        if (cellY2 == l)
                        {
                            dictionary3.Add(cellX2, num12);
                        }
                    }
                    List <FowLos.SPolylineSegment> list5 = new List <FowLos.SPolylineSegment>();
                    List <FowLos.SPolylineSegment> list6 = new List <FowLos.SPolylineSegment>();
                    int num13 = -1;
                    int num14 = -1;
                    Dictionary <int, int> .Enumerator enumerator2 = dictionary3.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        KeyValuePair <int, int> current3 = enumerator2.get_Current();
                        int value2 = current3.get_Value();
                        FieldObj.FOGridCell fOGridCell4 = this.LevelGrid.GridCells[value2];
                        int   cellX3 = (int)fOGridCell4.CellX;
                        int   cellY3 = (int)fOGridCell4.CellY;
                        VInt2 start  = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * cellX3, gridInfo.GridPos.y + gridInfo.CellSizeY * cellY3);
                        VInt2 end    = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * (cellX3 + 1), gridInfo.GridPos.y + gridInfo.CellSizeY * (cellY3 + 1));
                        VInt2 start2 = new VInt2(start.x, end.y);
                        VInt2 end2   = new VInt2(end.x, start.y);
                        if (cellY3 == 0 || key != this.LevelGrid.GridCells[value2 - cellNumX].m_viewBlockId)
                        {
                            if (num13 != -1 && cellX3 == num13 + 1)
                            {
                                if (list6.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment = new FowLos.SPolylineSegment(list6.get_Item(list6.get_Count() - 1));
                                    sPolylineSegment.m_end = end2;
                                    list6.set_Item(list6.get_Count() - 1, sPolylineSegment);
                                }
                                else
                                {
                                    list6.Add(new FowLos.SPolylineSegment(start, end2));
                                }
                            }
                            else
                            {
                                list6.Add(new FowLos.SPolylineSegment(start, end2));
                            }
                            num13 = cellX3;
                        }
                        if (cellY3 == cellNumY - 1 || key != this.LevelGrid.GridCells[value2 + cellNumX].m_viewBlockId)
                        {
                            if (num14 != -1 && cellX3 == num14 + 1)
                            {
                                if (list5.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment2 = new FowLos.SPolylineSegment(list5.get_Item(list5.get_Count() - 1));
                                    sPolylineSegment2.m_end = end;
                                    list5.set_Item(list5.get_Count() - 1, sPolylineSegment2);
                                }
                                else
                                {
                                    list5.Add(new FowLos.SPolylineSegment(start2, end));
                                }
                            }
                            else
                            {
                                list5.Add(new FowLos.SPolylineSegment(start2, end));
                            }
                            num14 = cellX3;
                        }
                    }
                    FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                    FieldObj.MergeBlockSegList(ref sBlockContext, list6, (int)key);
                    list4 = list5;
                }
                FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                list4.Clear();
                DebugHelper.Assert(sBlockContext.m_polylineSegList.get_Count() >= 2);
                for (int n = num2; n <= num4; n++)
                {
                    Dictionary <int, int> dictionary4 = new Dictionary <int, int>();
                    for (int num15 = 0; num15 < count3; num15++)
                    {
                        int num16 = list2.get_Item(num15);
                        FieldObj.FOGridCell fOGridCell5 = this.LevelGrid.GridCells[num16];
                        int cellX4 = (int)fOGridCell5.CellX;
                        int cellY4 = (int)fOGridCell5.CellY;
                        if (cellX4 == n)
                        {
                            dictionary4.Add(cellY4, num16);
                        }
                    }
                    List <FowLos.SPolylineSegment> list7 = new List <FowLos.SPolylineSegment>();
                    List <FowLos.SPolylineSegment> list8 = new List <FowLos.SPolylineSegment>();
                    int num17 = -1;
                    int num18 = -1;
                    Dictionary <int, int> .Enumerator enumerator3 = dictionary4.GetEnumerator();
                    while (enumerator3.MoveNext())
                    {
                        KeyValuePair <int, int> current4 = enumerator3.get_Current();
                        int value3 = current4.get_Value();
                        FieldObj.FOGridCell fOGridCell6 = this.LevelGrid.GridCells[value3];
                        int   cellX5 = (int)fOGridCell6.CellX;
                        int   cellY5 = (int)fOGridCell6.CellY;
                        VInt2 start3 = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * cellX5, gridInfo.GridPos.y + gridInfo.CellSizeY * cellY5);
                        VInt2 end3   = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * (cellX5 + 1), gridInfo.GridPos.y + gridInfo.CellSizeY * (cellY5 + 1));
                        VInt2 end4   = new VInt2(start3.x, end3.y);
                        VInt2 start4 = new VInt2(end3.x, start3.y);
                        if (cellX5 == 0 || key != this.LevelGrid.GridCells[value3 - 1].m_viewBlockId)
                        {
                            if (num17 != -1 && cellY5 == num17 + 1)
                            {
                                if (list8.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment3 = new FowLos.SPolylineSegment(list8.get_Item(list8.get_Count() - 1));
                                    sPolylineSegment3.m_end = end4;
                                    list8.set_Item(list8.get_Count() - 1, sPolylineSegment3);
                                }
                                else
                                {
                                    list8.Add(new FowLos.SPolylineSegment(start3, end4));
                                }
                            }
                            else
                            {
                                list8.Add(new FowLos.SPolylineSegment(start3, end4));
                            }
                            num17 = cellY5;
                        }
                        if (cellX5 == cellNumX - 1 || key != this.LevelGrid.GridCells[value3 + 1].m_viewBlockId)
                        {
                            if (num18 != -1 && cellY5 == num18 + 1)
                            {
                                if (list7.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment4 = new FowLos.SPolylineSegment(list7.get_Item(list7.get_Count() - 1));
                                    sPolylineSegment4.m_end = end3;
                                    list7.set_Item(list7.get_Count() - 1, sPolylineSegment4);
                                }
                                else
                                {
                                    list7.Add(new FowLos.SPolylineSegment(start4, end3));
                                }
                            }
                            else
                            {
                                list7.Add(new FowLos.SPolylineSegment(start4, end3));
                            }
                            num18 = cellY5;
                        }
                    }
                    FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                    FieldObj.MergeBlockSegList(ref sBlockContext, list8, (int)key);
                    list4 = list7;
                }
                FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                list4.Clear();
                DebugHelper.Assert(sBlockContext.m_polylineSegList.get_Count() >= 4);
                int count4 = sBlockContext.m_polylineVertices.get_Count();
                for (int num19 = 0; num19 < count4; num19++)
                {
                    FowLos.SPolylineVertex sPolylineVertex = sBlockContext.m_polylineVertices.get_Item(num19);
                    DebugHelper.Assert(sPolylineVertex.m_bNative);
                    DebugHelper.Assert(sPolylineVertex.m_belongBlockId != -1);
                    DebugHelper.Assert(sPolylineVertex.m_belongSegNoList.get_Count() <= 4);
                    DebugHelper.Assert(sPolylineVertex.m_belongSegNoList.get_Count() >= 2);
                }
                int count5 = sBlockContext.m_polylineSegList.get_Count();
                for (int num20 = 0; num20 < count5; num20++)
                {
                    FowLos.SPolylineSegment sPolylineSegment5 = sBlockContext.m_polylineSegList.get_Item(num20);
                    DebugHelper.Assert(sPolylineSegment5.m_index == num20);
                    DebugHelper.Assert(sPolylineSegment5.m_belongBlockId != -1);
                    DebugHelper.Assert(sPolylineSegment5.m_startPtIndex != -1);
                    DebugHelper.Assert(sPolylineSegment5.m_endPtIndex != -1);
                }
                sBlockContext.m_blockerGridIndexList = value;
                if (dictionary.ContainsKey(key))
                {
                    dictionary.set_Item(key, sBlockContext);
                }
                else
                {
                    dictionary.Add(key, sBlockContext);
                }
            }
            return(dictionary);
        }
Exemplo n.º 5
0
 public bool QueryAttr(FieldObj inFieldObj, out FieldObj.SViewBlockAttr outAttr)
 {
     return(inFieldObj.ViewBlockAttrMap.TryGetValue(this.m_viewBlockId, ref outAttr));
 }