⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agent.js

📁 shooting flash game with script
💻 JS
字号:
/*  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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -