Ejemplo n.º 1
0
        private void HandleCamera(InputHelper input, GameTime gameTime)
        {
            Vector2 camMove = Vector2.Zero;
            float MoveSpeed = 100f;

            if (input.KeyboardState.IsKeyDown(Keys.Up))
            {
                camMove.Y -= MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.KeyboardState.IsKeyDown(Keys.Down))
            {
                camMove.Y += MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.KeyboardState.IsKeyDown(Keys.Left))
            {
                camMove.X -= MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.KeyboardState.IsKeyDown(Keys.Right))
            {
                camMove.X += MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (camMove != Vector2.Zero)
            {
                Camera.MoveCamera(camMove);
            }
            if (input.KeyboardState.IsKeyDown(Keys.OemPlus))
            {
                Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
            }
            if (input.KeyboardState.IsKeyDown(Keys.OemMinus))
            {
                Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
            }
            if (input.IsNewKeyPress(Keys.Escape))
            {
                Camera.ResetCamera();
            }
        }
Ejemplo n.º 2
0
        public override void HandleInput(InputHelper input, Microsoft.Xna.Framework.GameTime gameTime)
        {
            supers.Clear();
            #if WINDOWS
            var surfacetouches = input.SurfaceTouches;
            if (surfacetouches.Count > 0)
            {
                //Surface
                for (int i = 0; i < surfacetouches.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(new Vector2(surfacetouches[i].X, surfacetouches[i].Y));

                    supers[i] = new Individual(i,((double)position.X),
                         ((double)position.Y),
                         0.0, 0.0, new Parameters());
                }
            }
            else
            #endif
            if (input.Touches.Count > 0)
            {
                //Everthing else touch
                for (int i = 0; i < input.Touches.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(new Vector2(input.Touches[i].Position.X, input.Touches[i].Position.Y));

                    supers[i] = new Individual(i, ((double)position.X),
                                              ((double)position.Y),
                                              0.0, 0.0, new SuperParameters());
                }
            }
            else if (supers.Count <= 0 &&
                    (input.Cursor != Vector2.Zero) &&
                    input.MouseState.LeftButton == ButtonState.Pressed)
            {
                //Mouse
                supers.Add(0, new Individual());
                for (int i = 0; i < supers.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(input.Cursor);

                    supers[i] = new Individual(i, ((double)position.X),
                         ((double)position.Y),
                         0, 0, new SuperParameters());
                }
            }

            if (input.IsNewKeyPress(Keys.A))
            {
                controlClient.ToggleAnalyze();
            }

            if (input.IsNewKeyPress(Keys.C))
            {
                debugComponent.SetVisiblity();
            }

            ButtonSection.HandleInput(input, gameTime);
            base.HandleInput(input, gameTime);
        }