Exemplo n.º 1
0
        //returns true if input was successfully recorded
        public bool StoreInput(SpaxInput input, bool inStop = false)
        {
            SpaxInput curInput = prevInputs[arrayPos];
            bool      ret      = false;

            if (!curInput.IsEqual(input))
            {
                changedPressed.buttons   = (curInput.buttons ^ input.buttons) & input.buttons;
                changedPressed.direction = (curInput.direction ^ input.direction) & input.direction;


                changedReleased.buttons   = (curInput.buttons ^ input.buttons) & curInput.buttons;
                changedReleased.direction = (curInput.direction ^ input.direction) & curInput.direction;


                //Debug.Log(input.direction + " " + input.buttons);
                arrayPos             = this.IncrementByPos(arrayPos, false);
                prevInputs[arrayPos] = input;
                this.SetInputCode();
                ret = true;
            }

            if (!inStop && prevInputsCode[codeArrayPos].framesHeld < 128)
            {
                prevInputsCode[codeArrayPos].framesHeld++;
            }
            return(ret);
        }
Exemplo n.º 2
0
        public void DisplayStick(SpaxInput input)
        {
            Vector3 pos = new Vector3(0f, 0f, 0f);;

            if ((input.direction & (Direction)56) > 0)
            {
                pos.y = 1f;
            }

            else if ((input.direction & (Direction)448) > 0)
            {
                pos.y = -1f;
            }

            if ((input.direction & (Direction)146) > 0)
            {
                pos.x = 1f;
            }

            else if ((input.direction & (Direction)292) > 0)
            {
                pos.x = -1f;
            }
            stick.transform.localPosition = pos;
        }
Exemplo n.º 3
0
        private void SetInputCode()
        {
            SpaxInput curInput = prevInputs[arrayPos];

            //records released inputs
            int change = 0;

            if (changedReleased.direction > Direction.N || changedReleased.buttons != 0)
            {
                change = (((int)changedReleased.direction & 510) << 2) | ((int)changedReleased.buttons << 11);

                //Debug.Log("release :: " + (InputCodeFlags)change);


                int checkPrev = ((int)prevInputsCode[codeArrayPos].inputCode >> 3);
                int checkCode = change >> 3;

                if (checkPrev == checkCode)
                {
                    change |= 1;
                }

                change |= 2;


                codeArrayPos = this.IncrementByPos(codeArrayPos, true);
                prevInputsCode[codeArrayPos].inputCode  = change;
                prevInputsCode[codeArrayPos].framesHeld = 0;
            }

            //records pressed inputs
            change = 0;

            if (changedPressed.direction > Direction.N || changedPressed.buttons != 0)
            {
                change = (((int)changedPressed.direction & 510) << 2) | ((int)changedPressed.buttons << 11);

                //Debug.Log("press :: " + (InputCodeFlags)change);

                int checkPrev = ((int)prevInputsCode[codeArrayPos].inputCode >> 3);
                int checkCode = change >> 3;

                if ((checkPrev ^ checkCode) == 0)
                {
                    change |= 1;
                }

                change |= 4;


                codeArrayPos = this.IncrementByPos(codeArrayPos, true);
                prevInputsCode[codeArrayPos].inputCode  = change;
                prevInputsCode[codeArrayPos].framesHeld = 0;
            }
        }
Exemplo n.º 4
0
 public void DisplayButtons(SpaxInput input)
 {
     for (int i = 0; i < 8; i++)
     {
         if ((input.buttons & (Button)(1 << i)) > 0)
         {
             buttons[i].color = Color.white;
         }
         else
         {
             buttons[i].color = Color.black;
         }
     }
 }
Exemplo n.º 5
0
        // Update is called once per frame
        void FixedUpdate()
        {
            if (Keyboard.current[Key.LeftShift].wasPressedThisFrame)
            {
                isFacingRight = !isFacingRight;
            }
            syncInput = asyncInput;

            bool newInput = inputRecorder.RecordInput(syncInput);

            if (newInput)
            {
                SearchForCommand();
            }

            proxy.DisplayInput(syncInput);
        }
Exemplo n.º 6
0
 public bool RecordInput(SpaxInput input, bool inStop = false)
 {
     return(prevInput.StoreInput(input, inStop));
 }
Exemplo n.º 7
0
 public bool IsEqual(SpaxInput other)
 {
     return((this.direction == other.direction) && (this.buttons == other.buttons));
 }
Exemplo n.º 8
0
 public void DisplayInput(SpaxInput input)
 {
     DisplayStick(input);
     DisplayButtons(input);
 }