Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            if (TouchPanel.GetCapabilities().IsConnected)
            {
                TouchCollection touchCol = TouchPanel.GetState();
                foreach (TouchLocation touch in touchCol)
                {
                    if (touch.State != TouchLocationState.Moved)
                    {
                    }
                }
            }
            else
            {
                MouseState ms = Mouse.GetState();
                mc.position = new Vector2(ms.Position.X, ms.Position.Y);
            }

            // TODO: Add your update logic here
            //Generating Enemies
            foreach (EnemyGenerator eg in EnemyGenList)
            {
                eg.Generate(gameTime, EnemyList);
            }
            foreach (Enemy e in EnemyList)
            {
                e.Move(gameTime);
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
0
 public static void Initialize()
 {
     TouchPanel.EnabledGestures = GestureType.None;
     TouchPanel.DisplayHeight   = RPGGame.GetClientBounds().Height;
     TouchPanel.DisplayWidth    = RPGGame.GetClientBounds().Width;
     _useMouse = !TouchPanel.GetCapabilities().IsConnected;
 }
Exemplo n.º 3
0
        public void Initialize()
        {
            ReadsInput = true;

            LastFrameGestures = new List <GestureSample>();
#if USE_TOUCH
            ReadsGestures = true;
            TouchPanel.EnabledGestures =
                GestureType.Tap |
                GestureType.DoubleTap |
                GestureType.Hold |
                GestureType.Pinch |
                GestureType.PinchComplete |
                GestureType.DragComplete |
                GestureType.FreeDrag |
                GestureType.HorizontalDrag |
                GestureType.VerticalDrag |
                GestureType.Flick;

            TouchPanelCapabilities touchPanelCapabilities = TouchPanel.GetCapabilities();
            MaximumTouchCount = touchPanelCapabilities.MaximumTouchCount;
#else
            MaximumTouchCount = 2;
#endif
            NumberTouchPointsNeededForPush = 1;
        }
        public GameplayScreen(ScreenManager manager, int id, bool touchState, Flyinghead head, BouncingText text)
        {
            //Allgemeine Initialisierungen
            screenManager = manager;
            screenManager.endBossActive = false;
            collision = new Collision();

            m_levelId   = id;
            m_gameSpeed = 10;

            bouncingText = text;
            flyinghead   = head;

            //Spielelemente
            startWeapon = new Weapon();
            player      = new Player();
            playerInput = new Input();

            levelEins            = new Level();
            m_enemyAnimationList = new List <Animation>();

            //Level
            m_Background1 = new Background();
            m_Background2 = new Background();
            m_Background3 = new Background();
            m_Background4 = new Background();
            m_Background5 = new Background();


            //Input
            listOfRectangles     = new List <Rectangle>();
            r_backwards          = new Rectangle(0, 1080 - 160, 80, 160);
            r_forward            = new Rectangle(90, 1080 - 160, 80, 160);
            r_shoot              = new Rectangle(1600, 700, 320, 380);
            listOfTouchLocations = new List <TouchLocation>();
            tc           = TouchPanel.GetCapabilities();
            b_touchState = touchState;
            helper       = new Helper(screenManager);

            if (b_touchState == true)
            {
                m_buttons = new ButtonsDraw();
            }

            m_textures = new Texture2D[5];

            manager.audioFileSystem.menuTheme.Stop();
            audioFileSystem = screenManager.audioFileSystem;
            imageFileSystem = screenManager.imageFileSystem;


            deathApplied = false;
            screenManager.audioFileSystem.s_levelOneTheme.IsLooped = true;
            victoryApplied   = false;
            bossThemeStarted = false;

            //Zählt runter bei null = Tod
            m_countdown = 300;
        }
Exemplo n.º 5
0
 public Dinosaur(int maxWidth, int maxHeight, ContentManager content)
 {
     touchPanelCapabilities = TouchPanel.GetCapabilities();
     touchPosition          = new Vector2();
     DinosaurTex            = content.Load <Texture2D>("Textures/dinosaur");
     this.maxWidth          = maxWidth;
     this.maxHeight         = maxHeight;
     this.Position          = new Vector2(maxWidth / 2, maxHeight / 2);
 }
Exemplo n.º 6
0
        static Input()
        {
            TouchPanelCapabilities capabilities = TouchPanel.GetCapabilities();

            TouchPanel.EnabledGestures = GestureType.Flick | GestureType.HorizontalDrag;


            IsConnected       = capabilities.IsConnected;
            MaximumTouchCount = capabilities.MaximumTouchCount;
        }
Exemplo n.º 7
0
        public TouchInputManager(Game game)
            : base(game)
        {
            Instance = this;

            UpdateOrder = -50000;
            DrawOrder   = 50000;

            IsTouch = TouchPanel.GetCapabilities().IsConnected;
        }
Exemplo n.º 8
0
        public void EnableTouchSupport()
        {
            _isConnected = TouchPanel.GetCapabilities().IsConnected;

            if (_isConnected)
            {
                Core.Emitter.AddObserver(CoreEvents.GraphicsDeviceReset, OnGraphicsDeviceReset);
                Core.Emitter.AddObserver(CoreEvents.OrientationChanged, OnGraphicsDeviceReset);
                OnGraphicsDeviceReset();
            }
        }
Exemplo n.º 9
0
        public InputCapabilities GetInputCapabilities(bool forceRefresh = false)
        {
            if (forceRefresh)
            {
                RunningOnPhone();
                RunningOnDesktop();
                inputCaps.IsTouchEnabled = TouchPanel.GetCapabilities().IsConnected;
            }

            return(inputCaps);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Updates the internal state dependent on user interaction.
 /// </summary>
 public void Update()
 {
     if (TouchPanel.GetCapabilities().IsConnected)
     {
         UpdateFromTouchPanel();
     }
     else
     {
         UpdateFromMouse();
     }
 }
Exemplo n.º 11
0
 public MonoGameInputMake(LGame game)
 {
     this._game = game;
     this._currentMouseState  = _previousMouseState = Mouse.GetState();
     this._currentPressedKeys = _previousPressedKeys = new Keys[0];
     this._isConnected        = TouchPanel.GetCapabilities().IsConnected;
     if (game.setting.emulateTouch && !_isConnected)
     {
         EmulateTouch();
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// constructor
        /// </summary>
        public TouchManager(ConvertToGameCoord gameCoord, GestureType supportedGestures = GestureType.Tap) : base(gameCoord)
        {
            TouchStartPosition = new TouchLocation[_numTouches];

            //Check if we even have a touchscreen available
            TouchPanelCapabilities touch = TouchPanel.GetCapabilities();

            IsEnabled = touch.IsConnected;

            //enable the tap gesture if available
            SupportedGestures = supportedGestures;
        }
Exemplo n.º 13
0
        public Pax4Touch(String p_name, PaxState p_parent0)
            : base(p_name, p_parent0)
        {
#if !WINDOWS_MOUSE
            _touchPanelCapabilities = TouchPanel.GetCapabilities();
#endif
            Reset();

            _flickVelocityThreshold *= Pax4Camera._current._scale2.X;

            _current = this;
        }
        // Token: 0x06002332 RID: 9010 RVA: 0x0014835E File Offset: 0x0014655E
        public bool create()
        {
            if (!TouchPanel.GetCapabilities().IsConnected)
            {
                // no touchy
                return(false);
            }

            this.Release();
            this.m_flag[0] = true;
            return(true);
        }
Exemplo n.º 15
0
        internal void setup()
        {
            touchInterval = Game1.config.touchInterval;

#if WINDOWS_PHONE
            touchPanelCapabilities = TouchPanel.GetCapabilities();
            if (touchPanelCapabilities.IsConnected)
            {
                maximumTouchCount = touchPanelCapabilities.MaximumTouchCount;
            }
#endif
        }
Exemplo n.º 16
0
        public int getTouchPoints()
        {
            TouchPanelCapabilities tc = TouchPanel.GetCapabilities();

            if (tc.IsConnected)
            {
                return(tc.MaximumTouchCount);
            }
            else
            {
                return(-1);
            }
        }
Exemplo n.º 17
0
        public void enableTouchSupport()
        {
#if !FNA
            _isConnected = TouchPanel.GetCapabilities().IsConnected;
#endif

            if (_isConnected)
            {
                Core.emitter.addObserver(CoreEvents.GraphicsDeviceReset, onGraphicsDeviceReset);
                Core.emitter.addObserver(CoreEvents.OrientationChanged, onGraphicsDeviceReset);
                onGraphicsDeviceReset();
            }
        }
Exemplo n.º 18
0
        public override void Update(GameTime gameTime)
        {
            previousKeyboardState = currentKeyboardState;
            previousGamepadState  = currentGamepadState;

            if (TouchPanel.GetCapabilities().IsConnected)
            {
                currentTouchCollection = TouchPanel.GetState();
            }
            currentKeyboardState = Keyboard.GetState();
            currentGamepadState  = GamePad.GetState(PlayerIndex.One);

            base.Update(gameTime);
        }
Exemplo n.º 19
0
        public PointerInputHandler(MessageManager messageManager, SceneGraph sceneGraph)
        {
            _sceneGraph     = sceneGraph;
            _messageManager = messageManager;

            _oldMouseState = Mouse.GetState();

            var touchCapabilities = TouchPanel.GetCapabilities();

            if (touchCapabilities.IsConnected)
            {
                _touchSupported = true;
                _oldTouchState  = TouchPanel.GetState();
            }
        }
Exemplo n.º 20
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen              = true;
            graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            graphics.ApplyChanges();

            if (TouchPanel.GetCapabilities().IsConnected)
            {
                Console.WriteLine("**********TOUCH INPUT CONNECTED**********");
                inputManager = new InputManager(this);
            }

            Content.RootDirectory = "Content";
        }
Exemplo n.º 21
0
 public static bool IsScreenTouched()
 {
     if (TouchPanel.GetCapabilities().IsConnected)
     {
         bool pressed = false;
         foreach (TouchLocation touchLocation in currentTouchCollection)
         {
             if (touchLocation.State == TouchLocationState.Pressed)
             {
                 pressed = true;
                 break;
             }
         }
         return(pressed);
     }
     return(false);
 }
Exemplo n.º 22
0
        private bool GetTouchState()
        {
            TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();

            if (touchCap.IsConnected)
            {
                TouchCollection touches = TouchPanel.GetState();

                if (touches.Count > 0)
                {
                    return(touches [0].State == TouchLocationState.Pressed);
                }

                return(false);
            }

            return(false);
        }
Exemplo n.º 23
0
        private bool TouchInRectangle(Rectangle rectangle)
        {
            TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();

            if (touchCap.IsConnected)
            {
                TouchCollection touches  = TouchPanel.GetState();
                Vector2         position = Vector2.Zero;

                if (touches.Count > 0)
                {
                    position = touches[0].Position;
                }

                return(position.X >= rectangle.X && position.X <= rectangle.X + rectangle.Width && position.Y >= rectangle.Y && position.Y <= rectangle.Y + rectangle.Height);
            }
            return(false);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Call this at the beginning of your update loop.
        /// </summary>
        public static void UpdateSetup()
        {
            _oldMouse    = _newMouse;
            _oldKeyboard = _newKeyboard;
            _newGamepad.CopyTo(_oldGamePad, 0);

            _newMouse    = Mouse.GetState();
            _newKeyboard = Keyboard.GetState();

            for (int i = 0; i < GamePad.MaximumGamePadCount; i++)
            {
                _newGamepad[i]          = GamePad.GetState(i, GamePadDeadZone[i]);
                _gamePadCapabilities[i] = GamePad.GetCapabilities(i);
            }

            _newTouchCollection     = TouchPanel.GetState();
            _touchPanelCapabilities = TouchPanel.GetCapabilities();
        }
Exemplo n.º 25
0
        public YnTouch(Game game)
            : base(game)
        {
            touchCollection     = TouchPanel.GetState();
            lastTouchCollection = touchCollection;
#if MONOGAME && (WINDOWS || LINUX)
            _maxFingerPoints = 0;
#else
            if (TouchPanel.GetCapabilities().IsConnected)
            {
                _maxFingerPoints = TouchPanel.GetCapabilities().MaximumTouchCount;
            }
            else
            {
                _maxFingerPoints = 0;
            }
#endif
            _needUpdate = true;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Call Setup in the game's LoadContent.
        /// </summary>
        /// <param name="game">Your game object.</param>
        public static void Setup(Game game)
        {
            Game = game;

            _newMouse               = Mouse.GetState();
            _newKeyboard            = Keyboard.GetState();
            _touchPanelCapabilities = TouchPanel.GetCapabilities();

            for (int i = 0; i < GamePad.MaximumGamePadCount; i++)
            {
                _gamePadDeadZone[i]     = Microsoft.Xna.Framework.Input.GamePadDeadZone.None;
                _newGamepad[i]          = GamePad.GetState(i, _gamePadDeadZone[i]);
                _gamePadCapabilities[i] = GamePad.GetCapabilities(i);
            }

            _newTouchCollection = TouchPanel.GetState();

            Window.TextInput += ProcessTextInput;
        }
Exemplo n.º 27
0
        // Group: Public Functions

        /// <summary>
        /// Call Setup in the game's LoadContent.
        /// </summary>
        /// <param name="game">Your game object.</param>
        public static void Setup(Game game)
        {
            Game = game;

            _newMouse               = Mouse.GetState();
            _newKeyboard            = Keyboard.GetState();
            _touchPanelCapabilities = TouchPanel.GetCapabilities();

            for (int i = 0; i < GamePad.MaximumGamePadCount; i++)
            {
                _gamePadDeadZone[i]     = Microsoft.Xna.Framework.Input.GamePadDeadZone.None;
                _newGamepad[i]          = GamePad.GetState(i, _gamePadDeadZone[i]);
                _gamePadCapabilities[i] = GamePad.GetCapabilities(i);
            }

            _newTouchCollection = TouchPanel.GetState();

            //This is boring but whatever, it only gets called once.
            //MonoGame doesn't offer TextInput under some platforms.
            EventInfo eInfo = Window.GetType().GetEvent("TextInput");

            if (eInfo != null)
            {
                Type            handlerType  = eInfo.EventHandlerType;
                MethodInfo      invokeMethod = handlerType.GetMethod("Invoke");
                ParameterInfo[] parms        = invokeMethod.GetParameters();
                Type[]          parmTypes    = new Type[parms.Length];
                for (int i = 0; i < parms.Length; i++)
                {
                    parmTypes[i] = parms[i].ParameterType;
                }

                Type processorType        = typeof(InputProcessor <>);
                Type genericProcessorType = processorType.MakeGenericType(parmTypes[1]);

                object inputProcessor = genericProcessorType.GetConstructor(Type.EmptyTypes).Invoke(null);

                MethodInfo eventHandler = inputProcessor.GetType().GetMethod("processTextInput");
                Delegate   d            = Delegate.CreateDelegate(handlerType, eventHandler);
                eInfo.AddEventHandler(Window, d);
            }
        }
Exemplo n.º 28
0
        public void SetMaxFingerPoints(int fingerCount)
        {
            if (fingerCount < 0)
            {
                _maxFingerPoints = 0;
            }
            else
            {
                if (fingerCount > TouchPanel.GetCapabilities().MaximumTouchCount)
                {
                    _maxFingerPoints = TouchPanel.GetCapabilities().MaximumTouchCount;
                }
                else
                {
                    _maxFingerPoints = fingerCount;
                }
            }

            _needUpdate = true;
        }
Exemplo n.º 29
0
        public TouchComponent(Game game)
            : base(game)
        {
            _touchState     = TouchPanel.GetState();
            _lastTouchState = _touchState;

            if (TouchPanel.GetCapabilities().IsConnected)
            {
                _maxFingerPoints = TouchPanel.GetCapabilities().MaximumTouchCount;
            }
            else
            {
                _maxFingerPoints = 0;
            }

            Sensitivity = Vector2.One;
            MaxDelta    = 100;
            DeadZone    = 1;
            _needUpdate = false;
            _needReset  = false;
        }
Exemplo n.º 30
0
        protected override void DoAction(Entity entity, TimeSpan gameTime)
        {
            base.DoAction(entity, gameTime);

            var touch = entity.GetComponent <InputTouchComponent>();

            touch.IsConnected = TouchPanel.GetCapabilities().IsConnected;

            touch.ResolutionScale  = this.ResolutionScale;
            touch.ResolutionOffset = this.ResolutionOffset;

            touch.PreviousTouches = touch.CurrentTouches;
            touch.CurrentTouches  = TouchPanel.GetState();

            touch.PreviousGestures = touch.CurrentGestures;
            touch.CurrentGestures.Clear();
            while (TouchPanel.IsGestureAvailable)
            {
                touch.CurrentGestures.Add(TouchPanel.ReadGesture());
            }
        }