Exemplo n.º 1
0
        public ProjectileDecorator(IProjectileLogic p)
        {
            ProjectileLogic = p;
            ProtoProjectile tmp = (ProtoProjectile) ProjectileLogic.getUpperMost();

            Game = tmp.Game;
            Scene = tmp.Scene;
            Input = tmp.Input;
            Projectile = tmp.Projectile;
        }
Exemplo n.º 2
0
        internal void Update()
        {
            // Set instance pointer to this object.
            Instance = this;

            // Force update all joysticks.
            Joystick.Update();

            // Update the previous button dictionaries.
            previousKeys = new Dictionary<Key, bool>(currentKeys);
            previousMouseButtons = new Dictionary<MouseButton, bool>(currentMouseButtons);
            for (int i = 0; i < previousButtons.Count; i++) {
                previousButtons[i] = new Dictionary<uint, bool>(currentButtons[i]);
            }

            // Update the previous press counts
            prevKeysPressed = currentKeysPressed;
            prevMouseButtonsPressed = currentMouseButtonsPressed;
            for (int i = 0; i < prevButtonsPressed.Count; i++) {
                prevButtonsPressed[i] = buttonsPressed[i];
            }

            // Update the current to the active keys.
            currentKeys = new Dictionary<Key, bool>(activeKeys);
            currentMouseButtons = new Dictionary<MouseButton, bool>(activeMouseButtons);
            for (int i = 0; i < currentButtons.Count; i++) {
                currentButtons[i] = new Dictionary<uint, bool>(activeButtons[i]);
            }

            foreach (var k in keyReleaseBuffer) {
                activeKeys[k] = false;
            }

            currentKeysPressed = keysPressed;

            keyReleaseBuffer.Clear();

            foreach (var m in mouseReleaseBuffer) {
                activeMouseButtons[m] = false;
            }

            currentMouseButtonsPressed = mouseButtonsPressed;

            mouseReleaseBuffer.Clear();

            for (int i = 0; i < Joystick.Count; i++) {
                foreach (var b in buttonReleaseBuffer[i]) {
                    activeButtons[i][b] = false;
                }

                buttonReleaseBuffer[i].Clear();
            }

            // Update the Joystick axes to use as buttons
            for (int i = 0; i < Joystick.Count; i++) {
                if (Joystick.IsConnected((uint)i)) {
                    foreach (JoyAxis axis in Enum.GetValues(typeof(JoyAxis))) {
                        float a = GetAxis(axis, i) * 0.01f;
                        if (a >= axisThreshold[axis]) {
                            if (!currentButtons[i][(uint)axisSet[axis].Plus]) {
                                buttonsPressed[i]++;
                            }
                            currentButtons[i][(uint)axisSet[axis].Plus] = true;
                        }
                        else {
                            if (currentButtons[i][(uint)axisSet[axis].Plus]) {
                                buttonsPressed[i]--;
                            }
                            currentButtons[i][(uint)axisSet[axis].Plus] = false;
                        }

                        if (a <= -axisThreshold[axis]) {
                            if (!currentButtons[i][(uint)axisSet[axis].Minus]) {
                                buttonsPressed[i]++;
                            }
                            currentButtons[i][(uint)axisSet[axis].Minus] = true;
                        }
                        else {
                            if (currentButtons[i][(uint)axisSet[axis].Minus]) {
                                buttonsPressed[i]--;
                            }
                            currentButtons[i][(uint)axisSet[axis].Minus] = false;
                        }
                    }
                }
            }

            mouseWheelDelta = currentMouseWheelDelta;
            currentMouseWheelDelta = 0;
        }
Exemplo n.º 3
0
 internal Input(Game game)
 {
     Game = game;
     Instance = this;
     Init();
 }