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; } }
public void Awake() { Path = GetComponent<iTweenPath>(); _fsm = Camera.main.GetComponent<PlayMakerFSM>(); _main = GameObject.Find("Main").GetComponent<Main>(); _grids = GameObject.Find("Grids").GetComponent<GridManager>(); }
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; }
void Start() { FSM = GetComponent<PlayMakerFSM>(); if( FSM ) FSMAgent.RegisterFSM( FSM ); }
void DoSetFsmFloatAdd() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) return; if (go != goLastFrame) { goLastFrame = go; // only get the fsm component if go has changed fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); } if (fsm == null) return; FsmFloat fsmFloat = fsm.FsmVariables.GetFsmFloat(variableName.Value); if (fsmFloat == null) return; if (!perSecond) fsmFloat.Value += add.Value; else fsmFloat.Value += add.Value * Time.deltaTime; }
void DoFsmStateTest() { var go = gameObject.Value; if (go == null) return; if (go != previousGo) { fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); previousGo = go; } if (fsm == null) { return; } var isState = false; if (fsm.ActiveStateName == stateName.Value) { Fsm.Event(trueEvent); isState = true; } else { Fsm.Event(falseEvent); } storeResult.Value = isState; }
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); } }
// 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); }
void DoSetFsmGameObject() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } if (go != goLastFrame) { goLastFrame = go; // only get the fsm component if go has changed fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); } if (fsm == null) { return; } var fsmGameObject = fsm.FsmVariables.GetFsmGameObject(variableName.Value); if (fsmGameObject != null) { fsmGameObject.Value = setValue == null ? null : setValue.Value; } }
public void Initialize() { if (!Application.isPlaying) { return; } if (_initialized) { return; } //Debug.Log("Initializing "+target); _initialized = true; if (target == ProxyFsmTarget.FsmComponent) { return; } if (gameObject!=null) { fsmComponent = PlayMakerUtils.FindFsmOnGameObject(gameObject,fsmName); } if (fsmComponent==null) { Debug.LogError("Initialized with no FsmComponent found"); } //Debug.Log("Initialized with fsmComponent<"+fsmComponent.FsmName+">"); }
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; }
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); }
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; }
void DoGetFsmVariable() { var 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 || storeValue == null) { return; } var fsmVar = fsm.FsmVariables.GetFsmTexture(variableName.Value); if (fsmVar != null) { storeValue.Value = fsmVar.Value; } }
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); }
// 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 } } }
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; }
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; } } }
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; } } }
void Awake() { instance = this; fsm = this.GetComponent<PlayMakerFSM>(); score_counter = this.GetComponent<ScoreCounter>(); previousSectionName = Music.CurrentSection.name; }
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); } }
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; }
public override void Reset() { this.sendToFsmComponent = null; this.sendToGameObject = null; this.fsmName = string.Empty; this.sendToChildren = false; this.broadcastToAll = false; }
public virtual void Awake() { fsm = GetComponent<PlayMakerFSM>(); if (screen != null) { screenAnimator = screen.GetComponent<Animator>(); } }
public override void Reset() { fsmComponent = null; gameObject = null; fsmName = ""; storeResult = null; everyFrame = false; }
// Use this for initialization void Start() { direction = GameMain.Instance.direction; attacking = false; weapon.active = false; controller = GetComponent<CharacterController>(); playerFSM = this.GetComponent<PlayMakerFSM>(); }
public override void Start() { base.Start(); unitFSM = VisObject.GetComponent<PlayMakerFSM> (); if (unitFSM == null) Debug.LogError ("Missing FSM"); }
public override void Reset() { sendToFsmComponent = null; sendToGameObject = null; fsmName = ""; sendToChildren = false; broadcastToAll = false; }
void Start() { _fsm = this.GetComponent<PlayMakerFSM>(); if (_fsm==null) { Debug.LogError("No Fsm found",this); } }
public void OnGUI_DrawNGuiEventImplementation(PlayMakerFSM fsm) { NGuiEventsToPlaymakerFsmEvents _target = (NGuiEventsToPlaymakerFsmEvents)this.target; bool _noImplementation = true; foreach (NGuiPlayMakerDelegates _value in Enum.GetValues(typeof(NGuiPlayMakerDelegates))) { string _fsmEvent = NGuiPlayMakerProxy.GetFsmEventEnumValue(_value); int _counter = _target.getUsage(_value); // if (Application.isPlaying) // { //_fsmEvent += " "+_target.getUsage(_value); // } string _feedback = "Not implemented"; Color _color = Color.white; if (_target.DoesTargetImplementsEvent(fsm,_fsmEvent)) { _noImplementation = false; _feedback = ""; _color = Color.green; }else{ if (_target.DoesTargetMissEventImplementation(fsm,_fsmEvent)) { _color = PlayMakerPhotonEditorUtility.lightOrange; _feedback = "Not used"; } } if (_counter>0) { _feedback += " "+_counter.ToString(); } GUI.color = _color; GUILayout.BeginHorizontal("","box",GUILayout.ExpandWidth(true)); GUI.color = Color.white; EditorGUILayout.LabelField(_fsmEvent,_feedback); GUILayout.EndHorizontal(); } if (_noImplementation) { EditorGUI.indentLevel = -2; EditorGUILayout.HelpBox("The Fsm Target does not implement any NGUI Events. Edit your Fsm to add Global Transitions or State Transitions from 'Custom Events/NGUI'",MessageType.Error); } }
private void Start() { if (!PlayerData.instance.infectedKnightDreamDefeated) { return; } if (!LostLord.Instance.IsInHall) { return; } Log(_changedKin); if (!_changedKin) { tk2dSpriteDefinition def = gameObject.GetComponent <tk2dSprite>().GetCurrentSpriteDef(); _oldTex = def.material.mainTexture; def.material.mainTexture = LostLord.SPRITES[0].texture; _changedKin = true; } _origFps = _origFps ?? _anim.Library.clips.Select(x => x.fps).ToArray(); PlayMakerFSM corpse = gameObject.FindGameObjectInChildren("Corpse Infected Knight Dream(Clone)").LocateMyFSM("corpse"); corpse.RemoveAction("Init", 9); corpse.RemoveAction("Init", 1); corpse.ChangeTransition("Pause", "FINISHED", "BG Open"); corpse.AddAction("Pause", corpse.GetAction <Tk2dPlayAnimation>("Blow", 9)); // Refill MP HeroController.instance.AddMPChargeSpa(999); // No stunning Destroy(_stunControl); // 🅱lood _enemyEffects.SetAttr("noBlood", true); // No balloons _balloons.ChangeTransition("Spawn Pause", "SPAWN", "Stop"); // 1500hp _hm.hp = 1500; // Disable Knockback _recoil.enabled = false; // 2x Damage on All Components foreach (DamageHero i in gameObject.GetComponentsInChildren <DamageHero>(true)) { Log(i.name); i.damageDealt *= 2; } // Speed up some attacks. foreach (KeyValuePair <string, float> i in _fpsDict) { _anim.GetClipByName(i.Key).fps = i.Value; } // Decrease idles _control.GetAction <WaitRandom>("Idle", 5).timeMax = 0.01f; _control.GetAction <WaitRandom>("Idle", 5).timeMin = 0.001f; // 2x Damage _control.GetAction <SetDamageHeroAmount>("Roar End", 3).damageDealt.Value = 2; // Increase Jump X _control.GetAction <FloatMultiply>("Aim Dstab", 3).multiplyBy = 5; _control.GetAction <FloatMultiply>("Aim Jump", 3).multiplyBy = 2.2f; // Decrease walk idles. var walk = _control.GetAction <RandomFloat>("Idle", 3); walk.min = 0.001f; walk.max = 0.01f; // Speed up _control.GetAction <Wait>("Jump", 5).time = 0.01f; _control.GetAction <Wait>("Dash Antic 2", 2).time = 0.27f; // Fall faster. _control.GetAction <SetVelocity2d>("Dstab Fall", 4).y = -200; // -130; // -90 _control.GetAction <SetVelocity2d>("Dstab Fall", 4).everyFrame = true; _control.GetAction <ActivateGameObject>("Dstab Land", 2).activate = false; _control.GetAction <ActivateGameObject>("Dstab Fall", 6).activate = false; // Combo Dash into Upslash followed by Dstab's Projectiles. _control.CopyState("Dstab Land", "Spawners"); _control.CopyState("Ohead Slashing", "Ohead Combo"); _control.CopyState("Dstab Recover", "Dstab Recover 2"); _control.ChangeTransition("Dash Recover", "FINISHED", "Ohead Combo"); _control.RemoveAnim("Dash Recover", 3); _control.RemoveAnim("Spawners", 3); _control.ChangeTransition("Ohead Combo", "FINISHED", "Spawners"); _control.ChangeTransition("Spawners", "FINISHED", "Dstab Recover 2"); _control.GetAction <Wait>("Dstab Recover 2", 0).time = 0f; List <FsmStateAction> a = _control.GetState("Dstab Fall").Actions.ToList(); a.AddRange(_control.GetState("Spawners").Actions); _control.GetState("Dstab Fall").Actions = a.ToArray(); // Spawners before Overhead Slashing. _control.CopyState("Spawners", "Spawn Ohead"); _control.ChangeTransition("Ohead Antic", "FINISHED", "Spawn Ohead"); _control.ChangeTransition("Spawn Ohead", "FINISHED", "Ohead Slashing"); _control.FsmVariables.GetFsmFloat("Evade Range").Value *= 2; // Dstab => Upslash _control.CopyState("Ohead Slashing", "Ohead Combo 2"); _control.ChangeTransition("Dstab Land", "FINISHED", "Ohead Combo 2"); _control.ChangeTransition("Ohead Combo 2", "FINISHED", "Dstab Recover"); // Aerial Dash => Dstab _control.ChangeTransition("Dash Recover", "FALL", "Dstab Antic"); // bingo bongo ur dash is now lightspeed _control.FsmVariables.GetFsmFloat("Dash Speed").Value *= 2; _control.FsmVariables.GetFsmFloat("Dash Reverse").Value *= 2; // Fixes the cheese where you can sit on the wall // right above where he can jump and then just spam ddark _control.CopyState("Jump", "Cheese Jump"); _control.GetAction <Wait>("Cheese Jump", 5).time.Value *= 5; _control.RemoveAction("Cheese Jump", 4); _control.InsertAction("Cheese Jump", new FireAtTarget { gameObject = new FsmOwnerDefault { GameObject = gameObject }, target = HeroController.instance.gameObject, speed = 100f, everyFrame = false, spread = 0f, position = new Vector3(0, 0) }, 4); foreach (string i in new[] { "Damage Response", "Attack Choice" }) { _control.InsertMethod(i, 0, StopCheese); } Log("fin."); }
}// GetFsmsWithNetworkSynchedVariables /// <summary> /// Determines whether a given fsm has network synch variables. /// </summary> /// <returns> /// <c>true</c> if this fsm features network synch variables; otherwise, <c>false</c>. /// </returns> /// <param name='fsm'> /// If set to <c>true</c> fsm. /// </param> private bool HasFsmNetworkingSynchVariables(PlayMakerFSM fsm) { foreach (FsmFloat fsmFloat in fsm.FsmVariables.FloatVariables) { if (fsmFloat.NetworkSync) { return(true); } } foreach (FsmInt fsmInt in fsm.FsmVariables.IntVariables) { if (fsmInt.NetworkSync) { return(true); } } foreach (FsmVector2 fsmVector2 in fsm.FsmVariables.Vector2Variables) { if (fsmVector2.NetworkSync) { return(true); } } foreach (FsmVector3 fsmVector3 in fsm.FsmVariables.Vector3Variables) { if (fsmVector3.NetworkSync) { return(true); } } foreach (FsmQuaternion fsmQuaternion in fsm.FsmVariables.QuaternionVariables) { if (fsmQuaternion.NetworkSync) { return(true); } } foreach (FsmColor fsmColor in fsm.FsmVariables.ColorVariables) { if (fsmColor.NetworkSync) { return(true); } } foreach (FsmBool fsmBool in fsm.FsmVariables.BoolVariables) { if (fsmBool.NetworkSync) { return(true); } } foreach (FsmString fsmString in fsm.FsmVariables.StringVariables) { if (fsmString.NetworkSync) { return(true); } } // TODO: duplicate for all Fsm variable types... yeekkk... could we not have a FsmVariableRoot extending the commong stuff or a c# trick? return(false); }// HasFsmNetworkingSynchVariables
}// ValidatePreFlightCheckOnGameObject /// <summary> /// Sanitizes the game object and check photonView observing fsm, else complain. /// If photonView there, will insert PlayMakerPhotonView inbetween. /// </summary> /// <param name='go'> /// Go. /// </param> public void SanitizeGameObject(GameObject go) { if (go == null) { return; } PhotonView[] allPhotonViews = go.GetComponentsInChildren <PhotonView>(); // now make sure all fsm with network synchronized variable have a photonView attached List <PlayMakerFSM> fsmsToObserve = GetFsmsWithNetworkSynchedVariables(go); Debug.Log("found fsm to observe : " + fsmsToObserve.Count); foreach (PlayMakerFSM fsm in fsmsToObserve) { bool ok = false; foreach (PhotonView _photonView in allPhotonViews) { foreach (Component _comp in _photonView.ObservedComponents) { if (_comp == fsm) { ok = true; break; } } } if (!ok) { Debug.LogError( string.Format( "Fsm component '{0}' on gameObject '{1}' has variable checked for network synching, but no PhotonView component is observing this fsm", fsm.name, fsm.gameObject.name) ); } } // now inject PlayMakerPhotonView where required. foreach (PhotonView _photonView in allPhotonViews) { Debug.Log(" photon view observing : " + _photonView.ObservedComponents.ToStringFull() + " " + _photonView.ViewID); Component _comp_i; for (int i = 0; i < _photonView.ObservedComponents.Count; i++) { _comp_i = _photonView.ObservedComponents[i]; if (_comp_i is PlayMakerFSM) { PlayMakerFSM fsm = (PlayMakerFSM)_comp_i; PlayMakerPhotonView synchProxy = _photonView.gameObject.AddComponent <PlayMakerPhotonView>(); Debug.Log("switching observed <" + i + ">"); synchProxy.observed = fsm; _photonView.ObservedComponents[i] = synchProxy; } i++; } Debug.Log(" photon view observing job done : " + _photonView.ObservedComponents.ToStringFull() + " " + _photonView.ViewID); } }// SanitizeGameObject
public static void AddCoroutine(this PlayMakerFSM fsm, string stateName, Func <IEnumerator> method) { fsm.InsertCoroutine(stateName, fsm.GetState(stateName).Actions.Length, method); }
void Awake() { Instance = this; FSM = GetComponent <PlayMakerFSM> (); }
public WorldDumper() { RegisterNewDumper <TextAsset>((UnityEngine.Object obj, HTMLWriter writer, WorldDumper dumper, string folder) => { TextAsset textAsset = (TextAsset)obj; writer.OneLiner("h2", $"Bytes ({textAsset.bytes.Length}):"); writer.OneLiner("b", "Bytes as string:"); writer.NewLine(); writer.OneLiner("textarea", System.Text.Encoding.UTF8.GetString(textAsset.bytes), "rows=\"20\" cols=\"100\" disabled"); writer.OneLiner("h2", $"Text ({textAsset.text.Length}):"); writer.OneLiner("textarea", textAsset.text, "rows=\"20\" cols=\"100\" disabled"); }); RegisterNewDumper <UnityEngine.Object>((UnityEngine.Object obj, HTMLWriter writer, WorldDumper dumper, string folder) => { writer.WriteValue($"THIS IS JUST UnityEngine.Object DUMP! The object type is - {obj.GetType().FullName}"); }); RegisterNewDumper <PlayMakerFSM>((UnityEngine.Object obj, HTMLWriter writer, WorldDumper dumper, string folder) => { PlayMakerFSM component = (PlayMakerFSM)obj; var fsm = component.Fsm; if (fsm == null) { writer.WriteValue("FSM IS INVALID!"); return; } // Make sure FSM is initialized. fsm.Init(component); writer.StartTag("h2"); writer.WriteValue($"Name: {fsm.Name}"); writer.EndTag(); writer.WriteValue($"<b>Active state:</b> {fsm.ActiveStateName}<br/>"); foreach (var state in fsm.States) { writer.StartTag("div", "class=\"fsm_state " + ((fsm.ActiveState == state) ? "fsm_active_state" : "") + $"\" id=\"{state.Name}\""); { writer.OneLiner("div", state.Name, "class=\"fsm_state_name\""); FsmTransition finishedTransition = null; if (state.Transitions.Length > 0) { writer.OneLiner("b", "Transitions:"); writer.StartTag("table", "class=\"transition_table\""); writer.StartTag("tr"); { writer.OneLiner("td", "Event"); writer.OneLiner("td", "State"); } writer.EndTag(); foreach (var transition in state.Transitions) { writer.StartTag("tr"); { writer.OneLiner("td", transition.EventName); writer.StartTag("td"); writer.Link($"#{transition.ToState}", transition.ToState); writer.EndTag(); } writer.EndTag(); if (transition.EventName == "FINISHED") { finishedTransition = transition; } } writer.EndTag(); } writer.StartTag("div", "class=\"state_phase\""); writer.WriteValue("START"); writer.EndTag(); writer.OneLiner("div", "", "class=\"arrow down center_arrow\""); foreach (var action in state.Actions) { if (action == null) { writer.OneLiner("div", "NULL ACTION!", "class=\"error\""); writer.OneLiner("div", "", "class=\"arrow down center_arrow\""); continue; } writer.StartTag("div", $"class=\"fsm_action\""); { writer.OneLiner("div", action.GetType().Name, $"class=\"fsm_action_name\" title=\"{action.GetType().FullName}\""); PrintObjectFields(action, writer); } writer.EndTag(); writer.OneLiner("div", "", "class=\"arrow down center_arrow\""); } writer.StartTag("div", "class=\"state_phase\""); writer.WriteValue("END"); if (finishedTransition != null) { writer.WriteValue(" - Jump to: "); writer.Link($"#{finishedTransition.ToState}", finishedTransition.ToState); } writer.EndTag(); } writer.EndTag(); } }); RegisterNewDumper <Component>((UnityEngine.Object obj, HTMLWriter writer, WorldDumper dumper, string folder) => { Component component = (Component)obj; writer.WriteValue("COMPONENT!"); }); RegisterNewDumper <GameObject>((UnityEngine.Object obj, HTMLWriter writer, WorldDumper dumper, string folder) => { GameObject go = (GameObject)obj; Component[] components = go.GetComponents <Component>(); writer.StartTag("h2"); writer.WriteValue($"Components ({components.Length}):"); writer.EndTag(); writer.StartTag("ol"); foreach (var component in components) { writer.StartTag("li"); { string componentFile = dumper.DumpObject(component, $"{folder}/{go.name}/Components", writer.FileName); writer.Link(componentFile, $"{GetComponentName(component)} - {component.GetType().Name}"); } writer.EndTag(); } writer.EndTag(); writer.StartTag("h2"); writer.WriteValue($"Children ({go.transform.childCount}):"); writer.EndTag(); writer.StartTag("ol"); for (int i = 0; i < go.transform.childCount; ++i) { GameObject childrenGo = go.transform.GetChild(i).gameObject; writer.StartTag("li"); { string childrenFile = dumper.DumpObject(childrenGo, $"{folder}/{go.name}/Children", writer.FileName); writer.Link(childrenFile, childrenGo.name); } writer.EndTag(); } writer.EndTag(); }); }
public static void RemoveTransition(this PlayMakerFSM fsm, string stateName, string transition) { FsmState t = fsm.GetState(stateName); t.Transitions = t.Transitions.Where(trans => transition != trans.ToState).ToArray(); }
public EnemyData(GameObject gameObject, PlayMakerFSM fsm) { this.gameObject = gameObject; rigidbody2D = gameObject.GetComponent <Rigidbody2D>(); this.fsm = fsm; }
public RouteSetter() { moveFsm = PlayMakerFSM.FindFsmOnGameObject(gameObject, "Move"); }
public void CR_Change_Room_temple(Scene scene) { if (scene.name != "Room_temple") { return; } Log("CR_Change_Room_temple()"); //yield return null; #region Hornet NPC FSM GameObject hornetNpcGo = scene.FindRoot("Hornet Black Egg NPC"); PlayMakerFSM hornetNpcFsm = hornetNpcGo.LocateMyFSM("Conversation Control"); FsmVariables hornetNpcFsmVar = hornetNpcFsm.FsmVariables; hornetNpcFsm.CopyState("Greet", "Give Item"); hornetNpcFsm.RemoveAction("Give Item", 0); hornetNpcFsm.GetAction <CallMethodProper>("Give Item", 0).parameters = new FsmVar[] { new FsmVar(typeof(string)) { stringValue = "CUSTOM_HORNET_PRE_FINAL_BATTLE" }, new FsmVar(typeof(string)) { stringValue = "Hornet" } }; var pdbtAction = new PlayerDataBoolTest(); pdbtAction.gameObject = hornetNpcFsm.GetAction <PlayerDataBoolTest>("Choice", 1).gameObject; pdbtAction.boolName = "SFGrenadeTestOfTeamworkHornetCompanion"; pdbtAction.isFalse = FsmEvent.GetFsmEvent("ABSENT"); hornetNpcFsm.InsertAction("Choice", pdbtAction, 1); hornetNpcFsm.AddTransition("Choice", "ABSENT", "Give Item"); #endregion #region Shiny FSM GameObject shinyParent = GameObject.Instantiate(PrefabHolder.shinyPrefab); shinyParent.name = "Necklace"; shinyParent.SetActive(false); shinyParent.transform.GetChild(0).gameObject.SetActive(true); shinyParent.transform.position = new Vector3(29.0f, 4.3f, 0.0f); hornetNpcFsm.CopyState("Box Up", "Give Item Spawn"); hornetNpcFsm.ChangeTransition("Give Item Spawn", FsmEvent.Finished.Name, "Talk Finish"); hornetNpcFsm.GetState("Give Item").Transitions.First(x => x.ToState == "Talk Finish").ToState = "Give Item Spawn"; hornetNpcFsm.RemoveAction("Give Item Spawn", 5); hornetNpcFsm.RemoveAction("Give Item Spawn", 4); hornetNpcFsm.RemoveAction("Give Item Spawn", 3); hornetNpcFsm.RemoveAction("Give Item Spawn", 2); hornetNpcFsm.RemoveAction("Give Item Spawn", 1); hornetNpcFsm.RemoveAction("Give Item Spawn", 0); var agoAction = new ActivateGameObject(); agoAction.gameObject = new FsmOwnerDefault(); agoAction.gameObject.OwnerOption = OwnerDefaultOption.SpecifyGameObject; agoAction.gameObject.GameObject = shinyParent; agoAction.activate = true; agoAction.recursive = false; agoAction.resetOnExit = false; agoAction.everyFrame = false; hornetNpcFsm.AddAction("Give Item Spawn", agoAction); hornetNpcFsm.AddAction("Give Item Spawn", new NextFrameEvent() { sendEvent = FsmEvent.Finished }); PlayMakerFSM shinyFsm = shinyParent.transform.GetChild(0).gameObject.LocateMyFSM("Shiny Control"); FsmVariables shinyFsmVars = shinyFsm.FsmVariables; shinyFsmVars.FindFsmInt("Charm ID").Value = 0; shinyFsmVars.FindFsmInt("Type").Value = 0; shinyFsmVars.FindFsmBool("Activated").Value = false; shinyFsmVars.FindFsmBool("Charm").Value = false; shinyFsmVars.FindFsmBool("Dash Cloak").Value = false; shinyFsmVars.FindFsmBool("Exit Dream").Value = false; shinyFsmVars.FindFsmBool("Fling L").Value = false; shinyFsmVars.FindFsmBool("Fling On Start").Value = true; shinyFsmVars.FindFsmBool("Journal").Value = false; shinyFsmVars.FindFsmBool("King's Brand").Value = false; shinyFsmVars.FindFsmBool("Mantis Claw").Value = false; shinyFsmVars.FindFsmBool("Pure Seed").Value = false; shinyFsmVars.FindFsmBool("Quake").Value = false; shinyFsmVars.FindFsmBool("Show Charm Tute").Value = false; shinyFsmVars.FindFsmBool("Slug Fling").Value = false; shinyFsmVars.FindFsmBool("Super Dash").Value = false; shinyFsmVars.FindFsmString("Item Name").Value = Consts.LanguageStrings.HornetInvNameKey; shinyFsmVars.FindFsmString("PD Bool Name").Value = "SFGrenadeTestOfTeamworkHornetCompanion"; IntSwitch isAction = shinyFsm.GetAction <IntSwitch>("Trinket Type", 0); var tmpCompareTo = new List <FsmInt>(isAction.compareTo); tmpCompareTo.Add(tmpCompareTo.Count + 1); isAction.compareTo = tmpCompareTo.ToArray(); shinyFsmVars.FindFsmInt("Trinket Num").Value = tmpCompareTo.Count; var tmpSendEvent = new List <FsmEvent>(isAction.sendEvent); tmpSendEvent.Add(FsmEvent.FindEvent("PURE SEED")); isAction.sendEvent = tmpSendEvent.ToArray(); shinyFsm.CopyState("Love Key", "Necklace"); shinyFsm.GetAction <SetPlayerDataBool>("Necklace", 0).boolName = "SFGrenadeTestOfTeamworkHornetCompanion"; shinyFsm.GetAction <SetSpriteRendererSprite>("Necklace", 1).sprite = TestOfTeamwork.Instance.SpriteDict.Get(TextureStrings.InvHornetKey); shinyFsm.GetAction <GetLanguageString>("Necklace", 2).convName = Consts.LanguageStrings.HornetInvNameKey; shinyFsm.AddTransition("Trinket Type", "PURE SEED", "Necklace"); #endregion Log("~CR_Change_Room_temple()"); }
private IEnumerator PlayCompleteAnimationCoroutine(PlayMakerFSM fsm, string eventName, AdventureWingProgressDisplay.OnAnimationComplete onAnimComplete, Option seenOption) { return(new < PlayCompleteAnimationCoroutine > c__Iterator10 { fsm = fsm, eventName = eventName, seenOption = seenOption, onAnimComplete = onAnimComplete, <$> fsm = fsm, <$> eventName = eventName, <$> seenOption = seenOption, <$> onAnimComplete = onAnimComplete, <> f__this = this });
public static T GetAction <T>(this PlayMakerFSM fsm, string stateName) where T : FsmStateAction { return(fsm.GetState(stateName).Actions.FirstOrDefault(x => x is T) as T); }
public static FsmStateAction GetAction(this PlayMakerFSM fsm, string stateName, int index) { return(fsm.GetState(stateName).Actions[index]); }
public static FsmState GetState(this PlayMakerFSM fsm, string stateName) { return(fsm.FsmStates.FirstOrDefault(t => t.Name == stateName)); }
public static void InsertCoroutine(this PlayMakerFSM fsm, string stateName, int index, Func <IEnumerator> coro, bool wait = true) { InsertAction(fsm, stateName, new InvokeCoroutine(coro, wait), index); }
public static void AddMethod(this PlayMakerFSM fsm, string stateName, Action method) { fsm.InsertMethod(stateName, fsm.GetState(stateName).Actions.Length, method); }
/// <summary> /// Open the Fsm Editor and select an Fsm Component /// </summary> public static void OpenWindow(PlayMakerFSM fsmComponent) { OpenWindow(); FsmEditor.SelectFsm(fsmComponent.Fsm); }
public static void SendEventToGameObject(PlayMakerFSM fromFsm, GameObject target, string fsmEvent, bool includeChildren) { SendEventToGameObject(fromFsm, target, fsmEvent, includeChildren, null); }
// Use this for initialization void Start() { mCanvas = GetComponent <Canvas>(); effectFSM = GetComponent <PlayMakerFSM>(); positioner = GetComponent <VRUIPositioner>(); }
public static void SendEventToGameObject(PlayMakerFSM fromFsm, GameObject target, string fsmEvent, FsmEventData eventData) { SendEventToGameObject(fromFsm, target, fsmEvent, false, eventData); }
private void Awake() { _activate = gameObject.LocateMyFSM("Activate Boss"); }
void Awake() { cachedFsm = GetComponent <PlayMakerFSM>(); }
public static T GetAction <T>(PlayMakerFSM fsm, string stateName, int index) where T : FsmStateAction { return(GetAction(fsm, stateName, index) as T); }
public static void InsertAction(this PlayMakerFSM fsm, string state, int ind, FsmStateAction action) { InsertAction(fsm, state, action, ind); }
/// <summary> /// Updates FSMs related to car ignition /// </summary> void UpdateInfo() { if (currentIgnitionFsm == playerCurrentVehicle.Value) { return; } currentIgnitionFsm = playerCurrentVehicle.Value; switch (playerCurrentVehicle.Value) { default: currentIgnitionFsm = ""; radioKnobFsm = null; hornObject = null; return; case "Satsuma": ignitionFsm = GameObject.Find("SATSUMA(557kg, 248)").transform.Find("Dashboard/Steering/steering_column2/Ignition").gameObject.GetComponent <PlayMakerFSM>(); Transform cd = GameObject.Find("SATSUMA(557kg, 248)").transform.Find("Dashboard/pivot_dashboard/dashboard(Clone)/" + "pivot_meters/dashboard meters(Clone)/pivot_radio/cd player(Clone)/ButtonsCD/RadioVolume"); if (cd != null) { radioKnobFsm = cd.gameObject.GetComponent <PlayMakerFSM>(); } else { Transform oldRadio = GameObject.Find("SATSUMA(557kg, 248)").transform.Find("Dashboard/pivot_dashboard/dashboard(Clone)/" + "pivot_meters/dashboard meters(Clone)/pivot_radio/radio(Clone)/ButtonsRadio/RadioVolume"); if (oldRadio != null) { radioKnobFsm = oldRadio.gameObject.GetComponent <PlayMakerFSM>(); } else { radioKnobFsm = null; } } hornObject = GameObject.Find("SATSUMA(557kg, 248)").transform.Find("CarSimulation/CarHorn").gameObject; break; case "Hayosiko": ignitionFsm = GameObject.Find("HAYOSIKO(1500kg, 250)").transform.Find("LOD/Dashboard/Knobs/Ignition").gameObject.GetComponent <PlayMakerFSM>(); radioKnobFsm = GameObject.Find("HAYOSIKO(1500kg, 250)").transform.Find("RadioPivot/Radio/ButtonsRadio/RadioVolume").gameObject.GetComponent <PlayMakerFSM>(); hornObject = GameObject.Find("HAYOSIKO(1500kg, 250)").transform.Find("LOD/Dashboard/ButtonHorn/CarHorn").gameObject; break; case "Ruscko": ignitionFsm = GameObject.Find("RCO_RUSCKO12(270)").transform.Find("LOD/Dashboard/Knobs/Ignition").gameObject.GetComponent <PlayMakerFSM>(); radioKnobFsm = null; hornObject = GameObject.Find("RCO_RUSCKO12(270)").transform.Find("LOD/Dashboard/Knobs/ButtonHorn/CarHorn").gameObject; break; case "Kekmet": ignitionFsm = GameObject.Find("KEKMET(350-400psi)").transform.Find("LOD/Dashboard/Ignition").gameObject.GetComponent <PlayMakerFSM>(); radioKnobFsm = GameObject.Find("KEKMET(350-400psi)").transform.Find("RadioPivot/Radio/ButtonsRadio/RadioVolume").gameObject.GetComponent <PlayMakerFSM>(); hornObject = null; break; case "Gifu": ignitionFsm = GameObject.Find("GIFU(750/450psi)").transform.Find("LOD/Dashboard/Ignition").gameObject.GetComponent <PlayMakerFSM>(); radioKnobFsm = GameObject.Find("GIFU(750/450psi)").transform.Find("RadioPivot/Radio/ButtonsRadio/RadioVolume").gameObject.GetComponent <PlayMakerFSM>(); hornObject = GameObject.Find("GIFU(750/450psi)").transform.Find("LOD/Dashboard/ButtonHorn/CarHorn").gameObject; break; case "Ferndale": ignitionFsm = GameObject.Find("FERNDALE(1630kg)").transform.Find("LOD/Dashboard/Knobs/Ignition").gameObject.GetComponent <PlayMakerFSM>(); radioKnobFsm = GameObject.Find("FERNDALE(1630kg)").transform.Find("RadioPivot/Radio/ButtonsRadio/RadioVolume").gameObject.GetComponent <PlayMakerFSM>(); hornObject = GameObject.Find("FERNDALE(1630kg)").transform.Find("LOD/Dashboard/Knobs/ButtonHorn/CarHorn").gameObject; break; } // Ignition ignitionSphereCollider = ignitionFsm.gameObject.GetComponent <SphereCollider>(); defaultSphereRadius = ignitionSphereCollider.radius; ignitionSphereValueToAdd = currentIgnitionFsm == "Satsuma" ? 20 : currentIgnitionFsm == "Ferndale" ? 15 : 0.5f; // Radio if (radioKnobFsm != null) { radioKnobSphereCollider = radioKnobFsm.gameObject.GetComponent <SphereCollider>(); defaultRadioSphereRadius = radioKnobSphereCollider.radius; } }
public DelayedEvent(PlayMakerFSM fsm, FsmEvent fsmEvent, float delay) : this(fsm.Fsm, fsmEvent, delay) { }
private void Awake() { fsm = GetComponent <PlayMakerFSM> (); }
private void Start() { enemyFsm = GetComponent <PlayMakerFSM>(); }
public static void InsertMethod(this PlayMakerFSM fsm, string stateName, int index, Action method) { InsertAction(fsm, stateName, new InvokeMethod(method), index); }
public DelayedEvent(PlayMakerFSM fsm, string fsmEventName, float delay) : this(fsm.Fsm, fsmEventName, delay) { }