Ejemplo n.º 1
0
        public bool InitMap(PlanesInstance planes, ushort index, ulong mapInstanceId, TableWrap.MapInfoData info, PlayerInstance creater)
        {
            mPlanes        = planes;
            mOwner         = creater;
            mIndexInServer = index;
            mMapInfo       = info;
            //             mMapInfo = MapInstanceManager.GetMapInitBySourceId(mapSourceId);
            //             if (mMapInfo == null)
            //                 return false;
            //mUUID = mapInstanceId;

            mMapInstanceId = mapInstanceId;
            mMapSourceId   = (ushort)info.MapData.id;// mapSourceId;
            InitPlayerPool((ushort)mMapInfo.MapData.maxPlayerCount);
            mNavigator = NavigatorMgr.Instance.InitNavigator(mMapSourceId, GetNavFilePath(mMapInfo.MapData.name));

            // 从地图数据中创建实例数据
            m_cellXCount = (int)(mMapInfo.MapData.sizeX / mServerMapCellWidth) + ((mMapInfo.MapData.sizeX % mServerMapCellWidth) > 0 ? 1 : 0);
            m_cellZCount = (int)(mMapInfo.MapData.sizeZ / mServerMapCellHeight) + ((mMapInfo.MapData.sizeZ % mServerMapCellHeight) > 0 ? 1 : 0);

            m_mapCells = new MapCellInstance[m_cellZCount, m_cellXCount];
            for (int i = 0; i < m_cellZCount; i++)
            {
                for (int j = 0; j < m_cellXCount; j++)
                {
                    MapCellInstance mapCell = new MapCellInstance(j, i);
                    m_mapCells[i, j] = mapCell;
                }
            }

            //LoadMapData();
            OnInit();
            return(true);
        }
Ejemplo n.º 2
0
        bool TourCellInner(MapCellInstance cell, ref SlimDX.Vector3 loc, float radius, UInt32 actorTypes, FOnVisitRole visit, object arg, List <RoleActor> outActors = null)
        {
            try
            {
                if ((actorTypes & (1 << (Int32)eActorGameType.Player)) != 0)
                {
                    for (int i = 0; i < cell.Players.Count; i++)
                    {
                        var ply = cell.Players[i];
                        if (ply == null)
                        {
                            continue;
                        }

                        float dist = Util.DistanceH(loc, ply.GetPosition());
                        if (dist > radius)
                        {
                            continue;
                        }

                        if (visit != null && visit(ply, arg) == false)
                        {
                            continue;
                        }

                        if (outActors != null)
                        {
                            outActors.Add(ply);
                        }
                    }
                }
                if ((actorTypes & (1 << (Int32)eActorGameType.PlayerImage)) != 0)
                {
                    for (int i = 0; i < cell.Images.Count; i++)
                    {
                        var img = cell.Images[i];
                        if (img == null)
                        {
                            continue;
                        }

                        float dist = Util.DistanceH(loc, img.GetPosition());
                        if (dist > radius)
                        {
                            continue;
                        }

                        if (visit != null && visit(img, arg) == false)
                        {
                            continue;
                        }

                        if (outActors != null)
                        {
                            outActors.Add(img);
                        }
                    }
                }
                if ((actorTypes & (1 << (Int32)eActorGameType.Npc)) != 0)
                {
                    for (int i = 0; i < cell.NPCs.Count; i++)
                    {
                        var npc = cell.NPCs[i];
                        if (npc == null)
                        {
                            continue;
                        }

                        float dist = Util.DistanceH(loc, npc.GetPosition());
                        if (dist > radius)
                        {
                            continue;
                        }

                        if (visit != null && visit(npc, arg) == false)
                        {
                            continue;
                        }

                        if (outActors != null)
                        {
                            outActors.Add(npc);
                        }
                    }
                }
                return(true);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("TourCellInner1 foreach except\r\n" + ex.ToString());
                return(true);
            }
        }
Ejemplo n.º 3
0
        bool TourCellInner(MapCellInstance cell, List <SlimDX.Matrix> invMatList, UInt32 actorTypes, FOnVisitRole visit, object arg, List <RoleActor> outActors = null)
        {
            try
            {
                if ((actorTypes & (1 << (Int32)eActorGameType.Player)) != 0)
                {
                    for (int i = 0; i < cell.Players.Count; i++)
                    {
                        var ply = cell.Players[i];
                        if (ply == null)
                        {
                            continue;
                        }

                        var tarLoc = ply.GetPosition();
                        foreach (var invMat in invMatList)
                        {
                            //var ctype = SlimDX.BoundingBox.Contains(box, tarLoc);
                            //if(ctype!=SlimDX.ContainmentType.Contains)
                            //    continue;
                            if (IsPositionIn(tarLoc, invMat) == false)
                            {
                                continue;
                            }

                            if (visit != null && visit(ply, arg) == false)
                            {
                                continue;
                            }

                            if (outActors != null)
                            {
                                outActors.Add(ply);
                            }
                        }
                    }
                }
                if ((actorTypes & (1 << (Int32)eActorGameType.PlayerImage)) != 0)
                {
                    for (int i = 0; i < cell.Images.Count; i++)
                    {
                        var img = cell.Images[i];
                        if (img == null)
                        {
                            continue;
                        }

                        var tarLoc = img.GetPosition();
                        foreach (var invMat in invMatList)
                        {
                            //var ctype = SlimDX.BoundingBox.Contains(box, tarLoc);
                            //if(ctype!=SlimDX.ContainmentType.Contains)
                            //    continue;
                            if (IsPositionIn(tarLoc, invMat) == false)
                            {
                                continue;
                            }

                            if (visit != null && visit(img, arg) == false)
                            {
                                continue;
                            }

                            if (outActors != null)
                            {
                                outActors.Add(img);
                            }
                        }
                    }
                }
                if ((actorTypes & (1 << (Int32)eActorGameType.Npc)) != 0)
                {
                    for (int i = 0; i < cell.NPCs.Count; i++)
                    {
                        var npc = cell.NPCs[i];
                        if (npc == null)
                        {
                            continue;
                        }

                        var tarLoc = npc.GetPosition();
                        foreach (var invMat in invMatList)
                        {
                            //var ctype = SlimDX.BoundingBox.Contains(box, tarLoc);
                            //if (ctype != SlimDX.ContainmentType.Contains)
                            //    continue;
                            if (IsPositionIn(tarLoc, invMat) == false)
                            {
                                continue;
                            }

                            if (visit != null && visit(npc, arg) == false)
                            {
                                continue;
                            }

                            if (outActors != null)
                            {
                                outActors.Add(npc);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (System.Exception)
            {
                System.Diagnostics.Debug.WriteLine("TourCellInner2 foreach except");
                return(true);
            }
        }