public void AddBuff(int id) { if (HasBuff(id)) { return; } if (_buffIndex.Count == 0) { LoadBuffIndexFiles(); } string path; if (!_buffIndex.TryGetValue(id, out path)) { throw new Exception("Buff ID 不存在 " + id); } Buff buff = GetBuff(path); BuffRuntime br = new BuffRuntime(); br.Init(buff, new RuntimeData(SceneObject, null, null)); if (_isTraversing) { _toAddBuffRuntimeList.Add(br); //todo:呼吸一帧 } else { _buffRuntimeList.Add(br); // _buffRuntimes.Add(id, br); } }
public void Update(float deltaTime) { _isTraversing = true; for (int i = 0; i < _buffRuntimeList.Count; i++) { BuffRuntime br = _buffRuntimeList[i]; br.Breath(deltaTime); if (!br.isRunning) { _buffRuntimeList.RemoveAt(i); // _buffRuntimes.Remove(br.SourceData.ID); i--; } } _isTraversing = false; }
public void FixedUpdate() { _isTraversing = true; for (int i = 0; i < _buffRuntimeList.Count; i++) { BuffRuntime br = _buffRuntimeList[i]; br.FixedBreath(); if (!br.isRunning) { _buffRuntimeList.RemoveAt(i); // _buffRuntimes.Remove(br.SourceData.ID); i--; } } _isTraversing = false; AfterFixedUpdate(); }