Exemplo n.º 1
0
        public MissionScript(MissionIni ini)
        {
            this.Ini = ini;
            foreach (var s in ini.Solars)
            {
                Set(Solars, s.Nickname, s);
            }
            foreach (var s in ini.Ships)
            {
                Set(Ships, s.Nickname, s);
            }
            foreach (var n in ini.NPCs)
            {
                Set(NPCs, n.Nickname, n);
            }
            foreach (var f in ini.Formations)
            {
                Set(Formations, f.Nickname, f);
            }
            foreach (var ol in ini.ObjLists)
            {
                Set(ObjLists, ol.Nickname, new ScriptAiCommands()
                {
                    Nickname = ol.Nickname,
                    Ini      = ol
                });
            }
            foreach (var dlg in ini.Dialogs)
            {
                Set(Dialogs, dlg.Nickname, dlg);
            }
            if (ini.ShipIni != null)
            {
                foreach (var s in ini.ShipIni.ShipArches)
                {
                    NpcShips[s.Nickname] = s;
                }
            }
            foreach (var tr in ini.Triggers)
            {
                AvailableTriggers[tr.Nickname] = new ScriptedTrigger()
                {
                    Nickname   = tr.Nickname,
                    Repeatable = tr.Repeatable,
                    Conditions = tr.Conditions.ToArray(),
                    Actions    = ScriptedAction.Convert(tr.Actions).ToArray()
                };
                if (tr.InitState == TriggerInitState.ACTIVE)
                {
                    InitTriggers.Add(tr.Nickname);
                }
            }

            Console.WriteLine();
        }
Exemplo n.º 2
0
    public ScriptedAction AssessActions()
    {
        ScriptedAction validAction = null;

        foreach (ScriptedAction action in availableActions)
        {
            if (action.HasRequirements(this) && (validAction == null || validAction.cost < action.cost))
            {
                validAction = action;
            }
        }
        return(validAction);
    }
Exemplo n.º 3
0
    void RunStates()
    {
        switch (currentState)
        {
        case State.Idle:
            currentAction = AssessActions();
            if (currentAction != null)
            {
                currentState = State.PerformAction;
            }
            break;

        case State.MoveTo:
            break;

        case State.PerformAction:
            currentAction.Execute(OnActionComplete, this);
            break;
        }
    }
Exemplo n.º 4
0
    void FixedUpdate()
    {
        if (isExecuting)
        {
            if (Time.fixedTime >= nextBehaviorTime)
            {
                if (isLooping)
                {
                    currentBehaviorIndex %= script.GetScriptedActions().Count;
                }
                else
                {
                    if (currentBehaviorIndex >= script.GetScriptedActions().Count)
                    {
                        isExecuting = false;
                        character.Stop();
                        return;
                    }
                }

                currentAction    = script.GetScriptedActions()[currentBehaviorIndex++];
                nextBehaviorTime = Time.fixedTime + currentAction.duration;
            }

            switch (currentAction.action)
            {
            case ScriptedAction.MOVE:
                character.Move(currentAction.direction);
                break;

            case ScriptedAction.STOP:
                character.Stop();
                break;

            case ScriptedAction.FACE:
                character.Face(currentAction.direction);
                break;
            }
        }
    }
Exemplo n.º 5
0
	void PostSetIndent(ScriptedAction line){
		if (line.type == ScriptedAction.actionType.ifThenElse 
			|| line.block == ScriptedAction.blockType.beginElse
			|| (line.type == ScriptedAction.actionType.putMessage
				&& line.gameMsgForm != null 
				&& line.gameMsgForm.msgType == GameMsgForm.eMsgType.dialogMsg
				&& line.dialogIfThen))
			indent += "|  ";
		
	}
Exemplo n.º 6
0
	public void InsertLineAt(int index){
		// create a new child game object with a default scripted action and link it in	
		GameObject newChild = new GameObject("newScriptLine-noop");
		ScriptedAction newSA = newChild.AddComponent("ScriptedAction") as ScriptedAction;
		newSA.type = ScriptedAction.actionType.wait;
		newSA.fadeLength = 0;
		newChild.transform.parent = transform;
		ScriptedAction[] tmp = new ScriptedAction[ scriptLines.Length];
		for (int i=0; i < scriptLines.Length; i++){
			tmp[i]= scriptLines[i];
		}
		scriptLines = new ScriptedAction[tmp.Length+1];
		for (int i=0; i < index; i++){
			scriptLines[i] = tmp[i];
		}
		scriptLines[index] = newSA;
		for (int i=index+1; i < tmp.Length+1; i++){
			scriptLines[i] = tmp[i-1];
		}		
	}
Exemplo n.º 7
0
	public void DeleteLineAt(int index){
		// remove a linked script line and destroy the child game object 
		
		DestroyImmediate(scriptLines[index].gameObject);
		ScriptedAction[] tmp = new ScriptedAction[ scriptLines.Length];
		for (int i=0; i < scriptLines.Length; i++){
			tmp[i]= scriptLines[i];
		}
		scriptLines = new ScriptedAction[tmp.Length-1];
		for (int i=0; i < index; i++){
			scriptLines[i] = tmp[i];
		}
		for (int i=index+1; i < tmp.Length; i++){
			scriptLines[i-1] = tmp[i];
		}
				
	}
Exemplo n.º 8
0
	public void OnLineComplete(ScriptedAction line){
		// start the next line if there is one	
		if (debug) Debug.Log ("Script "+name+" OnLineComplete from "+line.name+" at "+Time.time+"["+currentLine+"]"+line.error);
		
		if (line.error != ""){
			if (line.error == "abort"){
				OnScriptComplete ("abort");
				return;
			}
			if (line.error == "sequenceEnd"){
				// case for animation events calling scripts.  probably some special cleanup needed here.
				//OnScriptComplete ("sequenceEnd");
				return;
			}		
			
			Debug.Log ("ERROR from script "+gameObject.name+" line "+currentLine+":"+line.error);			
		}
		
		
		if (nextLineLabel != ""){ // label "" moves you to the next line, so 'if' can use that
			if (debug) Debug.Log ("Script "+name+" branching to "+nextLineLabel);
			int next = FindNextLine(nextLineLabel,currentLine+1);
			if (next >= 0)
				currentLine = next;
			else
				currentLine++;
			nextLineLabel = "";
		}
		else
			currentLine++;
		if (scriptLines.Length > currentLine &&  scriptLines[currentLine] != null){
			if (debug) Debug.Log ("Script "+name+" running "+scriptLines[currentLine].name+" ["+currentLine+"]");
			scriptLines[currentLine].Execute(this);
		}
		else
		{
			OnScriptComplete("");
		}
		
	}
Exemplo n.º 9
0
	public GameObject FindObjectToAffect(ScriptedAction action){ // default, or we could try looking up the name again...
		GameObject objectToAffect = null;	
		string searchName = ResolveArgs(action.objectName).Replace ("\"","");
		if (action.objectName != ""){
				// see if the object name can be mapped through the Roles dictionary for this run...
				if (roleMap.ContainsKey(searchName)){
					searchName = roleMap[searchName];
				}
				objectToAffect = GameObject.Find(searchName);
				// we have a problem with two names here, one used by unity, one by the 						
				if (objectToAffect == null){
					objectToAffect = ObjectManager.GetInstance().GetGameObject(searchName);
				}
			}
			else {
				objectToAffect = myObject; // this is basically the script owner as default.
			}
		return objectToAffect;
		}
Exemplo n.º 10
0
	void OnGUI(){
		
		if (confirmChange){
			GUILayout.Label("EXIT WITHOUT SAVING CHANGES?");
			if (GUILayout.Button("YES, EXIT")){
				myScript = requestedScript;
				confirmChange = false;
				Init (myScript);
			}
			if (GUILayout.Button("NO! SAVE!")){
				myParent.SaveToXML(myParent.XMLName);
				hasChanged = false;
				myScript = requestedScript;
				confirmChange = false;
				Init (myScript);
			}
			
			return;	
		}
		
		if (Application.isPlaying) hasBeenRunning = true;
		
		if (myScript != null && hasLostScript){
			// we've gotten our instance back, reinitialize.
			if (myParent != null){
				InteractionScript reconnectInstance = null;
				reconnectInstance = EditorUtility.InstanceIDToObject(scriptInstanceID) as InteractionScript;
				if (reconnectInstance != null){
					Init (reconnectInstance);	
					hasLostScript = false;
				}
			}
			//Init (myScript); // this reconnected with a stale instance
			//hasLostScript = false;
			return;
		}
		
		if (myScript== null || myScript.scriptLines == null){
			GUILayout.Label("I lost my Script when we stopped running... what was it ?");
			hasLostScript = true;
			return;
		}
		GUI.color = Color.white;
		GUILayout.BeginHorizontal();
		string pName = "NO ScriptedObject";
		if (myParent != null){ pName = myParent.name;
			GUILayout.Label ("EDITING "+pName+"->"+myScript.name,GUILayout.ExpandWidth(false));
			if (myScript.waitingForDebugger){
				if (GUILayout.Button ("STEP",GUILayout.ExpandWidth(false))){
					myScript.singleStepping = true;
					myScript.waitingForDebugger = false;
				}
				if (GUILayout.Button ("RUN to Break",GUILayout.ExpandWidth(false))){
					myScript.singleStepping = false;
					myScript.waitingForDebugger = false;
				}
				if (Time.timeScale == 1.0){
					if (GUILayout.Button ("1/10X",GUILayout.ExpandWidth(false))){
						Time.timeScale = 0.1f;
					}
				}
				else
				{
					if (GUILayout.Button ("1X",GUILayout.ExpandWidth(false))){
						Time.timeScale = 1.0f;
					}
				}
			}
			myScript.debug = GUILayout.Toggle(myScript.debug,"dbg",GUILayout.ExpandWidth(false));
			if (AnyBreakpoints() && GUILayout.Button("-bkpts",GUILayout.ExpandWidth(false))) ClearAllBreakpoints();
			if (hasChanged && !hasBeenRunning){
				if (GUILayout.Button ("SAVE to",GUILayout.ExpandWidth(false))){
					myParent.SaveToXML(myParent.XMLName);
					hasChanged = false;
					ignoreChangeOnce = true;
				}
				myParent.XMLName = GUILayout.TextField (myParent.XMLName);
			}
			else
			{
				if (GUILayout.Button ("UNCHANGED (SAVE)",GUILayout.ExpandWidth(false))){
					myParent.SaveToXML(myParent.XMLName);
					hasChanged = false;
					ignoreChangeOnce = true;					
				}
				if (myParent != null){
					if (myParent.XMLName == null) myParent.XMLName = "";
					myParent.XMLName = GUILayout.TextField (myParent.XMLName); // keep the same number of controls ?
				}
			}
		}
		GUILayout.EndHorizontal();
		scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
		indent = ""; // prevent runaway!
		for (int i=0; i< myScript.scriptLines.Length; i++){
			if (confirmDelete == i){
				GUILayout.Label("CONFIRM you want to delete this line? Cannot UNDO (yet)!");
				if (GUILayout.Button("YES, DELETE FOREVER!")){
					myScript.DeleteLineAt(i);
					hasChanged = true;
					confirmDelete = -1;
				}
				if (GUILayout.Button("Umm, no, sorry, I didn't mean it.  Keep the line")){
					confirmDelete = -1;
					ignoreChangeOnce = true;
				}
				
			}
			bool expand = false;
			GUILayout.BeginHorizontal();
			GUI.backgroundColor = Color.grey;
			if (GUILayout.Button (new GUIContent("X",null,"delete line"),GUILayout.ExpandWidth(false))){
//				myScript.DeleteLineAt(i);
//				hasChanged = true;
				confirmDelete = i;
				ignoreChangeOnce = true;
				break; // we've affected the array, don't draw any more gui this frame.
			}
			if (GUILayout.Button (new GUIContent("+",null,"insert line before"),GUILayout.ExpandWidth(false))){
				myScript.InsertLineAt(i);
				hasChanged=true;
				break;
			}
			if (Selection.activeObject != myScript.scriptLines[i].gameObject){
				GUI.backgroundColor = Color.yellow;
				if (GUILayout.Button (new GUIContent(">",null,"EDIT line"),GUILayout.ExpandWidth(false))){
					Selection.activeGameObject = myScript.scriptLines[i].gameObject;
					// Clear keyboard focus to get around text field value retention bug in unity
					GUIUtility.keyboardControl = 0;
					ignoreChangeOnce = true;
				}
			} else {
				GUI.backgroundColor = Color.red;
				expand = true;
				if (GUILayout.Button (new GUIContent("V",null,"CLOSE line"),GUILayout.ExpandWidth(false))){					
					Selection.activeGameObject = myScript.gameObject;
					ignoreChangeOnce = true;
				}
			}
			string prefix = i<10?"  ":"";
			PreSetIndent(myScript.scriptLines[i]);
			if (myScript.scriptLines[i].hasExecuted) GUI.color = Color.yellow;
			if (myScript.readyState == InteractionScript.readiness.executing && myScript.currentLine == i) GUI.color = Color.green;
			GUILayout.Label(prefix+i+":"+indent+myScript.scriptLines[i].PrettyPrint(),GUILayout.Width(450));
			GUI.color = Color.white;
			ShowFlowIcon(myScript.scriptLines[i]);
			PostSetIndent(myScript.scriptLines[i]);
			// if it's a noop, provide a copy from drop target
			if (myScript.scriptLines[i].type == ScriptedAction.actionType.wait 
				&& myScript.scriptLines[i].fadeLength == 0 
				&& myScript.scriptLines[i].stringParam == ""
				&& myScript.scriptLines[i].block == ScriptedAction.blockType.none){
				// copy from dropped scriptedAction
				ScriptedAction droppedSA = null;
				droppedSA = (ScriptedAction)EditorGUILayout.ObjectField("CopyFrom",droppedSA,typeof(ScriptedAction),true,GUILayout.Width(200));
				if (droppedSA != null){
					ScriptedAction.ScriptedActionInfo info = droppedSA.ToInfo(droppedSA);
					myScript.scriptLines[i].InitFrom(info);
				}
			}
			if (GUILayout.Button (new GUIContent("?",null,"show help"),GUILayout.ExpandWidth(false))){
				helpTarget = myScript.scriptLines[i];
				ignoreChangeOnce = true;
			}
			GUILayout.EndHorizontal();
			if (expand){ // if this is reliable, we may not need the change the current selection
				myScript.scriptLines[i].name = EditorGUILayout.TextField("name:",myScript.scriptLines[i].name);
				myScript.scriptLines[i].ShowInspectorGUI("");
			}
		}
		if (indent != ""){
			GUI.color = Color.red;
			GUILayout.Label ("WARNING: Unbalanced {} - Missing END }");
			GUI.color = Color.white;
		}
		GUI.backgroundColor = Color.grey;
		if (GUILayout.Button ("+",GUILayout.ExpandWidth(false))){
			myScript.InsertLineAt(myScript.scriptLines.Length);
		}
		EditorGUILayout.EndScrollView();
		if (ignoreChangeOnce)
		{
			hasChanged = false;
			ignoreChangeOnce = false;
		}
		else
		{
			hasChanged |= GUI.changed;
			if (GUI.changed) EditorUtility.SetDirty(myScript); // see if this helps keep changes
		}
		
		ShowHelp();
	}
	virtual public void OnSelected() // look at a particular instance object
		
	{
		myObject = target as ScriptedAction;
		//base.OnSelected();
	}
Exemplo n.º 12
0
	void ShowFlowIcon(ScriptedAction sa){
		if (sa.preAttributes!="" ){
			GUI.color = Color.yellow;
			GUILayout.Label (new GUIContent("~[",null,sa.preAttributes),GUILayout.ExpandWidth(false));
			GUI.color = Color.white;
		}
		if (sa.postAttributes!="" ){
			GUI.color = Color.yellow;
			GUILayout.Label (new GUIContent("]~",null,sa.postAttributes),GUILayout.ExpandWidth(false));
			GUI.color = Color.white;
		}
		if (sa.attachmentOverride!="" ){
			GUI.color = Color.cyan;
			GUILayout.Label (new GUIContent("@",null,sa.attachmentOverride),GUILayout.ExpandWidth(false));
			GUI.color = Color.white;
		}
		
		if (sa.breakpoint ){
			GUI.color = Color.red;
			GUILayout.Label (new GUIContent("*",null,"breakpoint set"),GUILayout.ExpandWidth(false));
			GUI.color = Color.white;
		}
		if (sa.type == ScriptedAction.actionType.wait && sa.stringParam != ""){
			GUI.color = Color.red;
			GUILayout.Label (new GUIContent("X",null,"waits for condition"),GUILayout.ExpandWidth(false));
			GUI.color = Color.white;
		}
		if (sa.sequenceEnd){
			GUI.color = Color.red;
			GUILayout.Label (new GUIContent("!",null,"animation event ends"),GUILayout.ExpandWidth(false));
			GUI.color = Color.white;
		}
		if (sa.waitForCompletion == false){
			GUI.color = Color.green;
			GUILayout.Label (new GUIContent("O",null,"no wait for completion"),GUILayout.ExpandWidth(false));
			GUI.color = Color.white;
		}
	}
Exemplo n.º 13
0
    // The window function. This works just like ingame GUI.Window
    void DoHelpWindow (int id) {
        if (GUILayout.Button ("Close")){ helpTarget = null; return;}
        helpScrollPos = GUI.BeginScrollView (
            new Rect (0, 40, helpWindowRect.width, helpWindowRect.height), 
            helpScrollPos, 
            new Rect (0, 0, helpWindowRect.width, 2000)
        );
		helpTarget.ShowHelp();        
		GUI.EndScrollView();
		GUI.DragWindow(); 
    }
Exemplo n.º 14
0
	void PreSetIndent(ScriptedAction line){
		if (line.block == ScriptedAction.blockType.endIfThenElse 
			|| line.block == ScriptedAction.blockType.beginElse){
			if (indent == ""){
				GUI.color = Color.red;
				GUILayout.Label ("WARNING: Unbalanced {} - Extra END }");
				GUI.color = Color.white;
			}
			if (indent.Length > 3)
				indent = indent.Substring(3);
			else {
				indent = "";
			}
		}
	}
Exemplo n.º 15
0
 public void OnActionComplete()
 {
     currentState  = State.Idle;
     currentAction = null;
 }
Exemplo n.º 16
0
	public GameMsg ToGameMsg( ScriptedAction scriptedAction ){
		// create a message of the appropriate type, and send it to the singleton, or	
		if (msgType == eMsgType.interactMsg){
			GameObject target = GameObject.Find (gameObjectName); // cant use ObjectManager from the editor
			if (target != null){
				InteractMsg newMsg = new InteractMsg(target,map.GetMap());
				//	newMsg.map.task = map.task; // Task master faults if this is null

				for(int i=0;i<newMsg.map.param.Count;i++)
				{
					if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
						newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
				}
				// this is problematic, because BaseObject.PutMessage does NOTHING! TODO
				//target.GetComponent<BaseObject>().PutMessage(newMsg);
				return newMsg as GameMsg;
			}
		}
		if (msgType == eMsgType.interactStatusMsg){
			GameObject target = GameObject.Find (gameObjectName);
			if (target != null){
				InteractMsg newMsg;
				if (sendMap)
					newMsg = new InteractMsg(target,map.GetMap());
				else
					newMsg = new InteractMsg(target,interactName,log);
				//newMsg.map.task = map.task; // Task master faults if this is null
				if (sendMap)
					for(int i=0;i<newMsg.map.param.Count;i++)
					{
						if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
							newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
					}
				InteractStatusMsg newisMsg = new InteractStatusMsg(newMsg);
				if (Params.Length > 0){
					newisMsg.Params=new List<string>();
					for(int i=0;i<Params.Length;i++)
					{
						if ( Params[i] != null && Params[i] != "" )
							newisMsg.Params.Add (scriptedAction.executedBy.ResolveArgs(Params[i])); // substitute any #values
					}
				}
				return newisMsg as GameMsg;
			}
		}
		if (msgType == eMsgType.quickInfoDialogMsg){
			DialogMsg newMsg = new QuickInfoMsg();
		
			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			newMsg.modal = modal;
			newMsg.command = command;
			
			return newMsg as GameMsg;
		}
		if (msgType == eMsgType.dialogMsg){
			
			DialogMsg newMsg = new DialogMsg();
		
			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			newMsg.modal = modal;
			newMsg.command = command;
			newMsg.className = className;
			newMsg.xmlName = xmlName;
			newMsg.arguments = new List<string>();
			newMsg.callback += scriptedAction.DialogCallback;
			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (scriptedAction.executedBy.ResolveArgs(arg)); // substitute any #values
			}
			// fire off the dialog
			return newMsg as GameMsg;
		}	
		if (msgType == eMsgType.guiScreenMsg){
			
			GUIScreenMsg newMsg = new GUIScreenMsg();
		
			newMsg.ScreenName = ScreenName;

			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (scriptedAction.executedBy.ResolveArgs(arg)); // substitute any #values
			}
			// fire off the dialog
			return newMsg as GameMsg;
		}
		return null;
	}	
Exemplo n.º 17
0
	/* ----------------------------  SERIALIZATION ----------------------------------------- */	
	
	
	
	public void PutMessage( ScriptedAction scriptedAction ){
		// create a message of the appropriate type, and send it to the singleton, or	
		if (msgType == eMsgType.interactMsg){
			BaseObject bo = ObjectManager.GetInstance().GetBaseObject(gameObjectName);
			if (bo == null){
				Debug.LogWarning("GameMsgForm "+name+" could not send message to '"+gameObjectName+"', not known to ObjectManager.");
				return;
			}
			GameObject target = bo.gameObject;
			if (target != null){
				InteractMsg newMsg = new InteractMsg(target,map.GetMap());
				// add flag to let everyone know that this command as generated internally
				newMsg.scripted = true;
				//	newMsg.map.task = map.task; // Task master faults if this is null

				for(int i=0;i<newMsg.map.param.Count;i++)
				{
					if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
						newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
				}
				// this is problematic, because BaseObject.PutMessage does NOTHING! TODO
				//target.GetComponent<BaseObject>().PutMessage(newMsg);
				ObjectManager.GetInstance ().GetBaseObject(gameObjectName).PutMessage(newMsg);
			}
		}
		if (msgType == eMsgType.interactStatusMsg){
			GameObject target = GameObject.Find (gameObjectName);
			if (target != null){
				InteractMsg newMsg;
				if (sendMap)
					newMsg = new InteractMsg(target,map.GetMap());
				else
					newMsg = new InteractMsg(target,interactName,log);
				// add flag to let everyone know that this command as generated internally
				newMsg.scripted = true;
				//newMsg.map.task = map.task; // Task master faults if this is null
				if (sendMap)
					for(int i=0;i<newMsg.map.param.Count;i++)
					{
						if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
							newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
					}
				InteractStatusMsg newisMsg = new InteractStatusMsg(newMsg);
				if (Params != null && Params.Length > 0){
					newisMsg.Params=new List<string>();
					for(int i=0;i<Params.Length;i++)
					{
						if ( Params[i] != null && Params[i] != "" )
							newisMsg.Params.Add (scriptedAction.executedBy.ResolveArgs(Params[i])); // substitute any #values
					}
				}
				// send to all objects
			//	ObjectManager.GetInstance().PutMessage(newisMsg);  // the brain sends to the object manager
				// send to the brain
				Brain.GetInstance().PutMessage(newisMsg);
			}
		}
		if (msgType == eMsgType.animateMsg){
			
		}
		if (msgType == eMsgType.taskMsg){
			
		}
		if (msgType == eMsgType.errorDialogMsg){
			
		}
		if (msgType == eMsgType.interactDialogMsg){
			
		}
		if (msgType == eMsgType.quickInfoDialogMsg){
			QuickInfoMsg newMsg = new QuickInfoMsg();
		
			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			// all the QuickInfo's had a timeout of 0 which was not getting passed, so if you see that, leave it alone
			// treat -1 as the value to leave the dialog up.
			if (timeout == 0) timeout = 2;
			if (timeout == -1) timeout = 0;
			newMsg.timeout = timeout;
			newMsg.modal = modal;
			newMsg.command = command;
			
			QuickInfoDialog.GetInstance().PutMessage( newMsg );
		}
		if (msgType == eMsgType.popupMsg){
			
		}
		if (msgType == eMsgType.dialogMsg){
			
			DialogMsg newMsg = new DialogMsg();

			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			newMsg.modal = modal;
			newMsg.command = command;
			newMsg.className = className;
			newMsg.name = dialogName;
			newMsg.anchor = anchor;
			newMsg.xmlName = xmlName;
			newMsg.arguments = new List<string>();
			newMsg.callback += scriptedAction.DialogCallback;
			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (StringLookup(scriptedAction.executedBy.ResolveArgs(arg))); // substitute any #values
			}
			// fire off the dialog
			GUIManager.GetInstance().PutMessage( newMsg );
		}	
		if (msgType == eMsgType.guiScreenMsg){
			
			GUIScreenMsg newMsg = new GUIScreenMsg();
		
			newMsg.ScreenName = ScreenName;

			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (StringLookup(scriptedAction.executedBy.ResolveArgs(arg))); // substitute any #values
			}
			// fire off the dialog
			GUIManager.GetInstance().PutMessage( newMsg );
		}		
	}
	void DeleteScriptLine(InteractionScript script, int index){
		
		ScriptedAction lineToDelete = script.scriptLines[index];
		
		// delete from the list
		ScriptedAction[] tmp = new ScriptedAction[script.scriptLines.Length];
		for (int i=0; i < script.scriptLines.Length; i++){
				tmp[i]= script.scriptLines[i];
		}
		script.scriptLines = new ScriptedAction[tmp.Length-1];
		for (int i=0; i < index; i++){
			script.scriptLines[i] = tmp[i];
		}
		for (int i=index+1; i < tmp.Length; i++){
			script.scriptLines[i-1] = tmp[i];
		}
		// clean up the game object.
		DestroyImmediate(lineToDelete.gameObject);  // that should get rid of all the components, too?
	}
Exemplo n.º 19
0
	public ScriptedActionInfo ToInfo(ScriptedAction sa){ // saves values to an info for serialization (to XML)
		ScriptedActionInfo info = new ScriptedActionInfo();
		
		info.unityObjectName = sa.name;
		
		info.comment = sa.comment;
		info.objectName = sa.objectName;
		info.type = sa.type;
		info.role = sa.role; // in a multi-role script, which role performs this action
		info.stringParam = sa.stringParam;  // used for a lot of different things
//info.audioClipName = sa.audioClipName;
		info.fadeLength = sa.fadeLength; // also used for wait, move
		info.desiredAlpha = sa.desiredAlpha;
		info.desiredColor = sa.desiredColor;
//	public Texture2Dname texture2D = null; // used for enableInteraction;
//	public Transform moveTo;
		info.moveToName = sa.moveToName;
		info.offset = sa.offset; // offset from transform for move, in transform's reference frame
		info.orientation = sa.orientation;
		if (scriptToExecute != null)
			info.stringParam2 = scriptToExecute.name; //name is in
		info.ease = sa.ease;
		info.negate = sa.negate; // use to turn enable to disable, stop audio, etc.
		info.loop = sa.loop;
		info.waitForCompletion = sa.waitForCompletion; // signal complete after audio, fade, etc.
		info.sequenceEnd = sa.sequenceEnd;
		info.executeOnlyOnce = sa.executeOnlyOnce;
		info.block = sa.block;
		info.dialogIfThen = sa.dialogIfThen;
		info.breakpoint = false; // always clear when saving. sa.breakpoint;
		info.preAttributes = sa.preAttributes; // processed when the line is begun
		info.postAttributes = sa.postAttributes; // processed when the line completes
		info.stringParam2 = sa.stringParam2;
		info.stringParam3 = sa.stringParam3;
		info.stringParam4 = sa.stringParam4;
		info.attachmentOverride = sa.attachmentOverride;
		info.eventScript = sa.eventScript;
		info.voiceTag = sa.voiceTag;
		info.heading = sa.heading;
		info.speed = sa.speed;
		
		if (sa.gameMsgForm != null){
			info.gameMsgFormInfo = sa.gameMsgForm.ToInfo(sa.gameMsgForm);
//			info.gameMsg = sa.gameMsgForm.ToGameMsg(this); // how to handle message subclasses ?
			if (sa.gameMsgForm.map != null){
				info.map = sa.gameMsgForm.map.GetMap(); 
			}
		}
		if (sa.type==actionType.characterTask && sa.syncToTasks != null && sa.syncToTasks.Length > 0){
			info.syncToTasksIndex = new int[sa.syncToTasks.Length];
			for (int t = 0; t<sa.syncToTasks.Length; t++){
				if (sa.syncToTasks[t]==null){
					Debug.LogError("null sync task encountered in scripted action"+name);
					info.syncToTasksIndex[t] = sa.GetLineNumber();
				}
				else
				{
					info.syncToTasksIndex[t] = sa.syncToTasks[t].GetLineNumber();
				}
			}
		}
		
//	info.gameMsg = gameMsgForm.ToMessage();
//gameMsg;
//map;
		
		return info;
	}
Exemplo n.º 20
0
	IEnumerator WaitForDialogClosed( ScriptedAction action, GameMsgForm form )
	{
		UnityEngine.Debug.LogWarning("ScriptedAction.WaitForDialogClosed() : <" + form.xmlName + "> is waiting for dialog <" + form.waitForDialogName + ">");

		// waitForDialogName is a CSV string with dialog names
		while( hasDialog(form.waitForDialogName) )
			yield return new WaitForSeconds(.1f);

		UnityEngine.Debug.LogWarning("ScriptedAction.WaitForDialogClosed() : <" + form.xmlName + "> is waiting for dialog <" + form.waitForDialogName + "> done!");

		form.PutMessage (action);
		if (waitForCompletion)
		{
//			if ( form.msgType == GameMsgForm.eMsgType.dialogMsg ) // It seems like this will always be true in this co routine ?
				waitingForDialog = true;
//			else
//				StartCoroutine(CompleteAfterDelay(form.time));
		} else
			OnComplete ();
		Cleanup ();
	}