public static XEffectComponent GetEffect(int id) { XEffectComponent effect = null; Instance._map.TryGetValue(id, out effect); return(effect); }
private void MakeOffsetScale(XEffectComponent xeffect, AnimationEvent e) { string srcString = e.stringParameter; if (srcString == "" || !srcString.Contains("#")) { return; } float offsetParam = float.Parse(srcString.Split('#')[0]); float scaleX = float.Parse(srcString.Split('#')[1]); float scaleZ = float.Parse(srcString.Split('#')[2]); xeffect.transform.localScale = new Vector3(scaleX, scaleZ, scaleZ); Vector3 tempPos = xeffect.transform.localPosition; tempPos.x += offsetParam * transform.Find("shape").localScale.x; xeffect.transform.localPosition = tempPos; _warnXEffectId = xeffect.gid; XBoxMotifyAttackWarning warning = xeffect.GetComponentInChildren <XBoxMotifyAttackWarning>(); if (warning != null) { warning.durtion = e.floatParameter; warning.elapse = 0; warning.isstart = true; } }
public void ClearQueueInCache() { for (int i = 0; i < _cacheList.Count; i++) { if (_cacheList[i].queue != null) { while (_cacheList[i].queue.Count > 0) { XEffectComponent eff = _cacheList[i].queue.Dequeue(); if (eff != null && eff.gameObject != null) { GameObject.Destroy(eff.gameObject); } } } } for (int i = 0; i < _bulletCacheList.Count; i++) { if (_bulletCacheList[i].queue != null) { while (_bulletCacheList[i].queue.Count > 0) { XBulletComponent eff = _bulletCacheList[i].queue.Dequeue(); if (eff != null && eff.gameObject != null) { GameObject.Destroy(eff.gameObject); } } } } _currentEffectCountDic.Clear(); }
public void DestroyEffect(XEffectComponent effect, bool destroyed = false) { if (effect == null) { return; } if (!destroyed) { XEffectCache effectCache = null; TryGetEffectCache(effect.resPath, out effectCache); if (effectCache != null) { if (effectCache.queue == null) { effectCache.queue = new Queue <XEffectComponent>(); } effectCache.queue.Enqueue(effect); effect.transform.parent = objectContainer; effect.gameObject.SetActive(false); } else if (effect.gameObject != null) { GameObject.Destroy(effect.gameObject); } } if (effect.gid > 0) { _map.Remove(effect.gid); effect.gid = 0; RemoveEffectCount(effect.resPath); } }
private IEnumerator GetEffect(string effectPath, System.Action <XEffectCache, XEffectComponent> callback) { XEffectCache effectCache = null; XEffectComponent effect = null; TryGetEffectCache(effectPath, out effectCache); if (effectCache == null) { effectCache = new XEffectCache(); effectCache.loading = true; AddEffectCache(effectPath, effectCache); yield return(XRes.LoadAsync <GameObject>(effectPath, delegate(Object obj) { effectCache.queue = new Queue <XEffectComponent>(); effectCache.prefab = obj as GameObject; effectCache.loading = false; })); } while (effectCache.loading) { yield return(null); } if (effectCache.prefab != null) { effect = GenerateEffect(effectPath, effectCache); } callback(effectCache, effect); }
private IEnumerator GetEffect(GameObject effectPrefab, System.Action <XEffectCache, XEffectComponent> callback) { XEffectCache effectCache = null; XEffectComponent effect = null; string effectPath = effectPrefab.name; TryGetEffectCache(effectPath, out effectCache); if (effectCache == null) { effectCache = new XEffectCache(); effectCache.loading = true; AddEffectCache(effectPath, effectCache); effectCache.queue = new Queue <XEffectComponent>(); effectCache.prefab = effectPrefab; effectCache.loading = false; } while (effectCache.loading) { yield return(null); } if (effectCache.prefab != null) { effect = GenerateEffect(effectPath, effectCache); } callback(effectCache, effect); }
void Awake() { XCameraFight fight = Camera.main.gameObject.GetComponent <XCameraFight>(); if (fight) { _isPvp = fight.IsPvp(); } if (fireEffectPrefab != null) { GameObject obj = GameObject.Instantiate(fireEffectPrefab); if (obj != null) { fireEffect_ = obj.GetComponent <XEffectComponent>(); fire_collider_ = obj.GetComponent <Collider>(); if (fire_collider_ != null) { fire_collider_.isTrigger = true; } } } if (flyEffectPrefab != null) { GameObject obj = GameObject.Instantiate(flyEffectPrefab); if (obj != null) { flyEffect_ = obj.GetComponent <XEffectComponent>(); collider_ = obj.GetComponent <Collider>(); if (collider_ != null) { collider_.isTrigger = true; } hitBox_ = obj.GetComponent <XBoxBulletHit>(); } } if (hitEffectPrefab != null) { GameObject obj = GameObject.Instantiate(hitEffectPrefab); if (obj != null) { hitEffect_ = obj.GetComponent <XEffectComponent>(); obj.transform.SetParent(transform); } } if (hitEffect_ != null) { hitEffect_.eventCallBack = delegate(XEffectComponent effect, XEffectComponent.EffectEventType eventType) { if (eventType == XEffectComponent.EffectEventType.FINISHED) { XEffectManager.Instance.DestroyBullet(this); } }; } }
public void DestroyEffect(int effectId) { XEffectComponent effect = null; _map.TryGetValue(effectId, out effect); if (effect != null) { DestroyEffect(effect, false); } }
private void AddEffectMap(XEffectComponent effect) { if (effect == null) { return; } effect.gid = _effectGlobalId++; _map.Add(effect.gid, effect); AddEffectCount(effect.resPath); }
// release queue private void ReleaseAllEffectQueueInCacheByTimeThreshold() { for (int i = 0; i < _cacheList.Count; i++) { if ((Time.time - _cacheList[i].createTime) > _effectQueueTimeThreshold && _cacheList[i].queue != null) { while (_cacheList[i].queue.Count > _maxEffectQueueCount) { XEffectComponent efc = _cacheList[i].queue.Dequeue(); GameObject.Destroy(efc.gameObject); } } } }
private bool CheckReleaseQueueInCacheByTimeThreshold(XEffectCache cache, float timeThreshold) { bool canEnqueue = true; if ((Time.time - cache.createTime) > timeThreshold && cache.queue != null) { while (cache.queue.Count > _maxEffectQueueCount) { XEffectComponent efc = cache.queue.Dequeue(); GameObject.Destroy(efc.gameObject); canEnqueue = false; } } return(canEnqueue); }
protected void AddFrameEffect(int status, XEffectConfigObject config, XEffectComponent xeffect) { xeffect.interruptType = config.interrupt; xeffect.freezeByAnimation = config.freezeByAnimation; xeffect.activedAnimatorState = status; List <XEffectComponent> list = null; _animatorFrameEffects.TryGetValue(status, out list); if (list == null) { list = new List <XEffectComponent>(); _animatorFrameEffects.Add(status, list); } list.Add(xeffect); }
public override void Release() { if (queue != null) { while (queue.Count > 0) { XEffectComponent efc = queue.Dequeue(); if (efc != null && efc.gameObject != null) { GameObject.Destroy(efc.gameObject); } } queue.Clear(); queue = null; } base.Release(); }
protected void InterruptAllPreEffects(int previous, int current) { foreach (KeyValuePair <int, List <XEffectComponent> > item in _animatorFrameEffects) { if (item.Key != current) { List <XEffectComponent> list = item.Value; for (int i = 0; i < list.Count; i++) { XEffectComponent xeffect = list[i]; if (xeffect != null && xeffect.gameObject.activeSelf) { xeffect.Interrupt(previous); } } list.Clear(); } } }
private XEffectComponent GenerateEffect(string effectPath, XEffectCache effectCache) { XEffectComponent effect = null; if (effectCache.queue.Count > 0) { effect = effectCache.queue.Dequeue(); if (effect == null || effect.gameObject == null) { effect = null; } else { effect.gameObject.SetActive(true); } } else { if (effectCache.prefab == null) { RemoveCache <XEffectCache>(_cacheList, effectCache); return(null); } if (!CanEffectInstantial(effectPath)) { return(null); } GameObject obj = GameObject.Instantiate(effectCache.prefab) as GameObject; effect = obj.GetComponent <XEffectComponent>(); if (effect != null) { effect.resPath = effectPath; } } AddEffectMap(effect); return(effect); }