Ejemplo n.º 1
0
	public void ExecuteEvent(ScriptedObject thisCaller,string eventName){
		// intended to be called from animation Events, start execution at the named line, and
		// run until an action flagged sequenceEnd=true;
		
		// Look for the line. fail if not found
		int startingIndex=-1;
		for (int i=0;i<scriptLines.Length;i++){
			if (scriptLines[i].name == eventName){
				startingIndex=i;
				break;
			}
		}
		if (startingIndex <0){
			Debug.LogError("AnimationEvent using "+name+" could not find line "+eventName);
			return;
		}
		
		// caller is only used by ExecuteScript and onScriptComplete, so we might go without it...
		caller = thisCaller;
		myObject = caller.gameObject;
		args.Clear(); // do we need any args for events ?
		SetArgs (startingArgs);
		
		currentLine = startingIndex;
		nextLineLabel = "";
		isRunning = true;
		readyState = readiness.executing;
		myOI = caller.GetComponent<ObjectInteraction>();

		if (debug) Debug.Log ("Script "+name+" execution started");
	
		if (scriptLines[currentLine] != null)
			scriptLines[currentLine].ForceExecute(this);
		else
			OnScriptComplete("");
	}
Ejemplo n.º 2
0
	public void Execute(ScriptedObject thisCaller,string argString="", GameObject obj=null){
		caller = thisCaller;

		foreach (ObjectInteraction actor in actorObjects){
			actor.reservedForScript = null; // incase anyone got reserved who doesn't get picked by the dispatcher
		}
		
		// here, we must find a character for each role, assign and reserve them
		Dispatcher.GetInstance().FillRoles(this); // bail if fail
		
		if (obj == null) myObject = caller.gameObject; // the scripted object by default
		else myObject = obj;
		args.Clear(); // clear the dictionary to start
		SetArgs (startingArgs);
		SetArgs(argString);
		currentLine = 0;
		nextLineLabel = "";
		isRunning = true;
		readyState = readiness.executing;
		myOI = caller.GetComponent<ObjectInteraction>();

//Debug.LogWarning(name+" reserving "+myOI.name);

		foreach (ObjectInteraction actor in actorObjects){
			actor.actingInScript = this;
			actor.reservedForScript = null;
		}
		foreach (ScriptedAction sa in scriptLines)
			sa.hasExecuted = false; // really just for debug use, would break 'executeOnlyOnce'
		
		// if there's an interaction set specified, send it to the interaction manager.
		if (interactionSet != null && interactionSet.Name != null && interactionSet.Name != "")
			InteractionMgr.GetInstance().CurrentSet = interactionSet;
		
		if (debug) Debug.Log ("Script "+name+" execution started");
		
		// we're going to have to handle multiple current lines for roles 
		
		if (scriptLines[currentLine] != null)
			scriptLines[currentLine].Execute(this);
		else
			OnScriptComplete("");
	}