public void Activate() { FlagManager fm = GameObject.Find("#Player").GetComponent <FlagManager>(); if (fm == null) { Debug.LogError("Couldn't find a FlagManager component and/or #Player gameobject."); return; } if (set) { fm.SetValue(flag, val); } else { fm.IncrementValue(flag, val); } }
//Call a function if we've got one. private void InvokeActions(Line line) { //Flag actions if (!string.IsNullOrEmpty(line.flagActionName) && !string.IsNullOrEmpty(line.flagActionParam)) { //If the effect starts with + or - we use IncrementValue, otherwise SetValue. if (line.flagActionParam.StartsWith("+")) { flagManager.IncrementValue(line.flagActionName, int.Parse(line.flagActionParam.TrimStart('+'))); } else if (line.flagActionParam.StartsWith("-")) { flagManager.IncrementValue(line.flagActionName, -int.Parse(line.flagActionParam.TrimStart('-'))); } else { flagManager.SetValue(line.flagActionName, int.Parse(line.flagActionParam)); } } //Function calls if (!string.IsNullOrEmpty(line.action)) { if (activeCharacter == null) { Debug.LogWarning("Tried to use a Line action (" + line.action + ") but the dialogue has no active character"); } else { switch (line.actionType) { case "system.string": activeCharacter.gameObject.BroadcastMessage(line.action, line.actionParamString, SendMessageOptions.DontRequireReceiver); break; case "system.int32": activeCharacter.gameObject.BroadcastMessage(line.action, line.actionParamInt, SendMessageOptions.DontRequireReceiver); break; case "system.single": activeCharacter.gameObject.BroadcastMessage(line.action, line.actionParamFloat, SendMessageOptions.DontRequireReceiver); break; case "unityengine.vector3": activeCharacter.gameObject.BroadcastMessage(line.action, line.actionParamVector3, SendMessageOptions.DontRequireReceiver); break; default: activeCharacter.gameObject.BroadcastMessage(line.action, line.actionParam, SendMessageOptions.DontRequireReceiver); break; } } } //UI Effect //Stop and rewind any ongoing animations. if (animation.clip != null) { animation.Rewind(); //If the AnimationClip has WrapMode Once it will not be reset by calling this. //Force it to start playing, if you want to rewind even such animations. //Could be useful not to, though, to apply "permanent" effects. // if(!animation.isPlaying) // animation.Play(); animation.Sample(); animation.Stop(); } //We got a new animation? Play it! if (line.uiAnimation != null) { animation.clip = line.uiAnimation; animation.Play(AnimationPlayMode.Queue); } /* * if(!string.IsNullOrEmpty(line.uiActionName)) * { * switch(line.uiActionType) * { * case "system.string": * effectsGO.SendMessage(line.uiActionName, line.uiActionParamString); * break; * case "system.int32": * effectsGO.SendMessage(line.uiActionName, line.uiActionParamInt); * break; * case "system.single": * effectsGO.SendMessage(line.uiActionName, line.uiActionParamFloat); * break; * case "unityengine.vector3": * effectsGO.SendMessage(line.uiActionName, line.uiActionParamVector3); * break; * default: * effectsGO.SendMessage(line.uiActionName, line.uiActionParam); * break; * } * } */ }