agent.js

来自「shooting flash game with script」· JavaScript 代码 · 共 84 行

JS
84
字号
/*  agent.js

	Class Agent for microfoft agent 
	
*/


// Constructor
function Agent(username, name) {
        
	// attributes
	this.username = username;			// name of the user
	this.name = name;					// name of the agent
	this.character = null;				// microsoft agent object
	
	this.SetAgent(name);
}

// Delete the agent
Agent.prototype.Unload = function () {
		
	if (this.character != null) {
		
		this.character.Hide();
		this.character.UnLoad();
		
		delete this.character;
		this.character = null;
	}
}

// Set the microsoft agent object
Agent.prototype.SetAgent = function (name) {
	
	if (name != "") {

		if (this.character!=null)
			this.Unload();
			
    	this.character = new Character(name);
    	this.character.Load(name + ".acs");  	
 	}
}

// Speaks the specified text
Agent.prototype.Speak = function (content) {
	
	if (this.character != null) {
		
		this.character.Speak(content);
	}
}

Agent.prototype.Hide = function () {
	if (this.character !=null) {
		this.character.Hide();
	}
}

// Set to be visible
Agent.prototype.Show = function () {
	
	if (this.character != null) {
		
		this.character.Show();
	}
}

// Move to the specified location 
Agent.prototype.MoveTo = function (x, y, speed) {
	
	if (this.character != null) {
		
		this.character.MoveTo(x, y, speed);
	}
}

Agent.prototype.Play = function (action) {
	
	if (this.character != null) {
		
		this.character.Play(action);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?