public void RemoveAll(bool _toEnd) { lock (dic) { Dictionary <int, SuperTweenUnit> tmpDic = dic; dic = new Dictionary <int, SuperTweenUnit> (); toDic = new Dictionary <Action <float>, SuperTweenUnit> (); Dictionary <int, SuperTweenUnit> .ValueCollection.Enumerator enumerator = tmpDic.Values.GetEnumerator(); while (enumerator.MoveNext()) { SuperTweenUnit unit = enumerator.Current; if (_toEnd) { if (unit.dele != null) { unit.dele(unit.endValue); } if (unit.endCallBack != null) { unit.endCallBack(); } } unit.isRemoved = true; } } }
public int To(float _startValue, float _endValue, float _time, Action <float> _delegate, Action _endCallBack, bool isFixed) { lock (dic) { if (toDic.ContainsKey(_delegate)) { SuperTweenUnit unit = toDic [_delegate]; unit.Init(unit.index, _startValue, _endValue, _time, _delegate, _endCallBack, isFixed); return(unit.index); } else { int result = GetIndex(); SuperTweenUnit unit = new SuperTweenUnit(); unit.Init(result, _startValue, _endValue, _time, _delegate, _endCallBack, isFixed); dic.Add(result, unit); toDic.Add(_delegate, unit); return(result); } } }
public void Remove(int _index, bool _toEnd) { lock (dic) { if (dic.ContainsKey(_index)) { SuperTweenUnit unit = dic [_index]; dic.Remove(_index); if (unit.dele != null) { toDic.Remove(unit.dele); } if (_toEnd) { if (unit.dele != null) { unit.dele(unit.endValue); } if (unit.endCallBack != null) { unit.endCallBack(); } } unit.isRemoved = true; } } }
public void RemoveAll(bool _toEnd) { Dictionary <int, SuperTweenUnit> tmpDic = dic; dic = new Dictionary <int, SuperTweenUnit>(); toDic = new Dictionary <Action <float>, SuperTweenUnit>(); IEnumerator <SuperTweenUnit> enumerator = tmpDic.Values.GetEnumerator(); while (enumerator.MoveNext()) { SuperTweenUnit unit = enumerator.Current; if (_toEnd) { if (unit.dele != null) { unit.dele(unit.endValue); } if (unit.endCallBack != null) { unit.endCallBack(); } } ReleaseUnit(unit); } }
public void SetTag(int _index, string _tag) { lock (dic) { if (dic.ContainsKey(_index)) { SuperTweenUnit unit = dic [_index]; unit.tag = _tag; } } }
public int NextFrameCall(Action _endCallBack) { int result = GetIndex(); SuperTweenUnit unit = GetUnit(); unit.Init(result, 0, 0, 0, null, _endCallBack, false); dic.Add(result, unit); return(result); }
public int DelayCall(float _time, Action _endCallBack, bool isFixed) { int result = GetIndex(); SuperTweenUnit unit = GetUnit(); unit.Init(result, 0, 0, _time, null, _endCallBack, isFixed); dic.Add(result, unit); return(result); }
public void RemoveWithTag(string _tag, bool _toEnd) { List <SuperTweenUnit> list = new List <SuperTweenUnit>(); IEnumerator <SuperTweenUnit> enumerator = dic.Values.GetEnumerator(); while (enumerator.MoveNext()) { SuperTweenUnit unit = enumerator.Current; if (unit.tag == _tag) { list.Add(unit); } } for (int i = 0; i < list.Count; i++) { SuperTweenUnit unit = list[i]; dic.Remove(unit.index); if (unit.dele != null) { toDic.Remove(unit.dele); } if (!_toEnd) { ReleaseUnit(unit); } } if (_toEnd) { for (int i = 0; i < list.Count; i++) { SuperTweenUnit unit = list[i]; if (unit.dele != null) { unit.dele(unit.endValue); } if (unit.endCallBack != null) { unit.endCallBack(); } ReleaseUnit(unit); } } }
public void RemoveWithTag(string _tag, bool _toEnd) { lock (dic) { List <SuperTweenUnit> list = new List <SuperTweenUnit> (); Dictionary <int, SuperTweenUnit> .ValueCollection.Enumerator enumerator = dic.Values.GetEnumerator(); while (enumerator.MoveNext()) { SuperTweenUnit unit = enumerator.Current; if (unit.tag != null && unit.tag.Equals(_tag)) { list.Add(unit); } } for (int i = 0; i < list.Count; i++) { SuperTweenUnit unit = list [i]; dic.Remove(unit.index); if (unit.dele != null) { toDic.Remove(unit.dele); } if (_toEnd) { if (unit.dele != null) { unit.dele(unit.endValue); } if (unit.endCallBack != null) { unit.endCallBack(); } } unit.isRemoved = true; } } }
// Update is called once per frame void Update() { lock (dic) { if (dic.Count > 0) { float nowTime = Time.time; float nowUnscaleTime = Time.unscaledTime; Dictionary <int, SuperTweenUnit> .Enumerator enumerator = dic.GetEnumerator(); while (enumerator.MoveNext()) { SuperTweenUnit unit = enumerator.Current.Value; float tempTime = 0; if (unit.isFixed) { tempTime = nowUnscaleTime; } else { tempTime = nowTime; } if (tempTime > unit.startTime + unit.time) { if (unit.dele != null) { toList.Add(new KeyValuePair <SuperTweenUnit, float>(unit, unit.endValue)); // unit.dele (unit.endValue); toDic.Remove(unit.dele); } endList.Add(unit); } else if (unit.dele != null) { float value = unit.startValue + (unit.endValue - unit.startValue) * (tempTime - unit.startTime) / unit.time; toList.Add(new KeyValuePair <SuperTweenUnit, float>(unit, value)); // unit.dele (value); } } if (toList.Count > 0) { for (int i = 0; i < toList.Count; i++) { KeyValuePair <SuperTweenUnit, float> pair = toList[i]; pair.Key.dele(pair.Value); } toList.Clear(); } if (endList.Count > 0) { for (int i = 0; i < endList.Count; i++) { SuperTweenUnit unit = endList [i]; dic.Remove(unit.index); if (!unit.isRemoved && unit.endCallBack != null) { unit.endCallBack(); } } endList.Clear(); } } } }
private void ReleaseUnit(SuperTweenUnit _unit) { pool.Enqueue(_unit); }
// Update is called once per frame void Update() { if (dic.Count > 0) { float nowTime = Time.time; float nowUnscaleTime = Time.unscaledTime; IEnumerator <SuperTweenUnit> enumerator = dic.Values.GetEnumerator(); while (enumerator.MoveNext()) { SuperTweenUnit unit = enumerator.Current; float tempTime = 0; if (unit.isFixed) { tempTime = nowUnscaleTime; } else { tempTime = nowTime; } if (tempTime > unit.startTime + unit.time) { if (unit.dele != null) { toList.Add(unit.index, unit.endValue); } endList.Add(unit.index); } else if (unit.dele != null) { float value = unit.startValue + (unit.endValue - unit.startValue) * (tempTime - unit.startTime) / unit.time; toList.Add(unit.index, value); } } if (toList.Count > 0) { IEnumerator <KeyValuePair <int, float> > enumerator2 = toList.GetEnumerator(); while (enumerator2.MoveNext()) { int index = enumerator2.Current.Key; SuperTweenUnit unit; if (dic.TryGetValue(index, out unit)) { unit.dele(enumerator2.Current.Value); } } toList.Clear(); } if (endList.Count > 0) { for (int i = 0; i < endList.Count; i++) { int index = endList[i]; SuperTweenUnit unit; if (dic.TryGetValue(index, out unit)) { dic.Remove(index); if (unit.dele != null) { toDic.Remove(unit.dele); } if (unit.endCallBack != null) { unit.endCallBack(); } ReleaseUnit(unit); } } endList.Clear(); } } }