当前位置: 首页>>代码示例>>C#>>正文


C# Object.GetDistance方法代码示例

本文整理汇总了C#中Object.GetDistance方法的典型用法代码示例。如果您正苦于以下问题:C# Object.GetDistance方法的具体用法?C# Object.GetDistance怎么用?C# Object.GetDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Object的用法示例。


在下文中一共展示了Object.GetDistance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateRange

        public bool UpdateRange(Object CurObj, bool ForceUpdate = false)
        {
            if (CurObj.IsActive == false || CurObj.IsDisposed)
                return false;

            if (CurObj.X == 0 && CurObj.Y == 0)
                return false;

            float Distance = CurObj.GetDistance(CurObj.LastRangeCheck);
            if (Distance > 100 || ForceUpdate)
            {
                CurObj.LastRangeCheck.X = CurObj.X;
                CurObj.LastRangeCheck.Y = CurObj.Y;
            }
            else 
                return false;

            CurObj.OnRangeUpdate();

            GetRangedObject(CurObj, 1, (Object DistObj) =>
                {
                    if (DistObj == null)
                        return;

                    if (IsVisibleBForA(CurObj, DistObj) && !CurObj.HasInRange(DistObj))
                    {
                        CurObj.AddInRange(DistObj);
                        DistObj.AddInRange(CurObj);

                        if (CurObj.IsPlayer())
                            DistObj.SendMeTo(CurObj.GetPlayer());

                        if (DistObj.IsPlayer())
                            CurObj.SendMeTo(DistObj.GetPlayer());
                    }
                });

            Object dist;
            for (int i = 0; i < CurObj._ObjectRanged.Count; ++i)
            {
                if ((dist = CurObj._ObjectRanged[i]) == null)
                    continue;

                if (CurObj == null || dist == null)
                    continue;

                if (dist.GetDistance(CurObj) > MAX_VISIBILITY_RANGE || !IsVisibleBForA(CurObj, dist))
                {
                    CurObj.RemoveInRange(dist);
                    dist.RemoveInRange(CurObj);
                    i--;
                }
            }

            return true;
        }
开发者ID:dzikun,项目名称:WarEmu,代码行数:56,代码来源:RegionMgr.cs

示例2: UpdateRange

        public bool UpdateRange(Object CurObj)
        {
            float Distance = CurObj.GetDistance(CurObj.LastRangeCheck);
            if (Distance > 100)
            {
                CurObj.LastRangeCheck.X = CurObj.X;
                CurObj.LastRangeCheck.Y = CurObj.Y;
            }
            else
                return false;

            List<Object> Objects = GetRangedObject(CurObj, 1);

            foreach (Object DistObj in Objects) // Ici on check tous les objets visibles
            {
                if(CurObj == DistObj)
                    continue;

                if (DistObj.IsPlayer() && !DistObj.GetPlayer().Client.IsPlaying())
                    continue;

                if(!CurObj.HasInRange(DistObj))
                {
                    CurObj.AddInRange(DistObj);
                    DistObj.AddInRange(CurObj);

                    if (CurObj.IsPlayer())
                        DistObj.SendMeTo(CurObj.GetPlayer());

                    if (DistObj.IsPlayer())
                        CurObj.SendMeTo(DistObj.GetPlayer());
                }
                else
                {

                }
            }

            List<Object> ToDel = CurObj._ObjectRanged.FindAll(dist => dist != null && dist.GetDistance(CurObj) > MAX_VISIBILITY_RANGE);
            foreach (Object Dist in ToDel)
            {
                CurObj.RemoveInRange(Dist);
                Dist.RemoveInRange(CurObj);
            }

            return true;
        }
开发者ID:Necrosummon,项目名称:WarEmu,代码行数:47,代码来源:RegionMgr.cs

示例3: GetRangedObject

        public void GetRangedObject(Object Obj, int Range, RangedObjectDelegate RangeFunction)
        {
            if (!Obj.IsInWorld())
                return;

            GetCells(Obj.XOffset, Obj.YOffset, Range, (CellMgr Cell) =>
            {
                Object DistObject = null;
                for(int i=0;i<Cell._Objects.Count;++i)
                {
                    if ((DistObject = Cell._Objects[i]) == null)
                    {
                        Cell._Objects.RemoveAt(i);
                        i--;
                    }
                    else if (Obj.GetDistance(DistObject) <= MAX_VISIBILITY_RANGE)
                        RangeFunction(DistObject);
                }
            });
        }
开发者ID:dzikun,项目名称:WarEmu,代码行数:20,代码来源:RegionMgr.cs

示例4: GetRangedObject

        public List<Object> GetRangedObject(Object Obj, int Range)
        {
            List<Object> Objs = new List<Object>();

            if (!Obj.IsInWorld())
                return Objs;

            List<CellMgr> Cells = GetCells(Obj.XOffset, Obj.YOffset, Range);
            foreach (CellMgr Cell in Cells)
                Objs.AddRange(Cell._Objects);

            Objs.RemoveAll(Dist => Dist != null && Obj.GetDistance(Dist) > MAX_VISIBILITY_RANGE);

            return Objs;
        }
开发者ID:Necrosummon,项目名称:WarEmu,代码行数:15,代码来源:RegionMgr.cs


注:本文中的Object.GetDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。