private void CheckLayerAndDoSomething(Collider other) { if (TriggerListener.IsInLayerMask(other.gameObject.layer, reactLayers)) { Collect(other); } }
public void PerformTest() { // Arrange int count = 0; TriggerListener listener = new TriggerListener(); Trigger trigger = listener.CreateTrigger(); // Act & assert (hasn't fired yet) listener.SetContinuation( () => { count++; } ); listener.Activate(); Assert.Equal(0, count); // Act & assert (fire it, get the callback) trigger.Fire(); Assert.Equal(1, count); // Act & assert (fire again, but no callback since it already fired) Trigger trigger2 = listener.CreateTrigger(); trigger2.Fire(); Assert.Equal(1, count); }
void OnTriggerExit(Collider col) { Rigidbody rb = Tools.FindInParents <Rigidbody>(col.transform); if (rb != null && !rb.isKinematic) { foreach (Entry ent in mList) { if (ent.rb == rb) { if (--ent.counter <= 0) { mList.Remove(ent); for (int i = mOnExit.Count; i > 0;) { TriggerListener listener = mOnExit[--i]; if (listener.mb == null || !listener.callback(rb)) { mOnExit.RemoveAt(i); } } } return; } } } }
void OnTriggerEnter(Collider col) { Rigidbody rb = Tools.FindInParents <Rigidbody>(col.transform); if (rb != null && !rb.isKinematic) { foreach (Entry ent in mList) { if (ent.rb == rb) { ++ent.counter; return; } } Entry e = new Entry(); e.rb = rb; e.counter = 1; mList.Add(e); for (int i = mOnEnter.Count; i > 0;) { TriggerListener listener = mOnEnter[--i]; if (listener.mb == null || !listener.callback(rb)) { mOnEnter.RemoveAt(i); } } } }
private EventManager() { this.initializedFlag = false; this.initializedListener = null; this.hitInfoListener = null; this.lastHitInfo = null; }
public void RegisterPlaySceneReadyListener(TriggerListener l) { if (playSceneReady) { l (); } else { this.playSceneReadyListener = l; } }
public void RegisterInitializedListener(TriggerListener l) { if (initializedFlag) { l (); } else { this.initializedListener = l; } }
// Use this for initialization void Start() { m_tl = (TriggerListener)Listener.GetComponent <TriggerListener>(); if (m_tl == null) { Object.Destroy(this); } }
void Start() { indexTipObj.GetComponent <Renderer>().enabled = false; knuckleObj.GetComponent <Renderer>().enabled = false; nerfGunObj.GetComponent <Renderer>().enabled = false; triggerComponent = thumbTipObj.GetComponent <TriggerListener>(); nerfGunComponent = nerfGunObj.GetComponent <NerfGunScript>(); }
public static TriggerListener Get(GameObject go) { TriggerListener tmpListener = go.GetComponent <TriggerListener>(); if (null == tmpListener) { tmpListener = go.AddComponent <TriggerListener>(); } return(tmpListener); }
void OnSceneLoaded() { Game.WindowsMgr.ShowWindow <FadeWnd, bool, bool>(false, true); GameObject tmpSceneMaskGo = GameObject.Find("SceneMask"); mSceneMaskSprs.Clear(); if (null != tmpSceneMaskGo) { for (int i = 0, max = tmpSceneMaskGo.transform.childCount; i < max; ++i) { SpriteRenderer tmpSprRender = tmpSceneMaskGo.transform.GetChild(i).GetComponent <SpriteRenderer>(); if (null != tmpSprRender) { mSceneMaskSprs.Add(tmpSprRender); tmpSprRender.color = Color.clear; } } } GameObject tmpInstanceRoot = GameObject.Find("InstanceRoot"); mTriggerCount = 0; GameObject tmpTransferGo = Utility.GameObj.Find(tmpInstanceRoot, "Transfer"); if (tmpTransferGo) { mTriggerCount += tmpTransferGo.transform.childCount; for (int i = 0, max = tmpTransferGo.transform.childCount; i < max; ++i) { TriggerListener.Get(tmpTransferGo.transform.GetChild(i).gameObject).OnEnter = OnTriggerEnterTransfer; } } GameObject tmpTriggerGo = Utility.GameObj.Find(tmpInstanceRoot, "Trigger"); if (tmpTriggerGo) { mTriggerCount += tmpTriggerGo.transform.childCount; for (int i = 0, max = tmpTriggerGo.transform.childCount; i < max; ++i) { TriggerListener.Get(tmpTriggerGo.transform.GetChild(i).gameObject).OnEnter = OnTriggerEnterTrigger; } } GameObject tmpBornPosGo = Utility.GameObj.Find(tmpInstanceRoot, "BornPos"); if (tmpBornPosGo) { mLocalPlayer.SetPosition(tmpBornPosGo.transform.position); mLocalPlayer.Controller.RepositionCamera(); } }
public void Initialize(bool isMandatory, Transform gameTransform, TriggerListener listener, LayerMask reactLayers, Sprite radarIcon) { RadarIcon = radarIcon; IsMandatory = isMandatory; RotationalTransform = GameTransform = gameTransform; RegisterAsTransformOwner(); RegisterToRadar(); MyTriggerListener = listener; this.reactLayers = reactLayers; SubscribeToTriggerListener(); RotationSpeed = Random.Range(0.1f, 0.5f) * Vector3.forward * 360f; StartRotating(MasterManager.Instance.LinksHolder.RotationManager); }
private void Initialize() { if (!isInitialized) { isInitialized = true; cutScenes.ForEach(cutScene => cutScene.AddEventListener(this.gameObject)); if (this.transform.Find("CutSceneEnableCollider")) { cutSceneEnableTriggerListener = this.transform.Find("CutSceneEnableCollider").GetComponent <TriggerListener>(); cutSceneEnableTriggerListener.AddEventListener(this.gameObject); } uiElements = new List <UIElement>(SceneUtils.FindObjectsOfType <UIElement>()); } }
// Use this for initialization void Start() { triggerListener = gameObject.GetComponent <TriggerListener>(); shootTimer = shootTimerSeed + shootTimerSeed * 3.0f * Random.value; deathTimer = deathTimerSeed + deathTimerSeed * 3.0f * Random.value; movementComponent = GetComponent <HorizontalGroundMovement>(); animator = GetComponent <Animator>(); if (triggered == true) { Invoke("Shoot", shootTimer); Invoke("Death", deathTimer); } }
public override IAsyncResult BeginExecute(ControllerContext context, IDictionary <string, object> parameters, AsyncCallback callback, object state) { Precondition.Require(context, () => Error.ArgumentNull("context")); Precondition.Require(parameters, () => Error.ArgumentNull("parameters")); AsyncManager asyncManager = GetAsyncManager(context.Controller); BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) { object[] parameterValues = _entryMethod.GetParameters() .Select(p => ExtractParameter(p, parameters, _entryMethod)) .ToArray(); TriggerListener listener = new TriggerListener(); MvcAsyncResult asyncResult = new MvcAsyncResult(asyncState); Trigger finishTrigger = listener.CreateTrigger(); asyncManager.Finished += delegate { finishTrigger.Fire(); }; asyncManager.OutstandingOperations.Increment(); listener.SetContinuation(() => ThreadPool.QueueUserWorkItem(_ => asyncResult.MarkCompleted(false, asyncCallback))); DispatcherCache.GetDispatcher(_entryMethod) .Execute(context.Controller, parameterValues); asyncManager.OutstandingOperations.Decrement(); listener.Activate(); return(asyncResult); }; EndInvokeDelegate <object> endDelegate = delegate(IAsyncResult asyncResult) { object[] parameterValues = _completedMethod.GetParameters() .Select(p => ExtractParameter(p, parameters, _completedMethod)) .ToArray(); return(DispatcherCache.GetDispatcher(_completedMethod) .Execute(context.Controller, parameterValues)); }; return(AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _executeTag, asyncManager.Timeout)); }
/// <summary> /// Add a new exit event listener. /// </summary> static public void AddOnExit(Component mb, OnTriggerCallback callback) { ProximityManager pro = GetInstance(mb); foreach (TriggerListener p in pro.mOnExit) { if (p.mb == mb && p.callback == callback) { return; } } TriggerListener ent = new TriggerListener(); ent.mb = mb; ent.callback = callback; pro.mOnExit.Add(ent); }
// Use this for initialization void Start() { triggerListener = gameObject.GetComponent <TriggerListener>(); if (useSceneStartingPoint == false) { this.gameObject.transform.position = new Vector3(startingPointX, this.gameObject.transform.position.y, this.gameObject.transform.position.z); } Vector3 moveDirection = new Vector3(this.gameObject.transform.localScale.x * startingDirection, this.gameObject.transform.localScale.y, this.gameObject.transform.localScale.z); this.gameObject.transform.localScale = moveDirection; if (randomizeSpeed == true) { speed = speed + (2f * randomSpeedFactor * Random.value); } }
/// <summary> /// DI 所使用的构造方法 /// </summary> /// <param name="options"></param> /// <param name="logger"></param> /// <param name="killAllListener"></param> /// <param name="killListener"></param> /// <param name="triggerListener"></param> public SwarmClient(IOptions <SwarmClientOptions> options, ILogger <SwarmClient> logger, KillAllListener killAllListener, KillListener killListener, TriggerListener triggerListener) { _logger = logger; var ops = options.Value; Name = ops.Name; Host = new Uri(ops.Host).ToString(); Group = ops.Group; AccessToken = ops.AccessToken; RetryTimes = ops.RetryTimes; Ip = ops.Ip; HeartbeatInterval = ops.HeartbeatInterval; _killAllListener = killAllListener; _killListener = killListener; _triggerListener = triggerListener; //TODO: Validate data Name = string.IsNullOrWhiteSpace(Name) ? Dns.GetHostName() : Name; if (string.IsNullOrWhiteSpace(Ip)) { var interfaces = NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault(i => (i.NetworkInterfaceType == NetworkInterfaceType.Ethernet || i.NetworkInterfaceType == NetworkInterfaceType.Wireless80211) && i.OperationalStatus == OperationalStatus.Up); if (interfaces != null) { Ip = interfaces.GetIPProperties().UnicastAddresses.FirstOrDefault(a => a.IPv4Mask?.ToString() != "255.255.255.255" && a.Address.AddressFamily == AddressFamily.InterNetwork)?.Address .ToString(); } } if (string.IsNullOrWhiteSpace(Ip)) { Ip = "127.0.0.1"; } }
public void PerformTest() { // Arrange int count = 0; TriggerListener listener = new TriggerListener(); Trigger trigger = listener.CreateTrigger(); // Act & assert 1 listener.SetContinuation(() => { count++; }); listener.Activate(); Assert.AreEqual(0, count, "Callback shouldn't have been executed."); // Act & assert 2 trigger.Fire(); Assert.AreEqual(1, count, "Callback should've been called once."); // Act & assert 3 Trigger trigger2 = listener.CreateTrigger(); trigger2.Fire(); Assert.AreEqual(1, count, "Callback should only be called once."); }
public void PerformTest() { // Arrange int count = 0; TriggerListener listener = new TriggerListener(); Trigger trigger = listener.CreateTrigger(); // Act & assert (hasn't fired yet) listener.SetContinuation(() => { count++; }); listener.Activate(); Assert.Equal(0, count); // Act & assert (fire it, get the callback) trigger.Fire(); Assert.Equal(1, count); // Act & assert (fire again, but no callback since it already fired) Trigger trigger2 = listener.CreateTrigger(); trigger2.Fire(); Assert.Equal(1, count); }
public void PerformTest() { // Arrange int count = 0; TriggerListener listener = new TriggerListener(); Trigger trigger = listener.CreateTrigger(); // Act & assert 1 listener.SetContinuation(() => { count++; }); listener.Activate(); Assert.AreEqual(0, count, "Callback shouldn't have been executed."); // Act & assert 2 trigger.Fire(); Assert.AreEqual(1, count, "Callback should've been called once."); // Act & assert 3 Trigger trigger2 = listener.CreateTrigger(); trigger2.Fire(); Assert.AreEqual(1, count, "Callback should only be called once."); }
public static void SubscribeToTrigger(GameObject g, TriggerListener listener) { GetOrAddScript(g).trigListeners.Add(listener); }
// Use this for initialization void Start() { kingCatchTrigger = GetComponentInChildren <TriggerListener>(); }
public static TriggerListener BuildTriggerListener(this ConnectionStringBuilder connectionStringBuilder) { var tel = new TriggerListener(connectionStringBuilder); return(tel); }
public void Initialize(TriggerListener l) { listener = l; }