DFdou's Blog Life is short,Be yourself.

7kankan11bookekzw免费小说网要看书网 官路风流 酒神 uawx书都阅读网 冒牌大英雄 斗罗大陆
2203/090

GAME-NamePK 鍩轰簬MD5鐨勫悕瀛桺K(涓)

涓婃帴锛氣GAME-NamePK 鍩轰簬MD5鐨勫悕瀛桺K(涓)
Source Code锛

import org.nwhy.Player;
//杩欎釜鏄疉s3CoreLib閲岀殑宸ュ叿绫
import com.adobe.utils.StringUtil;
import gs.TweenLite;

btnStart.buttonMode=true;
btnStart.addEventListener (MouseEvent.CLICK,gameStart);
//寮濮嬫父鎴
function gameStart (_evt:MouseEvent) {
	var p1Name:String=trimStr(inputP1.text);
	var p2Name:String=trimStr(inputP2.text);
	if (checkPName (p1Name) && checkPName (p2Name)) {
		txtInfoShow.text="";
		btnStart.buttonMode=false;
		btnStart.removeEventListener (MouseEvent.CLICK,gameStart);
		var p1=new Player(p1Name);
		initPlayer(p1,mcP1);
		var p2=new Player(p2Name);
		initPlayer(p2,mcP2);
		if(p1.getDex()>=p2.getDex()){
			txtInfoShow.appendText("姣斿鏁忔嵎鍊  "+p1.getName()+"  鑾峰緱浼樺厛鏀诲嚮鏉 \n");
			setTimeout(doPK,2000,p1,p2);
		}else{
			txtInfoShow.appendText("姣斿鏁忔嵎鍊  "+p2.getName()+"  鑾峰緱浼樺厛鏀诲嚮鏉 \n");
			setTimeout(doPK,2000,p2,p1);
		}
	} else {
		txtInfoShow.appendText("璇疯緭鍏ュ悕瀛楋紒\n");
	}
}
//鍒濆鍖栬鑹
function initPlayer(_player:Player,_mc:MovieClip){
	_player.setBindMC(_mc);
	setTxt(_mc.txtName,String(_player.getName()));
	setTxt(_mc.txtHp,String(_player.getHp()));
	setTxt(_mc.txtStr,String(_player.getStr()));
	setTxt(_mc.txtDex,String(_player.getDex()));
	TweenLite.to(_mc.hp,0.3,{width:_player.getHp()/5< &lt;0});
	TweenLite.to(_mc.str,0.3,{width:_player.getStr()*2});
	TweenLite.to(_mc.dex,0.3,{width:_player.getDex()*2});
}
function doPK(_p1:Player,_p2:Player){
	attack(_p1,_p2);
	if(_p2.isAlive()){
		setTimeout(doPK,1000,_p2,_p1);
	}
}
//鏀诲嚮鍑芥暟
function attack(_p1:Player,_p2:Player){
	var p1AttackValue:Array=_p1.attack();
	gameInfoShow(txtInfoShow,p1AttackValue[1],p1AttackValue[0],_p1);
	if(_p1.getRate()>_p2.getRate()){
		_p2.setHp(_p2.getHp()-p1AttackValue[0]);
  		if(_p2.isAlive()){
			setTxt(_p2.getBindMC().txtHp,String(_p2.getHp()));
			TweenLite.to(_p2.getBindMC().hp,0.3,{width:_p2.getHp()/5< &lt;0});
		}else{
			setTxt(_p2.getBindMC().txtHp,"姝讳骸");
			TweenLite.to(_p2.getBindMC().hp,0.3,{width:0});
			txtInfoShow.appendText(_p2.getName()+"  琚墎瓒翠笅  "+_p1.getName()+"  鑾峰緱鑳滃埄 \n");
			btnStart.buttonMode=true;
			btnStart.addEventListener (MouseEvent.CLICK,gameStart);
		}
	}else{
		txtInfoShow.appendText("浣嗘槸  "+_p2.getName()+"  闂紑浜 \n");
	}
}
//鏂囨湰璁剧疆
function setTxt(_txt:TextField,_str:String){
	_txt.text=_str;
}
//鏄剧ずPK瀹炲喌
function gameInfoShow(_txt:TextField,_style:String,_str:uint,_player:Player){
	_txt.appendText(_player.getName()+"  "+_style+"  浼ゅ鍊间负  "+_str+"\n");
}
//绠鍗曠殑瑙佽溅鍚嶅瓧杈撳叆
function checkPName (playerName:String):Boolean {
	if (playerName=="") {
		return false;
	} else {
		return true;
	}
}
//鍘诲乏鍙崇┖鏍煎嚱鏁
function trimStr(_str:String){
	return StringUtil.trim(_str);
}

鐩稿鏉ヨ涓昏灏辨槸鏀诲嚮鐨勯『搴忓垽鏂紝鏀诲嚮鐨勫懡涓紝杩樻湁娓告垙鏄惁缁撴潫鐨勫垽鏂
Source files here:http://dl.getdropbox.com/u/477487/flash/game/namePK.rar

2103/092

GAME-NamePK 鍩轰簬MD5鐨勫悕瀛桺K(涓)

鍏堜笂Demo锛