// Update is called once per frame void Update() { if (isOpen) { if (Input.GetMouseButtonDown(0)) { x = Input.mousePosition.x; } if (Input.GetMouseButtonUp(0)) { float xOffset = Input.mousePosition.x - x; if (Mathf.Abs(xOffset) > CHECK_DISTANCE) { SliderDirection dir = xOffset > 0 ? SliderDirection.LEFT_TO_RIGHT : SliderDirection.RIGHT_TO_LEFT; SuperEvent ev = new SuperEvent(SCREEN_SLIDER_EVENT); ev.data = new object[] { dir }; SuperFunction.Instance.DispatchEvent(gameObject, ev); } } } }
// Update is called once per frame void Update() { if (Input.touchCount > 1) { if (distance == -1) { distance = Vector2.Distance(Input.GetTouch(0).position, Input.GetTouch(1).position); } else { float tmpDistance = Vector2.Distance(Input.GetTouch(0).position, Input.GetTouch(1).position); Vector2 pos = (Input.GetTouch(0).position + Input.GetTouch(1).position) / 2; SuperEvent e = new SuperEvent(SCALE_CHANGE); e.data = new object[] { tmpDistance / distance, pos }; SuperFunction.Instance.DispatchEvent(gameObject, e); distance = tmpDistance; } } else if (distance != -1) { distance = -1; } }
private void GetMouseMove(SuperEvent e) { if (isDown != DownType.NULL) { BackgroundMove(); } }
/// <inheritdoc> /// <summary> /// Enable or disable the listener on the bound SuperEvent. /// </summary> /// <returns><c>True</c> if listener was enabled/disabled successfully, <c>false</c> otherwise.true</returns> /// </inheritdoc> public bool Enable(bool enable) { if (enable) { if (Enabled) { return(false); } if (!SuperEvent.AddListener(Listener, AllowDuplicates)) { return(false); } Enabled = true; return(true); } if (!Enabled) { return(false); } if (!SuperEvent.RemoveListener(Listener)) { return(false); } Enabled = false; return(true); }
private void GetMouseDown(SuperEvent e) { if ((int)e.data[1] == 0) { BackgroundDown(); } }
public void DispatchEvent(SuperEvent e) { if (dicWithEvent.ContainsKey(e.eventName)) { Dictionary <Action <SuperEvent>, SuperEventListenerUnit> dic = dicWithEvent[e.eventName]; Action[] arr = new Action[dic.Count]; Dictionary <Action <SuperEvent>, SuperEventListenerUnit> .Enumerator enumerator = dic.GetEnumerator(); int i = 0; while (enumerator.MoveNext()) { KeyValuePair <Action <SuperEvent>, SuperEventListenerUnit> pair = enumerator.Current; SuperEvent ev = new SuperEvent(e.eventName, pair.Value.index, e.datas); Action del = delegate() { pair.Key(ev); }; arr[i] = del; i++; } for (i = 0; i < arr.Length; i++) { arr[i](); } } }
private void AttackOver(List <Hero2> _heros) { for (int i = 0; i < _heros.Count; i++) { string eventName = string.Format("{0}{1}", SkillEventName.ATTACKOVER, _heros[i].uid); SuperEvent e = new SuperEvent(eventName); superEventListener.DispatchEvent(e); eventName = string.Format("{0}{1}", SkillEventName.ATTACKOVER, _heros[i].isMine); e = new SuperEvent(eventName, _heros[i]); superEventListener.DispatchEvent(e); eventName = SkillEventName.ATTACKOVER.ToString(); e = new SuperEvent(eventName, _heros[i]); superEventListener.DispatchEvent(e); } List <Hero2> dieHeroList = null; Dictionary <int, Hero2> .ValueCollection.Enumerator enumerator = heroMapDic.Values.GetEnumerator(); while (enumerator.MoveNext()) { enumerator.Current.RefreshData(); if (enumerator.Current.nowHp < 1) { if (dieHeroList == null) { dieHeroList = new List <Hero2>(); } dieHeroList.Add(enumerator.Current); } } if (dieHeroList != null) { for (int i = 0; i < dieHeroList.Count; i++) { Hero2 dieHero = dieHeroList[i]; dieHero.Die(); _heros.Remove(dieHero); heroMapDic.Remove(dieHero.pos); } } }
private void BattleOver() { RefreshTouchable(true); gameObject.SetActive(false); SuperEvent e = new SuperEvent(BATTLE_OVER); SuperFunction.Instance.DispatchEvent(gameObject, e); }
private void ScaleChange(SuperEvent e) { float scale = (float)e.data[0]; float tmpScale = scale * childTransform.localScale.x; if (tmpScale < minScale) { scale = minScale / childTransform.localScale.x; } else if (tmpScale > maxScale) { scale = maxScale / childTransform.localScale.x; } Vector2 pos = (Vector2)e.data[1]; pos = pos * (containerHalfRect.x * 2 / Screen.width); Vector2 resultPos = GetAnchoredPosFix(pos, scale); if (scale < 1) { if (resultPos.x + childWidth / 2 * childTransform.localScale.x * scale < containerHalfRect.x) { // Debug.Log("右面漏了"); resultPos = new Vector2(containerHalfRect.x - childWidth / 2 * childTransform.localScale.x * scale, resultPos.y); } else if (resultPos.x + containerHalfRect.x - childWidth / 2 * childTransform.localScale.x * scale > 0) { // Debug.Log("左面漏了"); resultPos = new Vector2(childWidth / 2 * childTransform.localScale.x * scale - containerHalfRect.x, resultPos.y); } if (resultPos.y + childHeight / 2 * childTransform.localScale.x * scale < containerHalfRect.y) { // Debug.Log("上面漏了"); resultPos = new Vector2(resultPos.x, containerHalfRect.y - childHeight / 2 * childTransform.localScale.x * scale); } else if (resultPos.y + containerHalfRect.y - childHeight / 2 * childTransform.localScale.x * scale > 0) { // Debug.Log("下面漏了"); resultPos = new Vector2(resultPos.x, childHeight / 2 * childTransform.localScale.x * scale - containerHalfRect.y); } } childTransform.anchoredPosition = resultPos; childTransform.localScale = childTransform.localScale * scale; }
void Awake() { downEvent = new SuperEvent(DOWN); downEvent.data = new object[1]; moveEvent = new SuperEvent(MOVE); moveEvent.data = new object[2]; upEvent = new SuperEvent(UP); }
private void BattleOver(SuperEvent e) { gameObject.SetActive(true); panel.SetActive(true); btPVP.SetActive(true); btPVE.SetActive(true); btCancel.SetActive(false); }
public void DispatchAnimationEventUpwards(string _eventName, string[] _strs) { SuperEvent superEvent = new SuperEvent(_eventName); if (_strs.Length > 2) { object[] tempData = new object[_strs.Length - 2]; for (int i = 2; i < _strs.Length; i++) { tempData[i - 2] = _strs[i]; } superEvent.data = tempData; } SuperFunction.Instance.DispatchEvent(gameObject, superEvent); }
public override void Raycast(PointerEventData eventData, List <RaycastResult> resultAppendList) { //SuperDebug.Log("Raycast:" + SuperGraphicRaycastScript.Instance.isOpen); if (SuperGraphicRaycastScript.Instance.isOpen < 1) { return; } if (touchCount > 0) { return; } touchCount++; // if(Input.GetMouseButton(0) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0)){ base.Raycast(eventData, resultAppendList); if (filter) { for (int i = resultAppendList.Count - 1; i > -1; i--) { if (!resultAppendList[i].gameObject.CompareTag(filterTag)) { resultAppendList.RemoveAt(i); } } } if (checkBlock3DRayCast && resultAppendList.Count > 0) { SuperEvent e = new SuperEvent(SuperRaycast.GetBlockByUi); SuperFunction.Instance.DispatchEvent(SuperRaycast.Go, e); } // } }
private void ScaleChange(SuperEvent e) { float scrollValue = (float)e.data [0]; Vector2 mousePosition = (Vector2)e.data [1]; if (scrollValue < 1) { Vector2 v = PublicTools.MousePositionToCanvasPosition(canvas, mousePosition); Vector2 v2 = (v - battleContainer.anchoredPosition) / battleContainer.localScale.x; battleContainer.localScale = battleContainer.localScale * scaleStep; if (battleContainer.localScale.x < minScale) { battleContainer.localScale = new Vector3(minScale, minScale, minScale); } battleContainer.anchoredPosition = v - v2 * battleContainer.localScale.x; FixBattleContainerRect(); } else if (scrollValue > 1) { Vector2 v = PublicTools.MousePositionToCanvasPosition(canvas, Input.mousePosition); Vector2 v2 = (v - battleContainer.anchoredPosition) / battleContainer.localScale.x; battleContainer.localScale = battleContainer.localScale / scaleStep; if (battleContainer.localScale.x > maxScale) { battleContainer.localScale = new Vector3(maxScale, maxScale, maxScale); } battleContainer.anchoredPosition = v - v2 * battleContainer.localScale.x; } }
private void LoadOver() { SuperEvent e = new SuperEvent(LOAD_OVER_EVENT); SuperFunction.Instance.DispatchEvent(eventGo, e); }
public void OpenMove(SuperEvent e) { movementType = ScrollRect.MovementType.Elastic; }
public void CloseMove(SuperEvent e) { movementType = ScrollRect.MovementType.Clamped; }
private static void TriggerAura(Battle _battle, Hero _hero, IAuraSDS _auraSDS, SuperEvent e, ref float _value) { Hero targetHero = e.datas[0] as Hero; if (targetHero == _hero) { return; } List <int> pos = BattlePublicTools.GetNeighbourPos(_battle.mapData.neighbourPosMap, _hero.pos); if (pos.Contains(targetHero.pos)) { _value = _value * _auraSDS.GetAuraDatas()[0]; } }
void Update() { if (m_isOpen > 0) { isProcessingUpdate = true; RaycastHit[] hits = null; if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); hits = Physics.RaycastAll(ray, float.MaxValue, layerIndex); int i = 0; foreach (RaycastHit hit in hits) { if (m_filter && !hit.collider.gameObject.CompareTag(m_filterTag)) { continue; } objs.Add(hit.collider.gameObject); SuperEvent enterEvent = new SuperEvent(GetMouseEnter); SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, enterEvent); SuperEvent e = new SuperEvent(GetMouseButtonDown); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } } if (Input.GetMouseButton(0)) { if (hits == null) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); hits = Physics.RaycastAll(ray, float.MaxValue, layerIndex); } List <GameObject> newObjs = new List <GameObject>(); List <GameObject> enterObjs = new List <GameObject>(); int i = 0; foreach (RaycastHit hit in hits) { if (m_filter && !hit.collider.gameObject.CompareTag(m_filterTag)) { continue; } newObjs.Add(hit.collider.gameObject); if (!objs.Contains(hit.collider.gameObject)) { enterObjs.Add(hit.collider.gameObject); // SuperEvent enterEvent = new SuperEvent(GetMouseEnter); // // SuperFunction.Instance.DispatchEvent(hit.collider.gameObject,enterEvent); } else { objs.Remove(hit.collider.gameObject); } SuperEvent e = new SuperEvent(GetMouseButton); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } foreach (GameObject go in objs) { SuperEvent exitEvent = new SuperEvent(GetMouseExit); SuperFunction.Instance.DispatchEvent(go, exitEvent); } objs = newObjs; foreach (GameObject go in enterObjs) { SuperEvent enterEvent = new SuperEvent(GetMouseEnter); SuperFunction.Instance.DispatchEvent(go, enterEvent); } } if (Input.GetMouseButtonUp(0)) { if (hits == null) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); hits = Physics.RaycastAll(ray, float.MaxValue, layerIndex); } int i = 0; foreach (RaycastHit hit in hits) { if (m_filter && !hit.collider.gameObject.CompareTag(m_filterTag)) { continue; } SuperEvent e = new SuperEvent(GetMouseButtonUp); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } // foreach(GameObject go in objs){ // // SuperEvent exitEvent = new SuperEvent(GetMouseExit); // // SuperFunction.Instance.DispatchEvent(go,exitEvent); // } objs.Clear(); } if (needClearObjs) { needClearObjs = false; objs.Clear(); } isProcessingUpdate = false; } }
void Update() { if (m_checkBlockByUi && isBlockByUi) { isBlockByUi = false; return; } if (m_isOpen > 0 && renderCamera != null) { isProcessingUpdate = true; RaycastHit[] hits = null; if (Input.GetMouseButtonDown(0)) { Ray ray = renderCamera.ScreenPointToRay(Input.mousePosition); if (layerIndex == 0) { hits = Physics.RaycastAll(ray, float.MaxValue); } else { hits = Physics.RaycastAll(ray, float.MaxValue, layerIndex); } int i = 0; for (int m = 0; m < hits.Length; m++) { RaycastHit hit = hits[m]; if (m_filter && !hit.collider.gameObject.CompareTag(m_filterTag)) { continue; } objs.Add(hit.collider.gameObject); downObjs.Add(hit.collider.gameObject); // SuperEvent enterEvent = new SuperEvent(GetMouseEnter); // // SuperFunction.Instance.DispatchEvent(hit.collider.gameObject,enterEvent); SuperEvent e = new SuperEvent(GetMouseButtonDown); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } } if (Input.GetMouseButton(0)) { if (hits == null) { Ray ray = renderCamera.ScreenPointToRay(Input.mousePosition); if (layerIndex == 0) { hits = Physics.RaycastAll(ray, float.MaxValue); } else { hits = Physics.RaycastAll(ray, float.MaxValue, layerIndex); } } List <GameObject> newObjs = new List <GameObject>(); List <GameObject> enterObjs = new List <GameObject>(); int i = 0; for (int m = 0; m < hits.Length; m++) { RaycastHit hit = hits[m]; if (m_filter && !hit.collider.gameObject.CompareTag(m_filterTag)) { continue; } newObjs.Add(hit.collider.gameObject); if (!objs.Contains(hit.collider.gameObject)) { enterObjs.Add(hit.collider.gameObject); } else { objs.Remove(hit.collider.gameObject); } SuperEvent e = new SuperEvent(GetMouseButton); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } for (i = 0; i < objs.Count; i++) { SuperEvent exitEvent = new SuperEvent(GetMouseExit); SuperFunction.Instance.DispatchEvent(objs[i], exitEvent); } objs = newObjs; for (i = 0; i < enterObjs.Count; i++) { SuperEvent enterEvent = new SuperEvent(GetMouseEnter); SuperFunction.Instance.DispatchEvent(enterObjs[i], enterEvent); } } if (Input.GetMouseButtonUp(0)) { if (hits == null) { Ray ray = renderCamera.ScreenPointToRay(Input.mousePosition); if (layerIndex == 0) { hits = Physics.RaycastAll(ray, float.MaxValue); } else { hits = Physics.RaycastAll(ray, float.MaxValue, layerIndex); } } int i = 0; for (int m = 0; m < hits.Length; m++) { RaycastHit hit = hits[m]; if (m_filter && !hit.collider.gameObject.CompareTag(m_filterTag)) { continue; } SuperEvent e = new SuperEvent(GetMouseButtonUp); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); if (downObjs.Contains(hit.collider.gameObject)) { e = new SuperEvent(GetMouseClick); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); } i++; } downObjs.Clear(); objs.Clear(); } if (needClearObjs) { needClearObjs = false; objs.Clear(); downObjs.Clear(); } isProcessingUpdate = false; } }
private void CastSkill(int _index, SuperEvent e) { if (isSilent) { return; } List <Hero2> targets = null; ISkillSDS skillSDS = Battle2.skillDataDic[sds.GetSkills()[_index]]; switch (skillSDS.GetTargetType()) { case SkillTargetType.SELF: targets = new List <Hero2>() { this }; break; case SkillTargetType.ALLY: targets = BattlePublicTools2.GetTargetHeroList(battle.mapData.neighbourPosMap, battle.heroMapDic, this, TargetType.ALLY); break; case SkillTargetType.ENEMY: targets = BattlePublicTools2.GetTargetHeroList(battle.mapData.neighbourPosMap, battle.heroMapDic, this, TargetType.ENEMY); break; case SkillTargetType.ALL: targets = BattlePublicTools2.GetTargetHeroList(battle.mapData.neighbourPosMap, battle.heroMapDic, this, TargetType.ALL); break; case SkillTargetType.TRIGGER: Hero2 tmpHero = e.datas[0] as Hero2; if (tmpHero == this) { return; } targets = new List <Hero2>() { tmpHero }; break; } if (targets.Count == 0) { return; } switch (skillSDS.GetConditionType()) { case SkillConditionType.DISTANCE_SMALLER: int dis = BattlePublicTools2.GetHerosDistance(battle.mapData.neighbourPosMap, pos, targets[0].pos); if (dis == 0 || dis >= skillSDS.GetConditionData()) { return; } break; case SkillConditionType.HP_BIGGER: if (nowHp <= skillSDS.GetConditionData()) { return; } break; case SkillConditionType.HP_SMALLER: if (nowHp >= skillSDS.GetConditionData()) { return; } break; case SkillConditionType.POWER_BIGGER: if (nowPower <= skillSDS.GetConditionData()) { return; } break; } while (targets.Count > skillSDS.GetTargetNum()) { int index = (int)(battle.random.NextDouble() * targets.Count); targets.RemoveAt(index); } switch (skillSDS.GetEffectType()) { case SkillEffectType.SILENT: for (int i = 0; i < targets.Count; i++) { targets[i].ChangeSilent(); } break; case SkillEffectType.MAX_HP_CHANGE: for (int i = 0; i < targets.Count; i++) { targets[i].ChangeMaxHp(skillSDS.GetEffectData()[0]); } break; case SkillEffectType.DAMAGE_CHANGE: for (int i = 0; i < targets.Count; i++) { targets[i].ChangeDamage(skillSDS.GetEffectData()[0]); } break; case SkillEffectType.POWER_CHANGE: for (int i = 0; i < targets.Count; i++) { targets[i].ChangePower(skillSDS.GetEffectData()[0]); } break; case SkillEffectType.DO_DAMAGE: for (int i = 0; i < targets.Count; i++) { targets[i].ChangeHp(skillSDS.GetEffectData()[0]); } break; case SkillEffectType.DO_DAMAGE_FIX: for (int i = 0; i < targets.Count; i++) { int doDamage = skillSDS.GetEffectData()[0] + targets[i].sds.GetDamage() * skillSDS.GetEffectData()[1]; if (doDamage < 0) { targets[i].ChangeHp(doDamage); } } break; case SkillEffectType.RECOVER_HP: for (int i = 0; i < targets.Count; i++) { targets[i].ChangeHp(skillSDS.GetEffectData()[0]); } break; } }
private void CheckBlockByUiHandler(SuperEvent e) { isBlockByUi = true; }
//OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { SuperEvent superEvent = new SuperEvent("poseStart"); SuperFunction.Instance.DispatchEvent(animator.gameObject, superEvent); }
void Trigger(string _eventName) { SuperEvent superEvent = new SuperEvent(_eventName); SuperFunction.Instance.DispatchEvent(gameObject, superEvent); }
void Update() { if (isOpen) { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray, float.MaxValue, 1 << LayerMask.NameToLayer("Default")); int i = 0; foreach (RaycastHit hit in hits) { if (filter && !hit.collider.gameObject.CompareTag(filterTag)) { continue; } objs.Add(hit.collider.gameObject); SuperEvent enterEvent = new SuperEvent(GetMouseEnter); SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, enterEvent); SuperEvent e = new SuperEvent(GetMouseButtonDown); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } } else if (Input.GetMouseButton(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray, float.MaxValue, 1 << LayerMask.NameToLayer("Default")); List <GameObject> newObjs = new List <GameObject>(); List <GameObject> enterObjs = new List <GameObject>(); int i = 0; foreach (RaycastHit hit in hits) { if (filter && !hit.collider.gameObject.CompareTag(filterTag)) { continue; } newObjs.Add(hit.collider.gameObject); if (!objs.Contains(hit.collider.gameObject)) { enterObjs.Add(hit.collider.gameObject); // SuperEvent enterEvent = new SuperEvent(GetMouseEnter); // // SuperFunction.Instance.DispatchEvent(hit.collider.gameObject,enterEvent); } else { objs.Remove(hit.collider.gameObject); } SuperEvent e = new SuperEvent(GetMouseButton); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } foreach (GameObject go in objs) { SuperEvent exitEvent = new SuperEvent(GetMouseExit); SuperFunction.Instance.DispatchEvent(go, exitEvent); } objs = newObjs; foreach (GameObject go in enterObjs) { SuperEvent enterEvent = new SuperEvent(GetMouseEnter); SuperFunction.Instance.DispatchEvent(go, enterEvent); } } else if (Input.GetMouseButtonUp(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray, float.MaxValue, 1 << LayerMask.NameToLayer("Default")); int i = 0; foreach (RaycastHit hit in hits) { if (filter && !hit.collider.gameObject.CompareTag(filterTag)) { continue; } SuperEvent e = new SuperEvent(GetMouseButtonUp); e.data = new object[] { hit, i }; SuperFunction.Instance.DispatchEvent(hit.collider.gameObject, e); i++; } // foreach(GameObject go in objs){ // // SuperEvent exitEvent = new SuperEvent(GetMouseExit); // // SuperFunction.Instance.DispatchEvent(go,exitEvent); // } objs.Clear(); } } }
private void GetMouseExit(SuperEvent e) { SendMessageUpwards("MapUnitExit", this, SendMessageOptions.DontRequireReceiver); }
private void GetMouseClick(SuperEvent e) { SendMessageUpwards("MapUnitUpAsButton", this, SendMessageOptions.DontRequireReceiver); }
private static void TriggerSkill(Battle _battle, Hero _hero, ISkillSDS _skillSDS, SuperEvent e) { switch (_skillSDS.GetSkillTime()) { case SkillTime.SHOOT: case SkillTime.RUSH: case SkillTime.ATTACK: case SkillTime.COUNTER: ShootRushAttackCounter(_battle, _hero, _skillSDS, (int)e.datas[0], e.datas[1] as List <Hero>, e.datas[2] as List <Hero>, e.datas[3] as Dictionary <Hero, int>, e.datas[4] as Dictionary <Hero, int>); break; case SkillTime.ROUNDSTART: case SkillTime.SUMMON: case SkillTime.RECOVER: case SkillTime.DIE: RoundStartSummonRecoverDie(_battle, _hero, _skillSDS, e.datas[0] as Dictionary <Hero, int>, e.datas[1] as Dictionary <Hero, int>); break; } }