Ejemplo n.º 1
0
    // 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;
    }
Ejemplo n.º 2
0
    protected override void Awake()
    {
        base.Awake();
        NewInput      = DirectionalAnalogEvent.Empty();
        PreviousInput = DirectionalAnalogEvent.Empty();

        cmdIntrp = GetComponent <CommandInterpreter> ();
    }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
            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);
                }
            }
Ejemplo n.º 5
0
            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);
            }
Ejemplo n.º 6
0
 public static bool CloseEnough(DirectionalAnalogEvent in1, DirectionalAnalogEvent in2, float delta)
 {
     return(Vector2.Distance(in1.Velocity, in2.Velocity) < delta &&
            in1.Region == in2.Region);
 }
Ejemplo n.º 7
0
 //Receives new input up for the manager
 void OnInputUp()
 {
     NewInput = DirectionalAnalogEvent.Empty();
 }
Ejemplo n.º 8
0
 //Receives new input down for the manager
 void OnInputDown(DirectionalAnalogEvent input)
 {
     NewInput = input;
 }