protected override object ProcessValue(object curValue) { if (_fe == null && curValue != _fe && curValue != null) { _fe = curValue as FxEngine; _fe.FxEvent += OnFxEvent; } if (_fe == null) { return(curValue); } foreach (var fx in _fe.ActiveFXs) { if (_currentFxs.ContainsKey(fx.Key)) { continue; } else { var fxRes = Resources.Load <GameObject>(fx.Value.fx); var fxInst = GameObject.Instantiate(fxRes, _fxsPlayer.Locations[fx.Value.location].transform); _currentFxs.Add(fx.Key, fxInst.transform); } } var fxsToRemove = _currentFxs.Where(x => !_fe.ActiveFXs.ContainsKey(x.Key)); if (fxsToRemove.Any()) { foreach (var fxToRemove in fxsToRemove.ToList()) { _currentFxs.Remove(fxToRemove.Key); if (fxToRemove.Value.gameObject != null) { GameObject.Destroy(fxToRemove.Value.gameObject); } } } return(curValue); }
private double processFx(object state) { if (!IsDisposed && ActiveFx && FxEngine != null) { if (FxEngine.Process(this, IsKeyOff, IsSoundOff)) { OnProcessFx(); } ActiveFx = FxEngine.Active; if (ActiveFx) { return(FxEngine.Settings.EnvelopeInterval); } else if (IsKeyOff) { TrySoundOff(); } } return(-1); }