本文整理汇总了C#中PlayMakerFSM类的典型用法代码示例。如果您正苦于以下问题:C# PlayMakerFSM类的具体用法?C# PlayMakerFSM怎么用?C# PlayMakerFSM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayMakerFSM类属于命名空间,在下文中一共展示了PlayMakerFSM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
instance = this;
fsm = this.GetComponent<PlayMakerFSM>();
score_counter = this.GetComponent<ScoreCounter>();
previousSectionName = Music.CurrentSection.name;
}
示例2: Start
// Use this for initialization
void Start()
{
foreach (PlayMakerFSM fsm in PlayMakerFSM.FsmList)
{
if (fsm.name == "PetRunFSM")
{
PetRunFSM = fsm;
break;
}
}
//Placeholder for getting the current pet interface
currentPet = GameObject.Find("Pet").GetComponent(typeof(IPet)) as IPet;
//Initializes the list of available pet states
if (PetRunFSM != null)
{
GameObject petStates = GameObject.Find("PetStates");
Object[] oStates = petStates.GetComponents(typeof(PetState));
foreach (object o in oStates)
{
states.Add(o as PetState);
(o as PetState).SetMyPet(currentPet); //Sets up all the states to refer to the correct IPet script
}
}
}
示例3: SendEvent
public bool SendEvent(PlayMakerFSM fromFsm,PlayMakerEventTarget eventTarget)
{
if (fromFsm==null)
{
if (FsmEventSender==null)
{
FsmEventSender = new GameObject("PlayMaker Send Event Proxy").AddComponent<PlayMakerFSM>();
FsmEventSender.FsmName = "Send Event Proxy";
FsmEventSender.FsmDescription = "This Fsm was created at runtime, because a script is willing to send a PlayMaker event but has not specified the Fsm Sender";
}
fromFsm = FsmEventSender;
}
// Debug.Log("Sending event <"+eventName+"> from fsm:"+fromFsm.FsmName+" "+eventTarget.eventTarget+" "+eventTarget.gameObject+" "+eventTarget.fsmComponent);
if (eventTarget.eventTarget == ProxyEventTarget.BroadCastAll)
{
PlayMakerFSM.BroadcastEvent(eventName);
}else if (eventTarget.eventTarget == ProxyEventTarget.Owner || eventTarget.eventTarget == ProxyEventTarget.GameObject)
{
PlayMakerUtils.SendEventToGameObject(fromFsm,eventTarget.gameObject,eventName,eventTarget.includeChildren);
}else if (eventTarget.eventTarget == ProxyEventTarget.FsmComponent)
{
eventTarget.fsmComponent.SendEvent(eventName);
}
return true;
}
示例4: DoEnableFSM
private void DoEnableFSM()
{
GameObject gameObject = (this.gameObject.OwnerOption != OwnerDefaultOption.UseOwner) ? this.gameObject.GameObject.Value : base.Owner;
if (gameObject == null)
{
return;
}
if (!string.IsNullOrEmpty(this.fsmName.Value))
{
PlayMakerFSM[] components = gameObject.GetComponents<PlayMakerFSM>();
PlayMakerFSM[] array = components;
for (int i = 0; i < array.Length; i++)
{
PlayMakerFSM playMakerFSM = array[i];
if (playMakerFSM.FsmName == this.fsmName.Value)
{
this.fsmComponent = playMakerFSM;
break;
}
}
}
else
{
this.fsmComponent = gameObject.GetComponent<PlayMakerFSM>();
}
if (this.fsmComponent == null)
{
this.LogError("Missing FsmComponent!");
return;
}
this.fsmComponent.enabled = this.enable.Value;
}
示例5: Awake
// get the Playmaker Photon proxy fsm.
void Awake()
{
Debug.Log("Player awake");
// get the photon proxy for Photon Fsm Proxy to send event.
GameObject go = GameObject.Find("PlayMaker Photon Proxy");
if (go == null )
{
Debug.LogError("Working with photon network require that you add a 'PlayMaker Photon Proxy' component to the gameObject. You can do so from the menu 'PlayMaker Photon/components/Add photon proxy to scene'");
return;
}
// get the proxy to set the debug flag.
PlayMakerPhotonProxy _proxy = go.GetComponent<PlayMakerPhotonProxy>();
if (_proxy!=null)
{
debug = _proxy.debug;
}
// get the Fsm for reference when sending events.
fsmProxy = go.GetComponent<PlayMakerFSM>();
if (fsmProxy==null)
{
return;
}
_proxy.SanitizeGameObject(this.gameObject);
}
示例6: DoesTargetImplementsEvent
public static bool DoesTargetImplementsEvent(PlayMakerFSM fsm, string fsmEvent)
{
if (fsm==null)
{
return false;
}
foreach(FsmTransition _transition in fsm.FsmGlobalTransitions)
{
if (_transition.EventName.Equals(fsmEvent))
{
return true;
}
}
foreach(FsmState _state in fsm.FsmStates)
{
foreach(FsmTransition _transition in _state.Transitions)
{
if (_transition.EventName.Equals(fsmEvent))
{
return true;
}
}
}
return false;
}
示例7: SendEventToGameObject
public static void SendEventToGameObject(PlayMakerFSM fromFsm,GameObject target,string fsmEvent,bool includeChildren,FsmEventData eventData)
{
if (eventData!=null)
{
HutongGames.PlayMaker.Fsm.EventData = eventData;
}
if (fromFsm == null)
{
return;
}
FsmEventTarget _eventTarget = new FsmEventTarget();
_eventTarget.excludeSelf = false;
FsmOwnerDefault owner = new FsmOwnerDefault();
owner.OwnerOption = OwnerDefaultOption.SpecifyGameObject;
owner.GameObject = new FsmGameObject();
owner.GameObject.Value = target;
_eventTarget.gameObject = owner;
_eventTarget.target = FsmEventTarget.EventTarget.GameObject;
_eventTarget.sendToChildren = includeChildren;
fromFsm.Fsm.Event(_eventTarget,fsmEvent);
}
示例8: DoAddToFsmInt
void DoAddToFsmInt()
{
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null) return;
// only get the fsm component if go has changed
if (go != goLastFrame)
{
goLastFrame = go;
fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
}
if (fsm == null) return;
FsmInt fsmInt = fsm.FsmVariables.GetFsmInt(variableName.Value);
if (fsmInt == null) return;
fsmInt.Value += add.Value;
if (storeResult != null){
storeResult.Value = fsmInt.Value;
}
}
示例9: DoGetFsmVector2
private void DoGetFsmVector2()
{
if (this.storeValue == null)
{
return;
}
GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
if (ownerDefaultTarget == null)
{
return;
}
if (ownerDefaultTarget != this.goLastFrame)
{
this.goLastFrame = ownerDefaultTarget;
this.fsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value);
}
if (this.fsm == null)
{
return;
}
FsmVector2 fsmVector = this.fsm.FsmVariables.GetFsmVector2(this.variableName.Value);
if (fsmVector == null)
{
return;
}
this.storeValue.Value = fsmVector.Value;
}
示例10: DoReadBool
void DoReadBool()
{
if (go == null)
return;
// only get the fsm component if go has changed
if (go != goLastFrame)
{
goLastFrame = go;
fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
}
if (fsm == null)
return;
FsmBool fsmBool = fsm.FsmVariables.GetFsmBool(variableName.Value);
if (fsmBool == null)
return;
// store in variable if defined
if(storeValue != null)
storeValue.Value = fsmBool.Value;
// send event if not null
if(IsFalse != null && fsmBool.Value == false)
Fsm.Event(IsFalse);
else if(IsTrue != null && fsmBool.Value == true)
Fsm.Event(IsTrue);
}
示例11: DoFsmStateSwitch
void DoFsmStateSwitch()
{
var go = gameObject.Value;
if (go == null)
{
return;
}
if (go != previousGo)
{
fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
previousGo = go;
}
if (fsm == null)
{
return;
}
var activeStateName = fsm.ActiveStateName;
for (var i = 0; i < compareTo.Length; i++)
{
if (activeStateName == compareTo[i].Value)
{
Fsm.Event(sendEvent[i]);
return;
}
}
}
示例12: DoGetFsmState
void DoGetFsmState()
{
if (fsm == null)
{
if (fsmComponent != null)
{
fsm = fsmComponent;
}
else
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go != null)
{
fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
}
}
if (fsm == null)
{
storeResult.Value = "";
return;
}
}
storeResult.Value = fsm.ActiveStateName;
}
示例13: DoSetFsmBool
private void DoSetFsmBool()
{
if (this.setValue == null)
{
return;
}
GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
if (ownerDefaultTarget == null)
{
return;
}
if (ownerDefaultTarget != this.goLastFrame)
{
this.goLastFrame = ownerDefaultTarget;
this.fsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value);
}
if (this.fsm == null)
{
this.LogWarning("Could not find FSM: " + this.fsmName.Value);
return;
}
FsmMaterial fsmMaterial = this.fsm.FsmVariables.GetFsmMaterial(this.variableName.Value);
if (fsmMaterial != null)
{
fsmMaterial.Value = this.setValue.Value;
}
else
{
this.LogWarning("Could not find variable: " + this.variableName.Value);
}
}
示例14: InitFsmVars
void InitFsmVars()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
if (go != cachedGO)
{
sourceVariables = new INamedVariable[getVariables.Length];
targetVariables = new NamedVariable[getVariables.Length];
for (var i = 0; i < getVariables.Length; i++)
{
var variableName = getVariables[i].variableName;
sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
sourceVariables[i] = sourceFsm.FsmVariables.GetVariable(variableName);
targetVariables[i] = Fsm.Variables.GetVariable(variableName);
getVariables[i].Type = FsmUtility.GetVariableType(targetVariables[i]);
if (!string.IsNullOrEmpty(variableName) && sourceVariables[i] == null)
{
LogWarning("Missing Variable: " + variableName);
}
cachedGO = go;
}
}
}
示例15: DoSetFsmGameObject
void DoSetFsmGameObject()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
// FIX: must check as well that the fsm name is different.
if (go != goLastFrame || fsmName.Value != fsmNameLastFrame)
{
goLastFrame = go;
fsmNameLastFrame = fsmName.Value;
// only get the fsm component if go or fsm name has changed
fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
}
if (fsm == null)
{
return;
}
var fsmGameObject = fsm.FsmVariables.FindFsmGameObject(variableName.Value);
if (fsmGameObject != null)
{
fsmGameObject.Value = setValue == null ? null : setValue.Value;
}
else
{
LogWarning("Could not find variable: " + variableName.Value);
}
}