Cascade.Controls.update C# (CSharp) Метод

update() публичный Метод

public update ( ) : void
Результат void
        public void update()
        {
            //get state gamepad/mouse
            leftstick = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left; 
            rightstick = GamePad.GetState(PlayerIndex.One).ThumbSticks.Right;
            mouseLB3 = 0;
            mouseLB2 = mouseLB;
            mouseRB3 = 0;
            mouseRB2 = mouseRB;
            //Console.WriteLine(getButton(Buttons.DPadRight));
            mouse = Mouse.GetState();
            mousePosPrev = mousePos;
            mousePos.X = mouse.X;
            mousePos.Y = mouse.Y;
            mousePos *= mouseMul / ScreenSize;
            if (mouse.LeftButton == ButtonState.Pressed)
            mouseLB = 1 ;
                else
            mouseLB = 0;
            if (mouse.RightButton == ButtonState.Pressed)
                mouseRB = 1;
            else
                mouseRB = 0;
            if (mouse.MiddleButton == ButtonState.Pressed)
                mouseCB = 1;
            else mouseCB = 0;

            vibration = 0;

            //vibration
            for (int i = 0; i < vibrationArray.Length; i++)
            {
                vibration += vibrationArray[i];
                vibrationArray[i] += (0-vibrationArray[i]) * vibrationSpeedArray[i];
                //if (vibrationArray[i] < 0)
                {
                   // vibrationArray[i] = 0;
                    //vibrationSpeedArray[i] = 0;
                }
            }
            //vibration *= vibrationArray.Length;
            if (vibration > 1)
                vibration = 1;
            if (vibration < 0)
                vibration = 0;
            //Console.WriteLine(vibration);
            GamePad.SetVibration(PlayerIndex.One, vibration, vibration);
            if (mouseLB == 1 && mouseLB2 == 1)
                mouseLB3 = 1;
            if (mouseLB == 1 && mouseLB2 == 0)
                mouseLB3 = 3;
            if (mouseLB == 0 && mouseLB2 == 1)
                mouseLB3 = 2;
            if (mouseLB == 0 && mouseLB2 == 0)
                mouseLB3 = 0;

            if (mouseRB == 1 && mouseRB2 == 1)
                mouseRB3 = 1;
            if (mouseRB == 1 && mouseRB2 == 0)
                mouseRB3 = 3;
            if (mouseRB == 0 && mouseRB2 == 1)
                mouseRB3 = 2;
            if (mouseRB == 0 && mouseRB2 == 0)
                mouseRB3 = 0;

            if (mouseCB == 1 && mouseCB2 == 1)
                mouseCB3 = 1;
            if (mouseCB == 1 && mouseCB2 == 0)
                mouseCB3 = 3;
            if (mouseCB == 0 && mouseCB2 == 1)
                mouseCB3 = 2;
            if (mouseCB == 0 && mouseCB2 == 0)
                mouseCB3 = 0;
            
            //get key states
            for (int i = 0; i < keyArray.Length; i += 1)
            {
                stateArray3[i] = 0;
                stateArray2[i] = stateArray[i];
                if (Keyboard.GetState().IsKeyDown(keyArray[i]))
                {
                    stateArray[i] = 1;
                }
                if (Keyboard.GetState().IsKeyUp(keyArray[i]))
                {
                    stateArray[i] = 0;
                }
                if (stateArray[i] == 1 && stateArray2[i] == 0)
                {
                    controlMode = 0;
                    stateArray3[i] = 3;
                }
                if (stateArray[i] == 0 && stateArray2[i] == 1)
                {
                    stateArray3[i] = 2;
                    stateArray5[i] = 0;
                }
                if (stateArray[i] == 0 && stateArray2[i] == 0)
                {
                    stateArray3[i] = 0;
                    stateArray4[i] = 0;
                    stateArray5[i]++;
                }
                if (stateArray[i] == 1 && stateArray2[i] == 1)
                {
                    stateArray3[i] = 1;
                    stateArray4[i] += 1;
                    stateArray5[i] = 0;
                }
            }

            //get button states
            for (int i = 0; i < buttonArray.Length; i += 1)
            {
                buttonStateArray3[i] = 0;
                buttonStateArray2[i] = buttonStateArray[i];
                if (GamePad.GetState(PlayerIndex.One).IsButtonDown(buttonArray[i]))
                {
                    buttonStateArray[i] = 1;
                }
                if (GamePad.GetState(PlayerIndex.One).IsButtonUp(buttonArray[i]))
                {
                    buttonStateArray[i] = 0;
                }
                if (buttonStateArray[i] == 1 && buttonStateArray2[i] == 0)
                {
                    controlMode = 1;
                    //buttonStateArray5[i] = 0;
                    buttonStateArray3[i] = 3;
                }
                if (buttonStateArray[i] == 0 && buttonStateArray2[i] == 1)
                {
                    buttonStateArray5[i] = 0;
                    buttonStateArray3[i] = 2;
                }
                if (buttonStateArray[i] == 0 && buttonStateArray2[i] == 0)
                {
                    buttonStateArray3[i] = 0;
                    buttonStateArray4[i] = 0;
                    buttonStateArray5[i]++;
                }
                if (buttonStateArray[i] == 1 && buttonStateArray2[i] == 1)
                {
                    buttonStateArray3[i] = 1;
                    buttonStateArray4[i] += 1;
                    buttonStateArray5[i] = 0;
                }
            }

            
        }