public override void OnInspectorGUI() { StringEvent script = (StringEvent)target; //Event Description GUILayout.BeginVertical(); EditorGUILayout.LabelField("Event Description", EditorStyles.centeredGreyMiniLabel); EditorStyles.textField.wordWrap = true; script.EventDescription = EditorGUILayout.TextArea(script.EventDescription, GUILayout.MinHeight(100)); GUILayout.EndVertical(); //Test Event Button GUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Test Event", EditorStyles.centeredGreyMiniLabel); value = EditorGUILayout.TextField("Value ", value); if (GUILayout.Button("Raise")) { if (Application.isPlaying) { script.Raise(value); } } GUILayout.EndVertical(); }
/// <summary> /// creates the menu item as a visible object in the 3D scene /// </summary> /// <param name="parentMenu">The menu to which the item belongs</param> /// <param name="parent">The parent menu item</param> public void Create(Menu parentMenu, CustomMenuItem parent) { this.parentMenuItem = parent; this.parentMenu = parentMenu; subMenuOpened = false; if (menuStyle == null) { menuStyle = parentMenu.defaultMenuStyle; } containerInstance = GameObject.Instantiate(menuStyle, parentMenu.transform); menuStyleAdapter = containerInstance.GetComponent <MenuStyleAdapter>(); menuStyleAdapter.Initialize(); menuStyleAdapter.RegisterForClickEvent(OnClick); menuStyleAdapter.UpdateText(text); menuStyleAdapter.UpdateIcon(icon); menuStyleAdapter.ItemEnabled = ItemEnabled; if (markOnClick) { menuStyleAdapter.Marked = marked; } if (onClickEvent == null) { onClickEvent = new StringEvent(); } }
IEnumerator RunTimer( int timeout, StringEvent bannerEvent ) { yield return(RunTimer(timeout, bannerEvent, () => true)); }
void Awake() { logEvent = new StringEvent(); LogWindow logWindow = GameObject.Find("LogWindow").GetComponent <LogWindow>(); logEvent.AddListener(logWindow.DisplayIntoLogWindow); //Для тестирования установим персонажам некоторую экипировку if (name == "Warrior") { onMainHand = new Weapon("Longsword", 3, 15, EquipmentType.FindByShortcut("M"), DiceSet.GetByName("1d8"), DamageType.Slashing, 5); armor = new Armor("Chain Mail", 55, 75, EquipmentType.FindByShortcut("HA"), 16); } else if (name == "Wizard") { //onMainHand = new Weapon("Quarterstaff", 2, 4, EquipmentType.FindByShortcut("M"), DiceSet.GetDiceSet("1d6"), DamageType.FindByShortcut("B"), 5); onMainHand = new Weapon("Fire bolt", 0, 0, EquipmentType.FindByShortcut("R"), DiceSet.GetByName("1d10"), DamageType.Fire, 30); } //Если зомби - установим оружие "когти зомби" else if (name.Contains("Zombie")) { onMainHand = new Weapon("Zombie's claws", 0, 0, EquipmentType.FindByShortcut("M"), DiceSet.GetByName("1d6"), DamageType.Bludgeoning, 5); } InitializeParameters(); CalculateArmorClass(); CalculateInitiative(); DefineAttackRange(); }
Callbacks() { if (null == onInitialized) { onInitialized = new BoolEvent(); } if (null == onSuccess) { onSuccess = new ProductEvent(); } if (null == onFailure) { onFailure = new ProductStringEvent(); } if (null == onCanceled) { onCanceled = new ProductEvent(); } if (null == onRestored) { onRestored = new ProductEvent(); } if (null == onProductRequestSuccess) { onProductRequestSuccess = new ProductArrayEvent(); } if (null == onProductRequestFailure) { onProductRequestFailure = new StringEvent(); } if (null == onRestoreComplete) { onRestoreComplete = new BoolStringEvent(); } }
public void addListener(StringEvent listener) { if (!listeners.Contains(listener)) { listeners.Add(listener); } }
public void Given_NoRequiredProperties_When_Serialised_Should_ThrowException() { var ev = new StringEvent(); Action action = () => JsonConvert.SerializeObject(ev); action.Should().Throw <JsonSerializationException>(); ev.EventType = null; ev.Source = (new Uri("http://localhost")).ToString(); ev.EventId = Guid.NewGuid().ToString(); action = () => JsonConvert.SerializeObject(ev); action.Should().Throw <JsonSerializationException>(); ev.EventType = "com.example.someevent"; ev.Source = null; ev.EventId = Guid.NewGuid().ToString(); action = () => JsonConvert.SerializeObject(ev); action.Should().Throw <JsonSerializationException>(); ev.EventType = "com.example.someevent"; ev.Source = (new Uri("http://localhost")).ToString(); ev.EventId = null; action = () => JsonConvert.SerializeObject(ev); action.Should().Throw <JsonSerializationException>(); }
void Awake() { if (OnInputEvent == null) { OnInputEvent = new StringEvent(); } }
public void Given_Version_Should_HaveVersion() { var version = "v1"; var ev = new StringEvent(version); ev.CloudEventsVersion.Should().Be(version); }
public LoadingScene(string sceneToLoad, StringEvent beginEvent, LevelLoadData data, float maxLoadTime) { this._transitionData = data.Transitions; this._sceneToLoad = sceneToLoad; this._maxLoadTime = maxLoadTime; this._beginEvent = beginEvent; this._displayLoading = data.ShowLoadingSceen; }
public void AddOnDataReceivedListener(UnityAction <string> listener) { if (onDataReceived == null) { onDataReceived = new StringEvent(); } onDataReceived.AddListener(listener); }
void Awake() { Library.initializeGameData(); modalPanel = ModalPanel.Instance(); quitAction = new UnityAction(QuitAction); logEvent = new StringEvent(); }
IEnumerator RunTimer( int timeout, StringEvent bannerEvent, System.Func <bool> conditionPredicate ) { bool showTimeSplit = (timeout > 60); var startTime = Time.fixedTime; var lastTick = timeout; timerTick = lastTick; if (debug) { Debug.Log("Tick: " + lastTick); } if (bannerEvent != null) { bannerEvent.Raise(FmtTimerMsg(showTimeSplit, lastTick)); } var currentDelta = Time.fixedTime - startTime; while (conditionPredicate() && (currentDelta < (float)timeout)) { var currentTick = timeout - Mathf.FloorToInt(currentDelta); if (currentTick != lastTick) { lastTick = currentTick; timerTick = lastTick; if (debug) { Debug.Log("Tick: " + lastTick); } if (bannerEvent != null) { bannerEvent.Raise(FmtTimerMsg(showTimeSplit, lastTick)); } } // wait until next frame; yield return(null); currentDelta = Time.fixedTime - startTime; } // don't show last tick if condition was hit if (conditionPredicate()) { lastTick = 0; timerTick = lastTick; if (bannerEvent != null) { bannerEvent.Raise(FmtTimerMsg(showTimeSplit, lastTick)); } if (debug) { Debug.Log("Tick: " + lastTick); } } }
public static void TriggerEvent(string eventName, string tag) { StringEvent thisEvent = null; if (Instance.stringEventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(tag); } }
public void Serializes_and_deserializes_without_attributes() { var serializer = new ProtocolBuffersSerializer(); var @event = new StringEvent("foo"); var serialized = serializer.SerializeToStream(@event); serialized.Position = 0; var deserialized = serializer.DeserializeFromStream<StringEvent>(serialized); Assert.AreEqual(@event, deserialized); }
/// <summary> /// should be called if the menu item is created programmatically and not in the Unity editor /// </summary> public void Init(GameObject menuStyle, List <CustomMenuItem> subMenu, bool closeOnClick) { this.menuStyle = menuStyle; this.subMenu = subMenu; this.closeOnClick = closeOnClick; if (onClickEvent == null) { onClickEvent = new StringEvent(); } }
void Start() { receiver = new OSCReceiver(); receiver.Open(port); if (updateEvent == null) { updateEvent = new StringEvent(); } }
public static void StopListeningStringEvent(string eventName, UnityAction <string> listener) { Init(); StringEvent thisStringEvent = null; if (stringEventDictionary.TryGetValue(eventName, out thisStringEvent)) { thisStringEvent.RemoveListener(listener); } }
private async void PersistsAsSerialized(ISerializer serializer, string extension) { var consumer = new FileConsumer <StringEvent>(serializer, _fixture.Folder, extension); var @event = new StringEvent("Test!"); await consumer.HandleAsync(@event); var file = OneFileSaved(extension); FileContainsTheEvent(file, serializer, @event); }
public void Given_ValidContentType_When_DataIsSet_Should_BeOk() { var data = "hello world"; var ev = new StringEvent(); ev.ContentType = "text/plain"; ev.Data = data; ev.Data.Should().Be(data); }
public void Serializes_and_deserializes_without_attributes() { var serializer = new ProtocolBuffersSerializer(); var @event = new StringEvent("foo"); var serialized = serializer.SerializeToStream(@event); serialized.Position = 0; var deserialized = serializer.DeserializeFromStream <StringEvent>(serialized); Assert.AreEqual(@event, deserialized); }
private StringEvent GetOrCreateStringEvent(string eventName) { UnityEventBase currentEvent = null; if (!Instance.m_EventDict.TryGetValue(eventName, out currentEvent)) { currentEvent = new StringEvent(); Instance.m_EventDict.Add(eventName, currentEvent); } return(currentEvent as StringEvent); }
public static void TriggerStringEvent(string eventName, string value) { Init(); StringEvent thisEvent = null; if (stringEventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(value); } }
public void Reset() { DataDumpProperty = null; OnStringUpdated = null; OnIntUpdated = null; OnIntUpdatedAsString = null; OnFloatUpdated = null; OnFloatUpdatedAsString = null; OnBoolUpdated = null; OnBoolUpdatedAsString = null; }
private static void PersistsAsSerialized(Serializer serializer, string extension) { var consumer = new FileConsumer <StringEvent>(serializer, "Events", extension); var @event = new StringEvent("Test!"); consumer.Handle(@event); var file = OneFileSaved(extension); FileContainsTheEvent(file, serializer, @event); }
public void SetHolderData(int posX, int posY, float bucketHoldTime, Vector2Event passBucketEvent, Vector2Event receiveBucketEvent, StringEvent keyPressEvent, List <string> keys, Transform parent) { this.posX = posX; this.posY = posY; this.bucketHoldTime = bucketHoldTime; this.passBucketEvent = passBucketEvent; this.receiveBucketEvent = receiveBucketEvent; this.keyPressEvent = keyPressEvent; this.keys = keys; transform.parent = parent; }
public void Given_RequiredProperties_When_Serialised_Should_BeOk() { var ev = new StringEvent(); ev.EventType = "com.example.someevent"; ev.Source = (new Uri("http://localhost")).ToString(); ev.EventId = Guid.NewGuid().ToString(); var serialised = string.Empty; Action action = () => serialised = JsonConvert.SerializeObject(ev); action.Should().NotThrow <Exception>(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.enabled = Application.isPlaying; StringEvent e = target as StringEvent; if (GUILayout.Button("Raise")) { e.Raise(e.testRaiseData); } }
void Awake() { if (OnInputEvent == null) { OnInputEvent = new StringEvent(); } if (Time.timeScale == 0) { Time.timeScale = 1; } mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>() as Camera; }
public void StringEventTest() { var e = new StringEvent(); string counter = ""; e.AddListener((val) => counter += "-" + val); Assert.AreEqual(counter, ""); e.Invoke("1"); Assert.AreEqual(counter, "-1"); e.Invoke("22"); e.Invoke("33"); Assert.AreEqual(counter, "-1-22-33"); }
public static void StopListening(string eventName, UnityAction <string> listener) { if (eventManager == null) { return; } StringEvent thisEvent = null; if (Instance.stringEventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
protected override void Awake() { base.Awake(); image = GetComponent <Image>(); text = transform.GetChild(0).GetComponent <Text>(); image.sprite = buttonUpSprite; if (stringEvent == null) { stringEvent = new StringEvent(); } //Setup(0); UpdateText(); }
public bool LoadFromLogFile (string filepath) { XDocument doc = XDocument.Load (filepath); foreach (XElement element in doc.Element("xs-event-replay-log").Elements ()) { if (element == null) { continue; } string evType = element.Attribute ("type").Value; RecordEvent ev = null; if (evType == "KeyPressEvent") { ev = new KeyPressEvent (); } else if (evType == "CommandEvent") { ev = new CommandEvent (); } else if (evType == "StringEvent") { ev = new StringEvent (); } if (ev == null) { return false; } ev.ParseXML (element); events.Add (ev); } return true; }