public void SortHashTableByValues() { if (!isProxyValid()) { return; } var _val = PlayMakerUtils.GetValueFromFsmVar(this.Fsm, theValue); foreach (DictionaryEntry entry in proxy.hashTable) { if (entry.Value.Equals(_val)) { result.Value = (string)entry.Key; Fsm.Event(KeyFoundEvent); return; } } Fsm.Event(KeyNotFoundEvent); }
bool getOwnerProperties() { if (_networkView == null) { return(false); } Player _player = _networkView.Owner; if (_player == null) { return(false); } nickname.Value = _player.NickName; userID.Value = _player.UserId; actorNumber.Value = _player.ActorNumber; isLocal.Value = _player.IsLocal; isMasterClient.Value = _player.IsMasterClient; // get the custom properties int i = 0; foreach (FsmString key in customPropertyKeys) { if (_player.CustomProperties.ContainsKey(key.Value)) { PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.CustomProperties[key.Value]); } else { return(false); } i++; } return(true); }
/// <summary> /// Finds Cloud System and adds custom Multiplayer weather events. /// </summary> public void CollectGameObject(GameObject gameObject) { if (gameObject.name != "Clouds") { return; } GameObject cloudSystem = gameObject; Client.Assert(cloudSystem != null, "cloudSystem couldn't be found!"); weatherSystemFSM = Utils.GetPlaymakerScriptByName(cloudSystem, "Weather"); FsmEvent rainEvent = weatherSystemFSM.Fsm.GetEvent(RAIN_ENAME); FsmEvent thunderEvent = weatherSystemFSM.Fsm.GetEvent(THUNDER_ENAME); FsmEvent noweatherEvent = weatherSystemFSM.Fsm.GetEvent(SUNNY_ENAME); PlayMakerUtils.AddNewGlobalTransition(weatherSystemFSM, rainEvent, "Rain"); PlayMakerUtils.AddNewGlobalTransition( weatherSystemFSM, thunderEvent, "Thunder"); PlayMakerUtils.AddNewGlobalTransition( weatherSystemFSM, noweatherEvent, "No weather"); }
public void GetItemAtIndex() { if (itemName.IsNone) { return; } object element = null; currentIndex.Value = nextItemIndex; try { element = (string)gdeData[nextItemIndex]; } catch (System.Exception e) { Debug.LogError(e.Message); Fsm.Event(failureEvent); return; } PlayMakerUtils.ApplyValueToFsmVar(Fsm, itemName, element); }
void DoFindMinimumValue() { if (!isProxyValid()) { return; } VariableType _targetType = minimumValue.Type; if (!supportedTypes.Contains(minimumValue.Type)) { return; } float min = float.PositiveInfinity; int minIndex = 0; int index = 0; foreach (object _obj in proxy.arrayList) { try{ float _val = PlayMakerUtils.GetFloatFromObject(_obj, _targetType, true); if (min > _val) { min = _val; minIndex = index; } }finally{ } index++; } minimumValueIndex.Value = minIndex; PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, minimumValue, proxy.arrayList[minIndex]); }
/// <summary> /// Collect given objects. /// </summary> /// <param name="gameObject">The game object to collect.</param> public void CollectGameObject(GameObject gameObject) { if (gameObject.name == "SUN" && worldTimeFsm == null) { // Yep it's called "Color" :> worldTimeFsm = Utils.GetPlaymakerScriptByName(gameObject, "Color"); if (worldTimeFsm == null) { return; } // Register refresh world time event. if (!worldTimeFsm.Fsm.HasEvent(REFRESH_WORLD_TIME_EVENT)) { FsmEvent mpRefreshWorldTimeEvent = worldTimeFsm.Fsm.GetEvent(REFRESH_WORLD_TIME_EVENT); PlayMakerUtils.AddNewGlobalTransition(worldTimeFsm, mpRefreshWorldTimeEvent, "State 1"); } // Make sure world time is up-to-date with cache. WorldTime = worldTimeCached; } else if (Utils.IsGameObjectHierarchyMatching(gameObject, "mailbox_bottom_player/Name")) { SetupMailbox(gameObject); } else if (gameObject.name == "TRAFFIC") { new TrafficManager(gameObject); } else if (gameObject.name == "STORE") { new Shop(gameObject); } else if (gameObject.name == "BOAT") { ObjectSyncComponent osc = gameObject.transform.FindChild("GFX").FindChild("Colliders").FindChild("Collider").gameObject.AddComponent<ObjectSyncComponent>(); osc.Setup(ObjectSyncManager.ObjectTypes.Boat, ObjectSyncManager.AUTOMATIC_ID); } else if (gameObject.name == "GarageDoors") { ObjectSyncComponent oscLeft = gameObject.transform.FindChild("DoorLeft").FindChild("Coll").gameObject.AddComponent<ObjectSyncComponent>(); oscLeft.Setup(ObjectSyncManager.ObjectTypes.GarageDoor, ObjectSyncManager.AUTOMATIC_ID); ObjectSyncComponent oscRight = gameObject.transform.FindChild("DoorRight").FindChild("Coll").gameObject.AddComponent<ObjectSyncComponent>(); oscRight.Setup(ObjectSyncManager.ObjectTypes.GarageDoor, ObjectSyncManager.AUTOMATIC_ID); } }
void SelectFsmFromGameObject(GameObject go) { PlayMakerFSM[] _list = go.GetComponents <PlayMakerFSM>(); _fsmChoices = new string[_list.Length]; for (int i = 0; i < _list.Length; i++) { _fsmChoices[i] = _list[i].FsmName; } if (_fsmChoices.Length == 0) { ErrorFeedbackGui("No Fsm on target"); } else { int _choiceIndex = EditorGUILayout.Popup("Fsm", _target.fsmVariableSetup.fsmIndex, _fsmChoices); if (_choiceIndex != _target.fsmVariableSetup.fsmIndex || _target.fsmVariableSetup.fsmComponent == null) { //GUILayout.Label("finding "+go.name+"/"+_fsmList[__fsmListChoiceIndex]+":" + PlayMakerUtils.FindFsmOnGameObject(go,_fsmList[__fsmListChoiceIndex])); _target.fsmVariableSetup.fsmIndex = _choiceIndex; PlayMakerFSM _fsm = PlayMakerUtils.FindFsmOnGameObject(go, _fsmChoices[_choiceIndex]); if (_fsm == null) { Debug.LogError("Could not find fsm " + _fsmChoices[_choiceIndex] + " on go:" + go.name); _target.fsmVariableSetup.fsmComponent = null; } else { // Debug.LogError("found fsm "+_fsmList[_choiceIndex]+" on go:"+go.name+" "+_fsm.FsmName); _target.fsmVariableSetup.fsmComponent = _fsm; } } } }
void OnParticleCollision(GameObject other) { ParticleSystem particleSystem; particleSystem = other.GetComponent <ParticleSystem>(); int safeLength = particleSystem.GetSafeCollisionEventSize(); // if (collisionEvents.Length < safeLength) collisionEvents = new ParticleCollisionEvent[safeLength]; int numCollisionEvents = particleSystem.GetCollisionEvents(gameObject, collisionEvents); FsmEventData _data = new FsmEventData(); _data.GameObjectData = other; _data.IntData = numCollisionEvents; PlayMakerUtils.SendEventToGameObject(_fsm, this.gameObject, "ON PARTICLE COLLISION"); /* * * int i = 0; * while (i < numCollisionEvents) { * if (gameObject.rigidbody) { * Vector3 pos = collisionEvents[i].intersection; * Vector3 force = collisionEvents[i].velocity * 10; * gameObject.rigidbody.AddForce(force); * } * i++; * } * */ }
public void doArrayListInsert() { if (!isProxyValid()) { return; } try { var _value = PlayMakerUtils.GetValueFromFsmVar(Fsm, variable); if (variable.Type == VariableType.Int && convertIntToByte) { proxy.arrayList.Insert(index.Value, System.Convert.ToByte(_value)); } else { proxy.arrayList.Insert(index.Value, _value); } }catch (System.Exception e) { Debug.LogError(e.Message + " on " + Fsm.GameObjectName + "\nFsm: " + Fsm.Name + "\nState: " + Fsm.ActiveStateName); Fsm.Event(failureEvent); } }
public void LoadHashTable() { if (!isProxyValid()) { return; } string _tag = uniqueTag.Value; if (string.IsNullOrEmpty(_tag)) { _tag = Fsm.GameObjectName + "/" + Fsm.Name + "/hashTable/" + reference; } ES2Settings loadSettings = new ES2Settings(); if (loadFromResources.Value) { loadSettings.saveLocation = ES2Settings.SaveLocation.Resources; } Dictionary <string, string> _dict = ES2.LoadDictionary <string, string>(saveFile.Value + "?tag=" + _tag); Log("Loaded from " + saveFile.Value + "?tag=" + _tag); proxy.hashTable.Clear(); foreach (string key in _dict.Keys) { proxy.hashTable[key] = PlayMakerUtils.ParseValueFromString(_dict[key]); } Finish(); }
public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { if (debug) { Debug.Log("PlayMakerSanPlayerLobbyHook OnLobbyServerSceneLoadedForPlayer lobbyPlayer:" + lobbyPlayer + " gamePlayer:" + gamePlayer, this); } if (lobbyPlayer == null) { return; } LobbyPlayer lp = lobbyPlayer.GetComponent <LobbyPlayer>(); if (lp != null) { Debug.Log("Local Player name :" + lp.playerName + " Color:" + lp.playerColor); Fsm.EventData.StringData = lp.playerName; Fsm.EventData.ColorData = lp.playerColor; PlayMakerUtils.SendEventToGameObject(null, gamePlayer, "UNET / SAN / ON LOBBY SERVER SCENE LOADED FOR PLAYER"); } }
public GameVehicle(GameObject go) { gameObject = go; dynamics = gameObject.GetComponent <CarDynamics>(); /*PlayMakerFSM loadingFsm = Utils.GetPlaymakerScriptByName(gameObject, "LOD"); * if (loadingFsm != null) { * Component.Destroy(loadingFsm); * }*/ PlayMakerFSM[] fsms = gameObject.GetComponentsInChildren <PlayMakerFSM>(); Logger.Log("FSMS of " + gameObject.name); foreach (var fsm in fsms) { if (fsm.FsmName != "PlayerTrigger") { continue; } FsmState playerInCarState = fsm.Fsm.GetState("Player in car"); FsmState waitForPlayerState = fsm.Fsm.GetState("Wait for player"); if (waitForPlayerState != null) { PlayMakerUtils.AddNewAction(waitForPlayerState, new OnLeaveAction(this)); } if (playerInCarState != null) { PlayMakerUtils.AddNewAction(playerInCarState, new OnEnterAction(this)); } } }
bool getLastMessagePlayerProperties() { if (PlayMakerPhotonProxy.Instance == null) { Debug.LogError("PlayMakerPhotonProxy is missing in the scene"); return(false); } Player _player = PlayMakerPhotonProxy.Instance.lastMessagePhotonPlayer; if (_player == null) { return(false); } nickName.Value = _player.NickName; actorNumber.Value = _player.ActorNumber; userId.Value = _player.UserId; isLocal.Value = _player.IsLocal; isMasterClient.Value = _player.IsMasterClient; // get the custom properties int i = 0; foreach (FsmString key in customPropertyKeys) { if (!_player.CustomProperties.ContainsKey(key.Value)) { return(false); } PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.CustomProperties[key.Value]); i++; } return(true); }
public bool SendEvent(PlayMakerFSM fromFsm, PlayMakerTimelineEventTarget eventTarget, bool debug = false) { fromFsm = SanitizeFsmEventSender(fromFsm); if (debug) { 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); }
/// <summary> /// Constructor. /// </summary> /// <param name="manager">The manager that owns this door.</param> /// <param name="gameObject">Game object of the doors to represent by this /// wrapper.</param> public GameDoor(GameDoorsManager manager, GameObject gameObject) { this.manager = manager; this.gameObject = gameObject; fsm = Utils.GetPlaymakerScriptByName(gameObject, "Use"); if (fsm.Fsm.HasEvent(MP_OPEN_EVENT_NAME)) { Logger.Log("Failed to hook game door " + gameObject.name + ". It is already hooked."); return; } FsmEvent mpOpenEvent = fsm.Fsm.GetEvent(MP_OPEN_EVENT_NAME); FsmEvent mpCloseEvent = fsm.Fsm.GetEvent(MP_CLOSE_EVENT_NAME); PlayMakerUtils.AddNewGlobalTransition(fsm, mpOpenEvent, "Open door"); PlayMakerUtils.AddNewGlobalTransition(fsm, mpCloseEvent, "Close door"); PlayMakerUtils.AddNewAction( fsm.Fsm.GetState("Open door"), new OnOpenDoorsAction(this)); PlayMakerUtils.AddNewAction( fsm.Fsm.GetState("Close door"), new OnCloseDoorsAction(this)); }
public override void OnEnter() { string file = saveFile.Value + "?tag=" + prefixTag.Value; for (int i = 0; i < tags.Length; i++) { if (!tags[i].IsNone || !tags[i].Value.Equals("")) { string tag = tags[i].Value; FsmVar fsmVar = values[i]; //string _name = fsmVar.variableName; string _fullFile = file; if (!tags[i].IsNone) { _fullFile = _fullFile + tag; } switch (fsmVar.Type) { case VariableType.Int: ES2.Save(fsmVar.IsNone ? 0 : (int)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.Float: ES2.Save(fsmVar.IsNone ? 0f : (float)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.Bool: ES2.Save(fsmVar.IsNone ? false : (bool)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.Color: ES2.Save(fsmVar.IsNone ? Color.black : (Color)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.Quaternion: ES2.Save(fsmVar.IsNone ? Quaternion.identity : (Quaternion)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.Rect: ES2.Save(fsmVar.IsNone ? new Rect(0f, 0f, 0f, 0f) : (Rect)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.Vector2: ES2.Save(fsmVar.IsNone ? Vector2.zero : (Vector2)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.Vector3: ES2.Save(fsmVar.IsNone ? Vector3.zero : (Vector3)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; case VariableType.String: ES2.Save(fsmVar.IsNone ? "" : (string)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar), _fullFile); break; default: LogError("EasySave2 does not support saving " + fsmVar.Type); break; } } } Finish(); }
public override void OnEnter() { string _roomName = null; if (!string.IsNullOrEmpty(roomName.Value)) { _roomName = roomName.Value; } ExitGames.Client.Photon.Hashtable _props = new ExitGames.Client.Photon.Hashtable(); int i = 0; foreach (FsmString _prop in customPropertyKey) { _props[_prop.Value] = PlayMakerUtils.GetValueFromFsmVar(this.Fsm, customPropertyValue[i]); i++; } string[] lobbyProps = new string[lobbyCustomProperties.Length]; int j = 0; foreach (FsmString _visibleProp in lobbyCustomProperties) { lobbyProps[j] = _visibleProp.Value; j++; } RoomOptions _options = new RoomOptions(); _options.MaxPlayers = (byte)maxNumberOfPLayers.Value; _options.IsVisible = isVisible.Value; _options.IsOpen = isOpen.Value; _options.CustomRoomProperties = _props; _options.CustomRoomPropertiesForLobby = lobbyProps; if (!playerTimeToLive.IsNone) { _options.PlayerTtl = playerTimeToLive.Value; } if (!emptyRoomTimeToLive.IsNone) { _options.EmptyRoomTtl = emptyRoomTimeToLive.Value; } if (!cleanupCacheOnLeave.IsNone) { _options.CleanupCacheOnLeave = cleanupCacheOnLeave.Value; } if (!suppressRoomEvents.IsNone) { _options.SuppressRoomEvents = suppressRoomEvents.Value; } if (!deleteNullProperties.IsNone) { _options.DeleteNullProperties = deleteNullProperties.Value; } if (!BroadcastPropsChangeToAll.IsNone) { _options.BroadcastPropsChangeToAll = BroadcastPropsChangeToAll.Value; } if (!publishUserId.IsNone) { _options.PublishUserId = publishUserId.Value; } if (!expectedUsers.IsNone) { _expectedUsers = expectedUsers.stringValues; } else { _expectedUsers = null; } if (plugins.Length > 0) { string[] _plugins = new string[plugins.Length]; int k = 0; foreach (FsmString _fsmstring in plugins) { _plugins[k] = _fsmstring.Value; k++; } _options.Plugins = _plugins; } PhotonNetwork.CreateRoom(_roomName, _options, lobby.GetTypedLobby(), _expectedUsers); Finish(); }
void OnEnable() { PlayMakerUtils.CreateIfNeededGlobalEvent(PlayMakerVuforiaVirtualButtonProxy.VirtualButtonPressedPlayMakerEventName); PlayMakerUtils.CreateIfNeededGlobalEvent(PlayMakerVuforiaVirtualButtonProxy.VirtualButtonReleasedPlayMakerEventName); }
public void SendPlayMakerEvent() { PlayMakerUtils.SendEventToGameObject(this.GetComponent <PlayMakerFSM>(), this.gameObject, "ANIMATION EVENT"); }
/// <summary> /// Collect given objects. /// </summary> /// <param name="gameObject">The game object to collect.</param> public void CollectGameObject(GameObject gameObject) { if (gameObject.name == "SUN" && worldTimeFsm == null) { // Yep it's called "Color" :> worldTimeFsm = Utils.GetPlaymakerScriptByName(gameObject, "Color"); if (worldTimeFsm == null) { return; } // Register refresh world time event. if (!worldTimeFsm.Fsm.HasEvent(REFRESH_WORLD_TIME_EVENT)) { FsmEvent mpRefreshWorldTimeEvent = worldTimeFsm.Fsm.GetEvent(REFRESH_WORLD_TIME_EVENT); PlayMakerUtils.AddNewGlobalTransition(worldTimeFsm, mpRefreshWorldTimeEvent, "State 1"); } // Make sure world time is up-to-date with cache. WorldTime = worldTimeCached; } else if (Utils.IsGameObjectHierarchyMatching(gameObject, "mailbox_bottom_player/Name")) { SetupMailbox(gameObject); } else if (gameObject.name == "TRAFFIC") { trafficManager.Setup(gameObject); } else if (gameObject.name == "STORE") { shopManager.Setup(gameObject); } else if (gameObject.name == "BOAT") { ObjectSyncComponent osc = gameObject.transform.FindChild("GFX/Colliders/Collider").gameObject.AddComponent <ObjectSyncComponent>(); osc.Setup(ObjectSyncManager.ObjectTypes.Boat, ObjectSyncManager.AUTOMATIC_ID); } // Garage doors. else if (gameObject.name == "GarageDoors") { ObjectSyncComponent oscLeft = gameObject.transform.FindChild("DoorLeft/Coll").gameObject.AddComponent <ObjectSyncComponent>(); oscLeft.Setup(ObjectSyncManager.ObjectTypes.GarageDoor, ObjectSyncManager.AUTOMATIC_ID); ObjectSyncComponent oscRight = gameObject.transform.FindChild("DoorRight/Coll").gameObject.AddComponent <ObjectSyncComponent>(); oscRight.Setup(ObjectSyncManager.ObjectTypes.GarageDoor, ObjectSyncManager.AUTOMATIC_ID); } // Old car shed doors. else if (gameObject.name == "Doors" && gameObject.transform.parent.name == "Shed") { PlayMakerFSM doorLeft = gameObject.transform.FindChild("DoorLeft/Mesh").gameObject.GetComponent <PlayMakerFSM>(); EventHook.AddWithSync(doorLeft, "Open door"); EventHook.AddWithSync(doorLeft, "Close door"); PlayMakerFSM doorRight = gameObject.transform.FindChild("DoorRight/Mesh").gameObject.GetComponent <PlayMakerFSM>(); EventHook.AddWithSync(doorRight, "Open door"); EventHook.AddWithSync(doorRight, "Close door"); } // Weather system. else if (gameObject.name == "Clouds" && gameObject.transform.parent.name == "CloudSystem") { ObjectSyncComponent osc = gameObject.AddComponent <ObjectSyncComponent>(); osc.Setup(ObjectSyncManager.ObjectTypes.Weather, ObjectSyncManager.AUTOMATIC_ID); } // Sewage well jobs. else if (gameObject.name.StartsWith("HouseShit")) { ObjectSyncComponent osc = gameObject.AddComponent <ObjectSyncComponent>(); osc.Setup(ObjectSyncManager.ObjectTypes.SewageWell, ObjectSyncManager.AUTOMATIC_ID); } // Phone. else if (gameObject.name == "Ring") { phoneManager.Setup(gameObject); } // Map. else if (gameObject.name == "MAP" && gameObject.transform.FindChild("Darts")) { mapManager.Setup(gameObject); } }
public override void OnEnter() { //check if we are in a room or not //if (PhotonNetwoek.is) if (!PhotonNetwork.insideLobby) { Fsm.Event(notInLobbyEvent); Finish(); return; } if (nextRoomIndex == 0) { rooms = PhotonNetwork.GetRoomList(); } if (rooms.Length == 0) { nextRoomIndex = 0; Fsm.Event(noRoomsEvent); Fsm.Event(finishedEvent); Finish(); return; } if (nextRoomIndex >= rooms.Length) { nextRoomIndex = 0; Fsm.Event(finishedEvent); Finish(); return; } _room = rooms[nextRoomIndex]; // we get the room properties RoomName.Value = _room.Name; maxPlayers.Value = _room.MaxPlayers; open.Value = _room.IsOpen; visible.Value = _room.IsVisible; playerCount.Value = _room.PlayerCount; // get the custom properties int i = 0; foreach (FsmString key in customPropertyKeys) { if (_room.CustomProperties.ContainsKey(key.Value)) { PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _room.CustomProperties[key.Value]); } i++; } nextRoomIndex++; Fsm.Event(loopEvent); Finish(); }
public void SetItemAtIndex() { if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) { Debug.Log("ArrayListTable not found for " + PlayMakerUtils.LogFullPathToAction(this)); Fsm.Event(failureEvent); return; } ArrayListTable _at = this.cachedComponent as ArrayListTable; int index = 0; string _error = string.Empty; try{ if (UseColumnHeader) { if (_at.HeaderProxy == null) { _error = "Header Proxy not defined"; throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this)); } index = _at.HeaderProxy.arrayList.IndexOf(atColumn.Value); if (index < 0 || (index + 1) > _at.ColumnData.Length) { _error = "Header Column index out of range"; throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this)); } } else { index = atColumnIndex.Value; if (index < 0 || (index + 1) > _at.ColumnData.Length) { _error = "Column index out of range"; throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this)); } } if (atRowIndex.Value < 0 || (atRowIndex.Value + 1) > _at.ColumnData[atColumnIndex.Value].arrayList.Count) { _error = "Row index out of range"; throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this)); } PlayMakerArrayListProxy _column = _at.ColumnData[index]; if (_column == null) { _error = "Column index not found"; throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this)); } _column._arrayList[atRowIndex.Value] = PlayMakerUtils.GetValueFromFsmVar(this.Fsm, value); }catch (System.Exception e) { Debug.Log(e.Message); Fsm.EventData.StringData = _error; Fsm.Event(failureEvent); return; } }
public static string ParseFsmVarToString(Fsm fsm, FsmVar fsmVar) { if (fsmVar == null) { return(""); } object item = PlayMakerUtils.GetValueFromFsmVar(fsm, fsmVar); if (item == null) { return(""); } if (fsmVar.Type == VariableType.String) { return((string)item); } if (fsmVar.Type == VariableType.Bool) { return((bool)item?"1":"0"); } if (fsmVar.Type == VariableType.Float) { float _val = float.Parse(item.ToString()); return(_val.ToString()); } if (fsmVar.Type == VariableType.Int) { int _val = int.Parse(item.ToString()); return(_val.ToString()); } if (fsmVar.Type == VariableType.Vector2) { Vector2 _val = (Vector2)item; return(_val.x + "," + _val.y); } if (fsmVar.Type == VariableType.Vector3) { Vector3 _val = (Vector3)item; return(_val.x + "," + _val.y + "," + _val.z); } if (fsmVar.Type == VariableType.Quaternion) { Quaternion _val = (Quaternion)item; return(_val.x + "," + _val.y + "," + _val.z + "," + _val.w); } if (fsmVar.Type == VariableType.Rect) { Rect _val = (Rect)item; return(_val.x + "," + _val.y + "," + _val.width + "," + _val.height); } if (fsmVar.Type == VariableType.Color) { Color _val = (Color)item; return(_val.r + "," + _val.g + "," + _val.b + "," + _val.a); } if (fsmVar.Type == VariableType.GameObject) { GameObject _val = (GameObject)item; //Debug.Log("GameObject "+_val.GetInstanceID().ToString()); //return "gameObject("+_val.GetInstanceID().ToString()+")"; return(_val.name); } if (fsmVar.Type == VariableType.Material) { Material _val = (Material)item; //Debug.Log("GameObject "+_val.GetInstanceID().ToString()); //return "gameObject("+_val.GetInstanceID().ToString()+")"; return(_val.name); } if (fsmVar.Type == VariableType.Texture) { Texture2D _val = (Texture2D)item; //Debug.Log("GameObject "+_val.GetInstanceID().ToString()); //return "gameObject("+_val.GetInstanceID().ToString()+")"; return(_val.name); } Debug.LogWarning("ParseValueToString type not supported " + item.GetType()); return("<" + fsmVar.Type + "> not supported"); }
void DoGetSpanTimeInfo() { TimeSpan span = new TimeSpan(); if (timeSpanCreate == TimeSpanCreate.TryParse) { /*bool _success = */ TimeSpan.TryParse(timeSpan.Value, out span); } else if (timeSpanCreate == TimeSpanCreate.FromSeconds) { span = TimeSpan.FromSeconds(Convert.ToDouble(timeSpan.Value)); } int i = 0; foreach (TimeSpanProperties _prop in properties) { FsmVar _var = values[i]; switch (_prop) { case TimeSpanProperties.Milliseconds: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Milliseconds); break; case TimeSpanProperties.TotalMilliseconds: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalMilliseconds); break; case TimeSpanProperties.Seconds: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Seconds); break; case TimeSpanProperties.TotalSeconds: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalSeconds); break; case TimeSpanProperties.Hours: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Hours); break; case TimeSpanProperties.TotalHours: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalHours); break; case TimeSpanProperties.Minutes: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Minutes); break; case TimeSpanProperties.totalMinutes: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalMinutes); break; case TimeSpanProperties.Days: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Days); break; case TimeSpanProperties.TotalDays: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalDays); break; default: PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, 0); break; } i++; } }
static public bool SetParsePropertyFromFsmVar(ParseObject _object, string property, Fsm fsm, FsmVar fsmVar) { if (_object == null) { Debug.Log("Parse Object null"); return(false); } if (string.IsNullOrEmpty(property)) { Debug.Log("property null"); return(false); } if (!_object.ContainsKey(property)) { // return false; } PlayMakerUtils.RefreshValueFromFsmVar(fsm, fsmVar); if (fsmVar.Type == VariableType.Bool) { _object[property] = fsmVar.boolValue; } else if (fsmVar.Type == VariableType.Float) { _object[property] = fsmVar.floatValue; } else if (fsmVar.Type == VariableType.Int) { _object[property] = fsmVar.intValue; } else if (fsmVar.Type == VariableType.String) { _object[property] = fsmVar.stringValue; } else if (fsmVar.Type == VariableType.Color) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.colorValue); } else if (fsmVar.Type == VariableType.GameObject) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.gameObjectValue); } else if (fsmVar.Type == VariableType.Material) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.materialValue); } else if (fsmVar.Type == VariableType.Quaternion) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.quaternionValue); } else if (fsmVar.Type == VariableType.Rect) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.rectValue); } else if (fsmVar.Type == VariableType.Texture) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.textureValue); } else if (fsmVar.Type == VariableType.Vector2) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.vector2Value); } else if (fsmVar.Type == VariableType.Vector3) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.vector3Value); } return(true); }
static public bool GetParsePropertyToFsmVar(ParseObject _object, string property, Fsm fsm, FsmVar fsmVar) { if (_object == null || string.IsNullOrEmpty(property)) { return(false); } if (!_object.ContainsKey(property)) { return(false); } if (fsmVar.Type == VariableType.Bool) { PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]); } else if (fsmVar.Type == VariableType.Float) { PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]); } else if (fsmVar.Type == VariableType.Int) { PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]); } else if (fsmVar.Type == VariableType.String) { PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]); } else if (fsmVar.Type == VariableType.Color) { fsmVar.colorValue = (Color)PlayMakerUtils.ParseValueFromString((string)_object[property]); } else if (fsmVar.Type == VariableType.GameObject) { fsmVar.gameObjectValue = (GameObject)PlayMakerUtils.ParseValueFromString((string)_object[property]); } else if (fsmVar.Type == VariableType.Material) { fsmVar.materialValue = (Material)PlayMakerUtils.ParseValueFromString((string)_object[property]); } else if (fsmVar.Type == VariableType.Quaternion) { fsmVar.quaternionValue = (Quaternion)PlayMakerUtils.ParseValueFromString((string)_object[property]); } else if (fsmVar.Type == VariableType.Rect) { fsmVar.rectValue = (Rect)PlayMakerUtils.ParseValueFromString((string)_object[property]); } else if (fsmVar.Type == VariableType.Texture) { fsmVar.textureValue = (Texture2D)PlayMakerUtils.ParseValueFromString((string)_object[property]); } else if (fsmVar.Type == VariableType.Vector2) { fsmVar.vector2Value = (Vector2)PlayMakerUtils.ParseValueFromString((string)_object[property]); } else if (fsmVar.Type == VariableType.Vector3) { fsmVar.vector3Value = (Vector3)PlayMakerUtils.ParseValueFromString((string)_object[property]); } return(true); }
public void doesArrayListContains() { if (!base.isProxyValid()) { return; } bool flag = false; PlayMakerUtils.RefreshValueFromFsmVar(base.Fsm, this.variable); switch (this.variable.Type) { case VariableType.Float: flag = this.proxy.arrayList.Contains(this.variable.floatValue); break; case VariableType.Int: flag = this.proxy.arrayList.Contains(this.variable.intValue); break; case VariableType.Bool: flag = this.proxy.arrayList.Contains(this.variable.boolValue); break; case VariableType.GameObject: flag = this.proxy.arrayList.Contains(this.variable.gameObjectValue); break; case VariableType.String: flag = this.proxy.arrayList.Contains(this.variable.stringValue); break; case VariableType.Vector2: flag = this.proxy.arrayList.Contains(this.variable.vector2Value); break; case VariableType.Vector3: flag = this.proxy.arrayList.Contains(this.variable.vector3Value); break; case VariableType.Color: flag = this.proxy.arrayList.Contains(this.variable.colorValue); break; case VariableType.Rect: flag = this.proxy.arrayList.Contains(this.variable.rectValue); break; case VariableType.Material: flag = this.proxy.arrayList.Contains(this.variable.materialValue); break; case VariableType.Texture: flag = this.proxy.arrayList.Contains(this.variable.textureValue); break; case VariableType.Quaternion: flag = this.proxy.arrayList.Contains(this.variable.quaternionValue); break; case VariableType.Object: flag = this.proxy.arrayList.Contains(this.variable.objectReference); break; } this.isContained.Value = flag; if (flag) { base.Fsm.Event(this.isContainedEvent); } else { base.Fsm.Event(this.isNotContainedEvent); } }
public override void OnEnter() { for (int i = 0; i < keys.Length; i++) { if (!keys[i].IsNone || !keys[i].Value.Equals("")) { string key = keys[i].Value; FsmVar fsmVar = values[i]; switch (fsmVar.Type) { case VariableType.Int: PlayerPrefs.SetInt(key, fsmVar.IsNone ? 0 : (int)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Float: PlayerPrefs.SetFloat(key, fsmVar.IsNone ? 0f : (float)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Bool: PlayerPrefsX.SetBool(key, fsmVar.IsNone ? false : (bool)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Color: PlayerPrefsX.SetColor(key, fsmVar.IsNone ? Color.black : (Color)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Quaternion: PlayerPrefsX.SetQuaternion(key, fsmVar.IsNone ? Quaternion.identity : (Quaternion)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Rect: PlayerPrefsX.SetRect(key, fsmVar.IsNone ? new Rect(0f, 0f, 0f, 0f) : (Rect)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Vector2: PlayerPrefsX.SetVector2(key, fsmVar.IsNone ? Vector2.zero : (Vector2)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Vector3: PlayerPrefsX.SetVector3(key, fsmVar.IsNone ? Vector3.zero : (Vector3)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.String: PlayerPrefs.SetString(key, fsmVar.IsNone ? "" : (string)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; default: LogError("PlayerPrefsx does not support saving " + fsmVar.Type); break; } } } Finish(); }
public override void OnEnter() { if (string.IsNullOrEmpty(jsonString.Value)) { LogWarning("json raw string is empty"); Fsm.Event(failureEvent); Finish(); return; } Hashtable jsonHash; try { jsonHash = (Hashtable)JSON.JsonDecode(jsonString.Value); if (jsonHash == null) { LogWarning("json content is null"); return; } } catch (System.Exception e) { LogError("Json parsing error " + e.Message); Fsm.Event(failureEvent); Finish(); return; } if (jsonHash == null) { LogError("Json parsing failed "); Fsm.Event(failureEvent); Finish(); return; } int i = 0; foreach (FsmString _key in keys) { object _val = jsonHash[_key.Value]; if (_val != null) { //Debug.Log(_val.GetType().Name); if (_val.GetType() == typeof(Hashtable)) { if (values[i].Type == VariableType.GameObject) { // we put it into a hashtable with a proper reference to it; PlayMakerHashTableProxy _proxy = GetHashTableProxyPointer(values[i].gameObjectValue, _key.Value, true); if (_proxy != null) { Hashtable _table = (Hashtable)_val; foreach (DictionaryEntry _entry in _table) { if (_entry.Value.GetType() == typeof(Hashtable) || _entry.Value.GetType() == typeof(ArrayList)) { _proxy.hashTable[_entry.Key] = JSON.JsonEncode(_entry.Value); } else { _proxy.hashTable[_entry.Key] = _entry.Value; } } } } else if (values[i].Type == VariableType.String) { PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], JSON.JsonEncode(_val)); } } else if (_val.GetType() == typeof(ArrayList)) { if (values[i].Type == VariableType.GameObject) { // we put it into a arraylist with a proper reference to it; PlayMakerArrayListProxy _proxy = GetArrayListProxyPointer(values[i].gameObjectValue, "", true); if (_proxy != null) { // Debug.Log("We are in"); ArrayList _list = (ArrayList)_val; foreach (object _entry in _list) { // Debug.Log(_entry); if (_entry.GetType() == typeof(Hashtable) || _entry.GetType() == typeof(ArrayList)) { _proxy.arrayList.Add(JSON.JsonEncode(_entry)); } else { _proxy.arrayList.Add(_entry); } } } } else if (values[i].Type == VariableType.String) { PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], JSON.JsonEncode(_val)); } } else { PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], _val); } } i++; } Fsm.Event(successEvent); Finish(); }
public void ArrayDelete() { if (sortOn & nullOn) { proxy.arrayList.Sort(); } var varTemp = proxy.preFillType.ToString(); atIndex = -1; atIndex_iplus = 0; for (int a = 0; a < c; a++) { atIndex++; atIndex_iplus = atIndex; for (int i = 0; i < c; i++) { IGNORE: if (restartbool) { atIndex_iplus = atIndex; restartbool = false; } atIndex_iplus++; if (atIndex_iplus == c) { break; } bool elementContained = false; object element = null; object element_b = null; try{ element = proxy.arrayList[atIndex]; element_b = proxy.arrayList[atIndex_iplus]; }catch (System.Exception e) { Debug.Log(e.Message); string fullLabel = Fsm.GetFullFsmLabel(this.Fsm); string name = Fsm.ActiveStateName; Debug.Log("Fsm Path= " + fullLabel + " : " + name); Fsm.Event(failureEvent); return; } if (element == null) { break; } if (element_b == null) { goto IGNORE; } switch (varTemp) { case "Int": FsmInt fsmVarI = System.Convert.ToInt32(element); int tempInt = System.Convert.ToInt32(element_b); elementContained = fsmVarI.Value == tempInt; break; case "Float": FsmFloat fsmVarF = (float)element; float tempFloat = (float)(element_b); elementContained = fsmVarF.Value == tempFloat; break; case "Bool": FsmBool fsmVarB = (bool)element; bool tempBool = (bool)(element_b); elementContained = fsmVarB.Value == tempBool; break; case "Color": FsmColor fsmVarC = (Color)element; Color tempColor = (Color)(element_b); elementContained = fsmVarC.Value == tempColor; break; case "Quaternion": FsmQuaternion fsmVarQ = (Quaternion)element; Quaternion tempQuaternion = (Quaternion)(element_b); elementContained = fsmVarQ.Value == tempQuaternion; break; case "Rect": FsmRect fsmVarR = (Rect)element; Rect tempRect = (Rect)(element_b); elementContained = fsmVarR.Value == tempRect; break; case "Vector2": FsmVector2 fsmVarV2 = (Vector2)element; Vector2 tempV2 = (Vector2)(element_b); elementContained = fsmVarV2.Value == tempV2; break; case "Vector3": FsmVector3 fsmVarV3 = (Vector3)element; Vector3 tempV3 = (Vector3)(element_b); elementContained = fsmVarV3.Value == tempV3; break; case "String": FsmString fsmVarString = (string)element; string tempString = (string)(element_b); elementContained = fsmVarString.Value == tempString; break; case "GameObject": FsmGameObject fsmVarGameObject = (GameObject)element; GameObject tempGameObject = (GameObject)(element_b); elementContained = fsmVarGameObject.Value == tempGameObject; break; case "Material": Material fsmVarMaterial = (Material)element; Material tempMaterial = (Material)(element_b); elementContained = fsmVarMaterial == tempMaterial; break; case "Texture": Texture fsmVarTexture = (Texture)element; Texture tempTexture = (Texture)(element_b); elementContained = fsmVarTexture == tempTexture; break; case "AudioClip": var fsmVarUnknown = element; var tempUnknown = element_b; elementContained = fsmVarUnknown == tempUnknown; break; default: Debug.Log("ERROR"); break; } if (elementContained) { if (!nullOn) { proxy.arrayList.RemoveAt(atIndex_iplus); } else { element_b = PlayMakerUtils.GetValueFromFsmVar(this.Fsm, null); proxy.arrayList[atIndex_iplus] = element_b; } i = 0; c = proxy.arrayList.Count; restartbool = true; } } } Finish(); }