function LSouSouSMap(){
	var self = this;
	base(self,LSprite,[]);
	LSouSouObject.sMap = self;
	self.nodeLength = 48;
	self._objectData = null;
	self._loadBar = null;
	self.mapData = null;
	self.mapToCoordinate = new LPoint(0,0);
	self.mapW = 0;
	self.mapH = 0;
	self.SCREEN_WIDTH = 768;
	self.SCREEN_HEIGHT = 432;
	self.ourlist = [];
	self.enemylist = [];
	self.friendlist = [];
	self.smapClick = new LSouSouSMapClick();
	self.backLayer = new LSprite();
	self.mapLayer = new LSprite();
	self.roadLayer = new LSprite();
	self.roadLayer.alpha = 0.5;
	self.attackRangeLayer = new LSprite();
	self.attackRangeLayer.alpha = 0.5;
	self.charaLayer = new LSprite();
	self.viewMapLayer = new LSprite();
	self.menuLayer = new LSprite();
	self.mainLayer = new LSprite();
	self.mainLayer.graphics.drawRect(1,"#000000",[self.SCREEN_WIDTH,0,LGlobal.width - self.SCREEN_WIDTH,LGlobal.height],true,"#FFFFFF");
	self.menu = null;
	//暂时添加，后面会脚本化
	LSouSouObject.memberList.push(new LSouSouMember(LGlobal.chara["peo1"]));
	LSouSouObject.memberList.push(new LSouSouMember(LGlobal.chara["peo2"]));
	LSouSouObject.memberList.push(new LSouSouMember(LGlobal.chara["peo3"]));
	LSouSouObject.perWarList.push(LGlobal.chara["peo1"].Index);
	LSouSouObject.perWarList.push(LGlobal.chara["peo2"].Index);
	LSouSouObject.perWarList.push(LGlobal.chara["peo3"].Index);
	
	self.addChild(self.backLayer);
	self.backLayer.addChild(self.mapLayer);
	self.backLayer.addChild(self.roadLayer);
	self.backLayer.addChild(self.attackRangeLayer);
	self.backLayer.addChild(self.charaLayer);
	self.addChild(self.viewMapLayer);
	self.addChild(self.menuLayer);
	self.addChild(self.mainLayer);
	LGlobal.script.scriptLayer.addChild(self);
	LSouSouSMapScript.analysis();
	
	self.addEventListener(LEvent.ENTER_FRAME,self.onframe);

	self.smapClick.setClickEvent(); 
}
LSouSouSMap.prototype.setLocation = function(value){
	var self = this;
	self.mapToCoordinate.x = 384 - LSouSouObject.charaSNow.x;
	self.mapToCoordinate.y = 240 - LSouSouObject.charaSNow.y;
	if(self.mapToCoordinate.x > 0)self.mapToCoordinate.x=0;
	if(self.mapToCoordinate.x < self.SCREEN_WIDTH - self.mapW)self.mapToCoordinate.x=self.SCREEN_WIDTH - self.mapW;
	if(self.mapToCoordinate.y > 0)self.mapToCoordinate.y=0;
	if(self.mapToCoordinate.y < self.SCREEN_HEIGHT - self.mapH)self.mapToCoordinate.y=self.SCREEN_HEIGHT - self.mapH;
	if(value){
		self.backLayer.x = self.mapToCoordinate.x;
		self.backLayer.y = self.mapToCoordinate.y;
	}
};
LSouSouSMap.prototype.onframe = function(self){
	if(self.mouseIsDown){
		self.mapMoveCheck();
	}
	self.mapMove();
};
LSouSouSMap.prototype.moveToCoordinate = function(intX,intY){
	var self = this;
	var toPoint = new LPoint(intX,intY);
	LSouSouObject.charaSNow.path = LSouSouObject.sQuery.queryPath(new LPoint(LSouSouObject.charaSNow.locationX(),LSouSouObject.charaSNow.locationY()),toPoint);
	trace("LSouSouObject.charaSNow.path="+LSouSouObject.charaSNow.path);
	if(LSouSouObject.charaSNow.path){
		self.roadList = null;
		LSouSouObject.sMap.roadLayer.graphics.clear();
		LSouSouObject.charaSNow.addEventListener(LSouSouEvent.CHARACTER_MOVE_COMPLETE,self.onMoveComplete);
	}
};
LSouSouSMap.prototype.onMoveComplete = function(){
	var self = LSouSouObject.sMap;
	LSouSouObject.charaSNow.removeEventListener(LSouSouEvent.CHARACTER_MOVE_COMPLETE,self.onMoveComplete);
	//移动结束
	if(LSouSouObject.charaSNow.belong == LSouSouObject.BELONG_SELF){
		self.showCtrlMenu();
	}else{
		//敌军AI，暂略
	}
};
LSouSouSMap.prototype.showCtrlMenu = function(){
	var self = this;
	self.menu = LSouSouSMapMenu.addSMenu(LSouSouObject.charaSNow.x,LSouSouObject.charaSNow.y,"ctrl");
	self.menuLayer.addChild(self.menu);
};
LSouSouSMap.prototype.mapMove = function(){
	var self = this;
	if(self.mapMove["left"]){
		self.mapIsMove = true;
		self.backLayer.x += self.nodeLength/4;
		self.mapToCoordinate.x = self.backLayer.x;
		if(self.backLayer.x % self.nodeLength == 0){
			self.mapMove["left"] = false;
		}
	}else if(self.mapMove["right"]){
		self.mapIsMove = true;
		self.backLayer.x -= self.nodeLength/4;
		self.mapToCoordinate.x = self.backLayer.x;
		if(self.backLayer.x % self.nodeLength == 0){
			self.mapMove["right"] = false;
		}
	}
	if(self.mapMove["up"]){
		self.mapIsMove = true;
		self.backLayer.y += self.nodeLength/4;
		self.mapToCoordinate.y = self.backLayer.y;
		if(self.backLayer.y % self.nodeLength == 0){
			self.mapMove["up"] = false;
		}
	}else if(self.mapMove["down"]){
		self.mapIsMove = true;
		self.backLayer.y -= self.nodeLength/4;
		self.mapToCoordinate.y = self.backLayer.y;
		if(self.backLayer.y % self.nodeLength == 0){
			self.mapMove["down"] = false;
		}
	}
};
LSouSouSMap.prototype.mapMoveCheck = function(){
	var self = this;
	if(mouseX < self.nodeLength && self.backLayer.x < 0 && !self.mapMove["left"]){
		self.mapMove["left"] = true;
	}
	if(mouseY < self.nodeLength && self.backLayer.y < 0 && !self.mapMove["up"]){
		self.mapMove["up"] = true;
	}
	if(mouseX > self.SCREEN_WIDTH - self.nodeLength && mouseX < self.SCREEN_WIDTH 
		&& self.backLayer.x > self.SCREEN_WIDTH - self.mapW && !self.mapMove["right"]){
		self.mapMove["right"] = true;
	}
	if(mouseY > self.SCREEN_HEIGHT - self.nodeLength && mouseY < self.SCREEN_HEIGHT 
		&& self.backLayer.y > self.SCREEN_HEIGHT - self.mapH && !self.mapMove["down"]){
		self.mapMove["down"] = true;
	}
};
LSouSouSMap.prototype.addOurCharacter = function(param){
	var self = this;
	//判断出战人员是否合法，LSouSouObject.perWarList是我军所选出战人员
	if(parseInt(param[0]) >= LSouSouObject.perWarList.length){
		LSouSouSMapScript.initialization();
		return;
	}
	var i,mbr,_characterS;
	//确定出战人员数据，LSouSouObject.memberList是加入我方的所有人员
	for(i=0;i<LSouSouObject.memberList.length;i++){
		mbr = LSouSouObject.memberList[i];
		if(mbr.getIndex() == LSouSouObject.perWarList[parseInt(param[0])])break;
	}
	//将出战人员加入到战场中的charaLayer层
	_characterS = new LSouSouCharacterS(mbr,0,parseInt(param[1]),0);
	self.charaLayer.addChild(_characterS);
	//出战人员位置确定
	_characterS.x = parseInt(param[2])*LSouSouObject.sMap.nodeLength;
	_characterS.y = parseInt(param[3])*LSouSouObject.sMap.nodeLength;
	//出战人员移动目标，人物移动是会用到
	_characterS.tagerCoordinate = new LPoint(_characterS.x,_characterS.y);
	//出战人员是否隐藏设定
	if(parseInt(param[4]) == 0)_characterS.visible = false;
	//将出战人员添加到我军人员ourlist数组
	LSouSouObject.sMap.ourlist.push(_characterS);
	LSouSouSMapScript.initialization();
};
LSouSouSMap.prototype.addEnemyCharacter = function(param){
	var self = this;
	var i,mbr,_characterS;
	//确定出战人员数据
	var memberData = LGlobal.chara["peo"+param[0]];
	mbr = new LSouSouMember(memberData);
	//将出战人员加入到战场中的charaLayer层
	_characterS = new LSouSouCharacterS(mbr,1,parseInt(param[2]),parseInt(param[6]));
	self.charaLayer.addChild(_characterS);
	//出战人员位置确定
	_characterS.x = parseInt(param[3])*LSouSouObject.sMap.nodeLength;
	_characterS.y = parseInt(param[4])*LSouSouObject.sMap.nodeLength;
	//出战人员移动目标，人物移动是会用到
	_characterS.tagerCoordinate = new LPoint(_characterS.x,_characterS.y);
	//出战人员是否隐藏设定
	if(parseInt(param[5]) == 0)_characterS.visible = false;
	//将出战人员添加到敌军人员enemylist数组
	LSouSouObject.sMap.enemylist.push(_characterS);
	LSouSouSMapScript.initialization();
};
LSouSouSMap.prototype.addFriendCharacter = function(param){
	var self = this;
	var i,mbr,_characterS;
	//确定出战人员数据
	var memberData = LGlobal.chara["peo"+param[0]];
	mbr = new LSouSouMember(memberData);
	//将出战人员加入到战场中的charaLayer层
	_characterS = new LSouSouCharacterS(mbr,-1,parseInt(param[2]),parseInt(param[6]));
	self.charaLayer.addChild(_characterS);
	//出战人员位置确定
	_characterS.x = parseInt(param[3])*LSouSouObject.sMap.nodeLength;
	_characterS.y = parseInt(param[4])*LSouSouObject.sMap.nodeLength;
	//出战人员移动目标，人物移动是会用到
	_characterS.tagerCoordinate = new LPoint(_characterS.x,_characterS.y);
	//出战人员是否隐藏设定
	if(parseInt(param[5]) == 0)_characterS.visible = false;
	//将出战人员添加到友军人员friendlist数组
	LSouSouObject.sMap.friendlist.push(_characterS);
	LSouSouSMapScript.initialization();
};
/**
* 读取地图
* param [地图名]
**/
LSouSouSMap.prototype.addMap = function(param){
	var self = this;
	var smapName = "images/smap/" + param;
	//显示读取进度
	self._loadBar = new LoadingSample3();
	self.addChild(self._loadBar);
	//开始读取战场地图文件
	var urlloader = new LURLLoader();
	urlloader.parent = self;
	urlloader.addEventListener(LEvent.COMPLETE,self.loadMapFileOver);
	urlloader.load(smapName+(LGlobal.traceDebug?("?"+(new Date()).getTime()):""),"text");
};
LSouSouSMap.prototype.loadMapFileOver = function(event){
	var self = event.target.parent;
	//保存战场地图文件内容
	self._objectData = JSON.parse(event.target.data);
	//保存地形
	self.mapData = self._objectData.data;
	//描绘进度条
	self._loadBar.setProgress(50);
	//获取战场大小
	self.mapW = self.mapData[0].length*48;
	self.mapH = self.mapData.length*48;
	
	LSouSouObject.sQuery = new LSouSouSQuery(self.mapData);
	//开始读取战场缩略图
	loader = new LLoader();
	loader.parent = self;
	loader.addEventListener(LEvent.COMPLETE,self.loadMapSmallOver);
	loader.load("images/smap/imgs/" + self._objectData["img-small"]+(LGlobal.traceDebug?("?"+(new Date()).getTime()):""),"bitmapData");
};
LSouSouSMap.prototype.loadMapSmallOver = function(event){
	var self = event.target.parent;
	//移除进度条
	self.removeChild(self._loadBar);
	var bitmapData = new LBitmapData(event.currentTarget);
	//计算缩略图和完整图的比例
	var scale = self.mapW/bitmapData.width;
	//将缩略图作为战场背景地图进行显示
	self._map = new LSouSouSMapBackground();
	self._map.setSmall(bitmapData,scale);
	self.mapLayer.addChild(self._map);

	//显示战场缩略图
	self._miniWindow = new LSouSouSMapMiniView(bitmapData);
	self.viewMapLayer.addChild(self._miniWindow);

	//开始读取战场完整图
	loader = new LLoader();
	loader.parent = self;
	loader.addEventListener(LEvent.COMPLETE,self.loadMapBigOver);
	loader.load("images/smap/imgs/" + self._objectData["img-big"]+(LGlobal.traceDebug?("?"+(new Date()).getTime()):""),"bitmapData");
};
LSouSouSMap.prototype.loadMapBigOver = function(event){
	var self = event.target.parent;
	self.removeChild(self._loadBar);
	var bitmapData = new LBitmapData(event.currentTarget);
	//战场完整图读取完成，替换战场地图
	self._map.setBig(bitmapData);
};