예제 #1
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);
            }
        }
예제 #2
0
        public bool TourRoles(ref SlimDX.Vector3 loc, float radius, UInt32 actorTypes, FOnVisitRole visit, object arg, List <RoleActor> outActors = null)
        {
            float startX   = loc.X - radius;
            float endX     = loc.X + radius;
            float startZ   = loc.Z - radius;
            float endZ     = loc.Z + radius;
            var   mapCells = GetMapCell(startX, startZ, endX, endZ);

            if (mapCells == null)
            {
                return(false);
            }

            for (var i = 0; i < mapCells.Count(); i++) //方便查看第几个格子
            {
                if (false == TourCellInner(mapCells[i], ref loc, radius, actorTypes, visit, arg, outActors))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
        public bool TourRoles(SlimDX.BoundingBox absBox, List <SlimDX.Matrix> invMatList, UInt32 actorTypes, FOnVisitRole visit, object arg)
        {
            if (invMatList.Count == 0)
            {
                return(true);
            }

            var mapCells = GetMapCell(absBox.Minimum.X, absBox.Minimum.Z, absBox.Maximum.X, absBox.Maximum.Z);

            if (mapCells == null)
            {
                return(false);
            }

            for (var i = 0; i < mapCells.Count(); i++) //方便查看第几个格子
            {
                if (false == TourCellInner(mapCells[i], invMatList, actorTypes, visit, arg))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #4
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);
            }
        }