예제 #1
0
	public void Editor_AddChunkAt(int x, int y, int depth, MapChunk chunkPrefab, bool placeAbsolute){
						
		ChunkSet cs = GetNodeAt(x,y);
				
		if(depth > mapUpperDepth){
			mapUpperDepth = depth;
		}
		
		if(depth < mapLowerDepth){
			mapLowerDepth = depth;
		}
		
		MapChunk mc = null;
		
		if(cs == null){
			cs = new ChunkSet();
			
			cs.InitializeChunkSet(this,x,y);
			
			AddNodeAt(cs,x,y);
			
			mc = GameObject.Instantiate(chunkPrefab) as MapChunk;
			
			mc.name = "MapChunk_"+x+"_"+y;
						
			cs.AddChunkAt(mc,depth);
			
			mc.Editor_Activate(chunkWidth,chunkHeight,cs.x,cs.y,depth,this,placeAbsolute);
						
			return;
		}
		else{
			
			if(cs.x != x){
				cs.x = x;
			}
			
			if(cs.y != y){
				cs.y = y;
			}
			
		}
				
		if(cs.GetChunkAt(depth,false) != null){
									
			return;
		}
		
		mc = GameObject.Instantiate(chunkPrefab) as MapChunk;
			
		mc.name = "MapChunk_"+x+"_"+y;
			
		//at this point we want to do a different activation, as the chunkset already exists
		//and this is therefore at a different depth
		cs.AddChunkAt(mc,depth);
		
		int upper = depth+1;
		int lower = depth-1;
		
		MapChunk u = cs.GetChunkAt(upper,false);
		MapChunk l = cs.GetChunkAt(lower,false);
				
		if(u != null){
			
			mc.Editor_ActivateBound(chunkWidth,chunkHeight,cs.x,cs.y,depth,this,u);
			
		}
		else if(l != null){
			
			mc.Editor_ActivateBound(chunkWidth,chunkHeight,cs.x,cs.y,depth,this,l);
			
		}
		else{
			
			mc.Editor_Activate(chunkWidth,chunkHeight,cs.x,cs.y,depth,this,placeAbsolute);
		}
				
	}