public void Remove(EventType eventType) { for (var i = 0; i < _actions.Count; i++) { if (_actions[i].EventType != eventType) { continue; } _actions.RemoveAt(i); switch (eventType) { case EventType.SetSpeed: OnActionChanged?.Invoke(CacheValue.Bpm); break; case EventType.Twirl: OnActionChanged?.Invoke(CacheValue.IsClockWise); break; case EventType.NotAvailable: break; default: throw new ArgumentOutOfRangeException(nameof(eventType), eventType, null); } break; } }
public void SelectAction(Action iAction) { if (selectedAction.Result != null && selectedAction != iAction) { selectedAction.Result.Deselect(); } selectedAction = iAction; selectedAction.Result.Select(); Debug.Log("[" + selectedAction.Result.ToString() + "]"); if (OnActionChanged != null) { OnActionChanged.Invoke(iAction); } }
public void Add(Data.Action action) { Action instance = null; switch (action.EventType) { case EventType.Twirl: if (Find(EventType.Twirl) != null) { break; } instance = new Twirl(JToken.FromObject(action)); OnActionChanged?.Invoke(CacheValue.IsClockWise); break; case EventType.SetSpeed: var setSpeedData = (Data.SetSpeed)action; if (Find(EventType.SetSpeed) is SetSpeed setSpeed) { setSpeed.SetValue(setSpeedData.SpeedType, (setSpeedData.SpeedType == SpeedType.Bpm) ? setSpeedData.BeatsPerMinute : setSpeedData.BpmMultiplier); } else { instance = new SetSpeed(JToken.FromObject(setSpeedData)); } OnActionChanged?.Invoke(CacheValue.Bpm); break; case EventType.NotAvailable: goto default; default: break; } if (instance == null) { return; } instance.ActionChanged += Action_OnActionChanged; _actions.Add(instance); }
private void Action_OnActionChanged(CacheValue cacheValue) => OnActionChanged?.Invoke(cacheValue);