package extend.pk.player.state;

import com.game.ActionEvent;
import com.game.Global;
import com.game.player.state.PlayerWaitState;
import com.game.state.StateBase;
import extend.pk.EXPlayer;



public class EXPlayerPiaoNiaoTipState  extends StateBase<EXPlayer>{
	
	@Override
	public void enter(EXPlayer owner) {

		owner.startActionTimer();
	}
	
	/**
	 * 重连
	 * @param owner
	 */
	@Override
	public void reload(EXPlayer owner) {
		owner.startActionTimer();
	}
	
	
	@Override
	public void exit(EXPlayer owner) {
		owner.stopActionTimer();
	}
	
	private void _action(EXPlayer owner,int id,int gid) {

		
		owner.stateMachine.changeState(Global.getState(PlayerWaitState.class));
		owner.getRoom().piaoCount --;

	}
	
	@Override
	public void execute(EXPlayer owner, String cmd, int gid, Object param) {
		super.execute(owner, cmd, gid, param);
		if(cmd.equals(ActionEvent.EVENT_TIMER_AUTO) || cmd.equals(ActionEvent.EVENT_ENTRUST)) {
			_action(owner,0,gid);
		}
		else if(cmd.equals(ActionEvent.EVENT_OFFLINE)) {
			owner.startActionTimer();
		}
	}
}
