private void Awake() { RotationHelper.I.Initialize(); m_actions = m_actionContainer.GetComponentsInChildren <ActionController>(); m_keys = m_keyContainer.GetComponentsInChildren <KeyController>(); foreach (var cell in m_keys) { m_allCells.Add(cell); } m_nerves = new NerveController[m_nerveCount]; for (var i = 0; i < m_nerveCount; i++) { var nerve = Instantiate(m_nerverSettings.GetRandomNerve(), m_nerveContainer); nerve.transform.localPosition = new Vector3( Random.Range(m_nerverSettings.MinInitX, m_nerverSettings.MaxInitX), 0, 0); nerve.SetInitRotation(Random.Range(0f, m_nerverSettings.InitRotationRange)); m_nerves[i] = nerve; m_allCells.Add(nerve); } foreach (var cell in m_actions) { m_allCells.Add(cell); } EventEmitter.Add(GameEvent.Killed, OnKilled); EventEmitter.Add(GameEvent.KeyPressed, OnKeyPressed); EventEmitter.Add(GameEvent.KeyUp, OnKeyUp); }
private void Start() { #if UNITY_WEBGL || UNITY_EDITOR || UNITY_STANDALONE EventEmitter.Add(GameEvent.NerversDraging, OnNeverDragging); #endif gameObject.SetActive(!IsRotationKey); }
private void Awake() { instance = this; m_rigid = GetComponent <Rigidbody2D>(); m_collider = GetComponent <BoxCollider2D>(); EventEmitter.Add(GameEvent.Action, HandleOnAction); EventEmitter.Add(GameEvent.Killed, ElectricKill); EventEmitter.Add(GameEvent.StageClear, RequestStageClear); }
public void TestEmitInt() { var value = 0; EventEmitter.Add(GameEvent.None, Action1); EventEmitter.Emit(GameEvent.None, new IntEvent(1)); Assert.AreEqual(expected: 1, actual: value); void Action1(IEvent @event) { value = (@event as IntEvent).Value; } }
public void TestEmitNull() { var success = false; EventEmitter.Add(GameEvent.None, Action1); EventEmitter.Emit(GameEvent.None); Assert.IsTrue(success); void Action1(IEvent val) { success = true; } }
public void TestEmitMultiListener() { var value1 = 0; var value2 = 0; EventEmitter.Add(GameEvent.None, Action1); EventEmitter.Add(GameEvent.None, Action2); EventEmitter.Emit(GameEvent.None, new IntEvent(1)); Assert.AreEqual(expected: 1, actual: value1); Assert.AreEqual(expected: 1, actual: value2); void Action1(IEvent @event) { value1 = (@event as IntEvent).Value; } void Action2(IEvent @event) { value2 = (@event as IntEvent).Value; } }
public void TestEmitOrder() { var value = 0; var value1 = 0; var value2 = 0; EventEmitter.Add(GameEvent.None, Action1); EventEmitter.Add(GameEvent.None, Action2); EventEmitter.Emit(GameEvent.None); Assert.AreEqual(expected: 1, actual: value1); Assert.AreEqual(expected: 2, actual: value2); void Action1(IEvent @event) { value1 = ++value; } void Action2(IEvent @event) { value2 = ++value; } }
public void Initialize() { EventEmitter.Remove(GameEvent.NerversRotation, Rotate); EventEmitter.Add(GameEvent.NerversRotation, Rotate); }
void RegisterEvent() { EventEmitter.Add(GameEvent.LevelComplete, OnLevelComplete); }
void RegisterEvent() { EventEmitter.Add(GameEvent.LevelStart, OnLevelStart); }
private void RegisterEvent() { EventEmitter.Add(GameEvent.Complete, OnComplete); EventEmitter.Add(GameEvent.Restart, OnRestart); }
void Start() { Smartpad.Add(this); }
private void RegisterEvents() { EventEmitter.Add(GameEvent.PlayMusic, OnPlayMusic); EventEmitter.Add(GameEvent.PlaySound, OnPlaySound); }
void RegisterEvent() { EventEmitter.Add(GameEvent.LevelStart, OnLevelStart); EventEmitter.Add(GameEvent.LevelFail, OnLevelFail); EventEmitter.Add(GameEvent.LevelComplete, OnLevelComplete); }