Example #1
0
        static Zone[] FindZones(int X, int Y)
        {
            Zone[] zone = new Zone[4];

            int Xfoo = (int)Math.Floor((decimal)(X / ChunkSize)) * ChunkSize;
            int Yfoo = (int)Math.Floor((decimal)(Y / ChunkSize)) * ChunkSize;

            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                {
                    zone[0] = z;
                }
            }
            if (zone[0] == null)
            {
                zone[0] = new Zone(new Rectangle(new Vector2f(Xfoo, Yfoo), new Vector2f(100, 100)));
                ZoneList.Add(zone[0]);
            }
            Xfoo = (int)Math.Ceiling((decimal)(X / ChunkSize)) * ChunkSize;
            Yfoo = (int)Math.Floor((decimal)(Y / ChunkSize)) * ChunkSize;
            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                {
                    zone[1] = z;
                }
            }
            if (zone[0] == null)
            {
                zone[0] = new Zone(new Rectangle(new Vector2f(Xfoo, Yfoo), new Vector2f(100, 100)));
                ZoneList.Add(zone[0]);
            }
            Xfoo = (int)Math.Ceiling((decimal)(X / ChunkSize)) * ChunkSize;
            Yfoo = (int)Math.Ceiling((decimal)(Y / ChunkSize)) * ChunkSize;
            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                {
                    zone[2] = z;
                }
            }
            if (zone[0] == null)
            {
                zone[0] = new Zone(new Rectangle(new Vector2f(Xfoo, Yfoo), new Vector2f(100, 100)));
                ZoneList.Add(zone[0]);
            }
            Xfoo = (int)Math.Floor((decimal)(X / ChunkSize)) * ChunkSize;
            Yfoo = (int)Math.Ceiling((decimal)(Y / ChunkSize)) * ChunkSize;
            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                {
                    zone[3] = z;
                }
            }
        }
Example #2
0
        static Zone[] FindZones(int X, int Y)
        {
            Zone[] zone = new Zone[4];

            int Xfoo = (int)Math.Floor((decimal)(X / ChunkSize)) * ChunkSize;
            int Yfoo = (int)Math.Floor((decimal)(Y / ChunkSize)) * ChunkSize;
            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                    zone[0] = z;
            }
            if (zone[0] == null)
            {
                zone[0] = new Zone(new Rectangle(new Vector2f(Xfoo, Yfoo), new Vector2f(100, 100)));
                ZoneList.Add(zone[0]);

            }
            Xfoo = (int)Math.Ceiling((decimal)(X / ChunkSize)) * ChunkSize;
            Yfoo = (int)Math.Floor((decimal)(Y / ChunkSize)) * ChunkSize;
            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                    zone[1] = z;
            }
            if (zone[0] == null)
            {
                zone[0] = new Zone(new Rectangle(new Vector2f(Xfoo, Yfoo), new Vector2f(100, 100)));
                ZoneList.Add(zone[0]);

            }
            Xfoo = (int)Math.Ceiling((decimal)(X / ChunkSize)) * ChunkSize;
            Yfoo = (int)Math.Ceiling((decimal)(Y / ChunkSize)) * ChunkSize;
            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                    zone[2] = z;
            }
            if (zone[0] == null)
            {
                zone[0] = new Zone(new Rectangle(new Vector2f(Xfoo, Yfoo), new Vector2f(100, 100)));
                ZoneList.Add(zone[0]);

            }
            Xfoo = (int)Math.Floor((decimal)(X / ChunkSize)) * ChunkSize;
            Yfoo = (int)Math.Ceiling((decimal)(Y / ChunkSize)) * ChunkSize;
            foreach (Zone z in ZoneList)
            {
                if (z.ZoneRectangle.X == Xfoo && z.ZoneRectangle.Y == Yfoo)
                    zone[3] = z;
            }
        }