// Update is called once per frame void Update() { DirectionalAnalogEvent newInput = NewInput; if (!newInput.IsEmpty) { if (PreviousInput.IsEmpty || (newInput.Velocity - PreviousInput.Velocity).sqrMagnitude >= commandAccelerationSquared) { cmdIntrp.AddToInterpreter(newInput); //print (newInput.Region); } else { Move(newInput.Velocity); } } else { if (!PreviousInput.IsEmpty) { print(cmdIntrp.Interpret()); cmdIntrp.Flush(); BeginRecenter(); } } PreviousInput = newInput; }
protected override void Awake() { base.Awake(); NewInput = DirectionalAnalogEvent.Empty(); PreviousInput = DirectionalAnalogEvent.Empty(); cmdIntrp = GetComponent <CommandInterpreter> (); }
public void Flush() { commandString = new char[] { 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n' }; commandSize = 0; commandDirection = 0; lastDirectionalRegion = CommandRegion.None; LastInput = DirectionalAnalogEvent.Empty(); }
public void AddToInterpreter(DirectionalAnalogEvent newInput) { DirectionalAnalogEvent lastInput = LastInput; if (newInput.Region == CommandRegion.None) { Flush(); } else if (newInput.Region != lastInput.Region) { //print (newInput.Region); LastInput = newInput; InterpretStep(newInput.Region); } }
void Awake() { lastInput = DirectionalAnalogEvent.Empty(); interpretDict.Add(TapKey, ActionTypes.Tap); interpretDict.Add(CounterKey, ActionTypes.Counter); interpretDict.Add(JabKey, ActionTypes.Jab); interpretDict.Add(PullKey, ActionTypes.Pull); interpretDict.Add(SwipeKey, ActionTypes.Swipe); interpretDict.Add(QuarterSweepKey, ActionTypes.QuarterSweep); interpretDict.Add(HalfSweepKey, ActionTypes.HalfSweep); interpretDict.Add(FullSweepKey, ActionTypes.FullSweep); interpretDict.Add(QuarterAngleKey, ActionTypes.QuarterAngle); interpretDict.Add(HalfAngleKey, ActionTypes.HalfAngle); interpretDict.Add(FullAngleKey, ActionTypes.FullAngle); interpretDict.Add(QuarterLoopKey, ActionTypes.QuarterLoop); interpretDict.Add(HalfLoopKey, ActionTypes.HalfLoop); interpretDict.Add(FullLoopKey, ActionTypes.FullLoop); interpretDict.Add(FigureLKey, ActionTypes.FigureL); interpretDict.Add(FigureZKey, ActionTypes.FigureZ); }
public static bool CloseEnough(DirectionalAnalogEvent in1, DirectionalAnalogEvent in2, float delta) { return(Vector2.Distance(in1.Velocity, in2.Velocity) < delta && in1.Region == in2.Region); }
//Receives new input up for the manager void OnInputUp() { NewInput = DirectionalAnalogEvent.Empty(); }
//Receives new input down for the manager void OnInputDown(DirectionalAnalogEvent input) { NewInput = input; }