using UnityEngine; using System.Collections; public class IgnitionSwitchController : IIgnitionStateController { private int _holdId; public void SetButtonState (IgnitionSystem sys, int button, bool press){ int nextId = 0; if ((_holdId >= 0 && _holdId != button)) { return; } _holdId = press ? button : -1; bool next = button == 0; bool release = !press; switch (sys.State) { case IgnitionState.Lock: if(press && next){ sys.State = IgnitionState.Acc; } break; case IgnitionState.Acc: if(press){ if(next){ sys.State = IgnitionState.On; }else{ sys.State = IgnitionState.Lock; } } break; case IgnitionState.On: if(press){ if(next){ sys.State = IgnitionState.Start; }else{ sys.State = IgnitionState.Acc; } } break; case IgnitionState.Start: if(release){ if(next){ sys.State = IgnitionState.On; } } break; } } public void Update (IgnitionSystem sys){ } }