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

📄 scriptedentity.java

📁 一个很不错的j2me的rpg游戏的源码
💻 JAVA
字号:
package mobileRPG.client;

public class ScriptedEntity extends Entity {
	
	public Script onTime, onMapLoad, onTalk;
	
	public ScriptedEntity(int xSize, int ySize, int xPosition, int yPosition, Main main, String entFilename, MapCanvas map, String entScriptFilename) {
		super(xSize, ySize, xPosition, yPosition, main, entFilename, map);
		
		loadScript(entScriptFilename);
		
	}
	
	public void loadScript(String filename) {
		ConfigFile cf = new ConfigFile(filename);
		String[] s = new String[70];
		int lineCount;
		String scriptName, line;
		Script script;
		
		while (!cf.isClosed()) {
			line = cf.readLine();
			
			if (!line.trim().equals("")) {
				scriptName = line;
				lineCount = 0;
				while (!(line = cf.readLine()).equals("")) {
					if (line.equals("end sub")) {
						break;
					}
					
					s[lineCount] = line;
					lineCount++;
					
				}
				
				script = new Script(this, lineCount);
				for (int n = 0; n < lineCount; n++) {
					script.line[n] = s[n];
				}
				
				if (scriptName.equals("sub ontime")) {
					//System.out.println("Setting onTime Script");
					onTime = script;
					//onTime.printScript();
				} else {
					//System.out.println("Missing hook for script: " + scriptName);
				}
			}
			
		}
		
		cf.close();
		
	}
	
	public void onTime() {
		// try to activate the onTime script
		if (onTime != null && !onTime.isActive()) {
			onTime.activateScript();
		}
		
		// Run through each script and do the onTime method
		if (onTime != null && onTime.isActive()) {
			onTime.onTime();
		}
		
		if (onMapLoad != null && onMapLoad.isActive()) {
			onMapLoad.onTime();
		}
		
		if (onTalk != null && onTalk.isActive()) {
			onTalk.onTime();
		}
		
	}
	
	/*
	 * Some script requirements:
	 * 
	 *		Triggers:
	 * 			OnMapLoad
	 * 			OnTalk
	 * 			OnApproach
	 * 			OnTime
	 * 			OnPush
	 * 			OnStep
	 * 
	 * 		Actions:
	 * 			Set Variable
	 * 			Give Item
	 * 			Take/Steal Item
	 * 			Say/Display message
	 * 			Open a store window
	 * 			Force another entity to take an action
	 * 			Move
	 * 			Wait
	 * 			Kick - toggles the feet
	 * 
	 * 			Check Variable - Do ElseIF situation depending on value
	 * 			Show a choice select - Do ElseIF situation depending on answer
	 * 			Accept Item (Opens inventory window - Do ElseIF situation depending on answer)
	 * 			
	 */
	
}

⌨️ 快捷键说明

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