

function RunAction(character){
	this.name = "run";
	this.character = character;
	this.animation = character.animations["run"];
	this.relations = new Array();
}

RunAction.prototype.update = function(time){
	this.animation.addTime(time);
	for(var i = 0; i < this.relations.length; i++){
		var rel = this.relations[i];
		var res = rel.condition();
		if(res){
			return rel.targetAction;
		}
	}
	
	this.character.speed.x = this.character.dirx * this.character.runSpeed;
	
	if(this.character.isKeyDown(cmd_up)){
		this.character.speed.z = Math.max((this.character.speed.z -this.character.runSpeed) / 2, -this.character.runSpeed / 2);
	}else if(this.character.isKeyDown(cmd_down)){
		this.character.speed.z = Math.min((this.character.speed.z + this.character.runSpeed) / 2, this.character.runSpeed / 2);
	}else{
		this.character.speed.z  = 0;
	}
	
	this.character.move(this.character.speed.mulScalar(time));
	
	return this;
}

RunAction.prototype.setTime = function(time){
	this.age = time;
	this.animation.setTime(time);
}

