Esempio n. 1
0
        public Point GetRespawn()
        {
            if (SafePoints == null)
            {
                SafePoints = new List <Point>();
                for (var y = SafeArea.Y; y < SafeArea.Bottom; y++)
                {
                    for (var x = SafeArea.X; x < SafeArea.Right; x++)
                    {
                        var cell = Layer[x + y * 256];
                        if ((cell & (MapAttributes.NoWalk | MapAttributes.Hide)) == 0)
                        {
                            SafePoints.Add(new Point(x, y));
                        }
                    }
                }
            }
            if (SafePoints.Any())
            {
                var rand = Program.RandomProvider(SafePoints.Count());
                var id   = SafePoints[rand];
                return(id);
            }
            else
            {
                var p = ResourceCache.Instance.GetGates().Values
                        .First(x => x.Map == (Maps)Map)
                        .Door.Location;

                SafePoints.Add(p);
            }

            return(new Point());
        }
Esempio n. 2
0
        public Point GetRespawn()
        {
            if (SafePoints == null)
            {
                SafePoints = new List <Point>();
                for (var y = SafeArea.Y; y < SafeArea.Bottom; y++)
                {
                    for (var x = SafeArea.X; x < SafeArea.Right; x++)
                    {
                        var cell = Layer[x + y * 256];
                        if ((cell & 4) != 4 && (cell & 8) != 8)
                        {
                            SafePoints.Add(new Point(x, y));
                        }
                    }
                }
            }
            if (SafePoints.Any())
            {
                var rand = new Random().Next(SafePoints.Count());
                var id   = SafePoints[rand];
                return(id);
            }
            else
            {
                var p = ResourceCache.Instance.GetGates().Values
                        .First(x => x.Map == (Maps)Map)
                        .Door.Location;

                SafePoints.Add(p);
            }

            return(new Point());
        }