Exemplo n.º 1
0
 public double DistanceTo(Position pos)
 {
     double dx = Math.Pow(x-pos.x,2);
     double dy = Math.Pow(y-pos.y,2);
     double dz = Math.Pow(z-pos.z,2);
     return Math.Sqrt(dx+dy+dz);
 }
Exemplo n.º 2
0
		public Level(short width,short depth,short height) {
			this.width = width;
			this.depth = depth;
			this.height = height;
			mapdata = new byte[width*depth*height];
			blockdata = new byte[width*depth*height];
			spawn = new Position(width*16+16,depth*16+32,height*16+16,0,0);
		}
Exemplo n.º 3
0
 public void Set(Position pos)
 {
     Set(pos.x,pos.y,pos.z,pos.rotx,pos.roty);
 }
Exemplo n.º 4
0
		public bool IsInside(Position pos) {
			return (pos.X>=x1*32 && pos.Y>=y1*32 && pos.Z>=z1*32 &&
			        pos.X<x2*32 && pos.Y<y2*32 && pos.Z<z2*32);
		}
Exemplo n.º 5
0
		public void Teleport(Position pos) {
			Protocol.TeleportPacket(0xFF,pos).Send(this);
		}
Exemplo n.º 6
0
		public void Spawn(Position pos) {
			Protocol.SpawnPacket(0xFF,name,pos).Send(this);
		}
Exemplo n.º 7
0
		public static Level Load(string name) {
			if (name==null) { throw new ArgumentNullException("name"); }
			if (name=="") { throw new ArgumentException("Name musn't be an empty string.","name"); }
			if (!RegexHelper.IsAlphaNumeric(name)) {
				throw new ArgumentException("Only alphanumerical characters allowed.","name");
			} string filename = "levels/"+name+".lvl";
			try {
				Node node = host.Load(filename,out name);
				if (name!="obsidian-level") { return null; }
				short width = (short)node["width"].Value;
				short depth = (short)node["depth"].Value;
				short height = (short)node["height"].Value;
				Node spawnNode = node["spawn"];
				Position spawn = new Position(
					(short)spawnNode["x"].Value,(short)spawnNode["y"].Value,(short)spawnNode["z"].Value,
					(byte)spawnNode["rotx"].Value,(byte)spawnNode["roty"].Value);
				byte[] mapdata = (byte[])node["mapdata"].Value;
				byte[] blockdata = (byte[])node["blockdata"].Value;
				Level level = new Level(width,depth,height);
				level.spawn.Set(spawn);
				level.mapdata = mapdata;
				level.blockdata = blockdata;
				level.custom = node["custom"]??level.custom;
				return level;
			} catch { return null; }
		}
Exemplo n.º 8
0
		public List<Region> RegionsAt(Position pos) {
			List<Region> regs = new List<Region>();
			foreach (Region region in regions) {
				if (region.IsInside(pos)) { regs.Add(region); }
			} return regs;
		}