public KinectGrabWheelController(WheelDelegate wheelDelegate, ScreenManager screenManager, KinectSensor kinect)
        {
            this.device = screenManager.GraphicsDevice;

            this.wheelDelegate = wheelDelegate;
            position = new Vector2();
            positionScreen = new Vector2();
            this.kinectSensor = kinect;

            //if (!kinect.IsRunning)
            //{
                var parameters = new TransformSmoothParameters
                {
                    Smoothing = 0.1f,
                    Correction = 0.0f,
                    Prediction = 0.0f,
                    JitterRadius = 1.0f,
                    MaxDeviationRadius = 0.5f
                };
                kinect.SkeletonStream.Enable(parameters);
                kinect.DepthStream.Enable();
                kinect.ColorStream.Enable();

                kinect.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(ks_AllFramesReady);

                interactionStream = new Microsoft.Kinect.Toolkit.Interaction.InteractionStream(kinect, new myIntClient());
                interactionStream.InteractionFrameReady += new EventHandler<InteractionFrameReadyEventArgs>(intStream_InteractionFrameReady);
                kinect.Start();
            //}
        }
Пример #2
0
        public FarseerPhysicsGame()
        {
            Window.Title = "Farseer Samples Framework";
            _graphics = new GraphicsDeviceManager(this);
            _graphics.PreferMultiSampling = true;
            #if WINDOWS || XBOX
            _graphics.PreferredBackBufferWidth = 1280;
            _graphics.PreferredBackBufferHeight = 720;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(24f);
            IsFixedTimeStep = true;
            #elif WINDOWS_PHONE
            _graphics.PreferredBackBufferWidth = 800;
            _graphics.PreferredBackBufferHeight = 480;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(16f);
            IsFixedTimeStep = false;
            #endif
            #if WINDOWS
            _graphics.IsFullScreen = false;
            #elif XBOX || WINDOWS_PHONE
            _graphics.IsFullScreen = true;
            #endif

            Content.RootDirectory = "Content";

            //new-up components and add to Game.Components
            ScreenManager = new ScreenManager(this);
            Components.Add(ScreenManager);

            FrameRateCounter frameRateCounter = new FrameRateCounter(ScreenManager);
            frameRateCounter.DrawOrder = 101;
            Components.Add(frameRateCounter);
        }
Пример #3
0
        private void CreateTowers(ScreenManager screenManager, float oneSixth)
        {
            Bases = new Dictionary<Side, Base>
                {
                    {
                        Side.Heart,
                        new Base(Side.Heart, -(screenManager.GraphicsDevice.Viewport.Width*2.5f + oneSixth), screenManager)
                    },
                    {
                        Side.Brain,
                        new Base(Side.Brain, screenManager.GraphicsDevice.Viewport.Width*2.5f + oneSixth, screenManager)
                    }
                };

            Towers = new List<Tower>
                {
                    new Tower(Side.Heart, -oneSixth, screenManager),
                    new Tower(Side.Brain, +oneSixth, screenManager),
                    new Tower(Side.Heart, -oneSixth*3, screenManager),
                    new Tower(Side.Brain, +oneSixth*3, screenManager),
                    new Tower(Side.Heart, -oneSixth*5, screenManager),
                    new Tower(Side.Brain, +oneSixth*5, screenManager),
                    new Tower(Side.Heart, -oneSixth*7, screenManager),
                    new Tower(Side.Brain, +oneSixth*7, screenManager),
                    new Tower(Side.Heart, -oneSixth*9, screenManager),
                    new Tower(Side.Brain, +oneSixth*9, screenManager),
                    new Tower(Side.Heart, -oneSixth*11, screenManager),
                    new Tower(Side.Brain, +oneSixth*11, screenManager),
                    new Tower(Side.Heart, -oneSixth*13, screenManager),
                    new Tower(Side.Brain, +oneSixth*13, screenManager),
                };
        }
Пример #4
0
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.PreferMultiSampling = true;
            #if WINDOWS || XBOX
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 480;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(1f);
            IsFixedTimeStep = true;
            #elif WINDOWS_PHONE
            _graphics.PreferredBackBufferWidth = 800;
            _graphics.PreferredBackBufferHeight = 480;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(16f);
            IsFixedTimeStep = false;
            #endif
            #if WINDOWS
            graphics.IsFullScreen = false;
            #elif XBOX || WINDOWS_PHONE
            _graphics.IsFullScreen = true;
            #endif
            ScreenManager = new ScreenManager(this);
            Components.Add(ScreenManager);

            FrameRateCounter frameRateCounter = new FrameRateCounter(ScreenManager);
            frameRateCounter.DrawOrder = 101;
            Components.Add(frameRateCounter);
        }
Пример #5
0
        /// <summary>
        ///   Constructs a new input state.
        /// </summary>
        public InputHelper(ScreenManager manager)
        {
            _currentKeyboardState = new KeyboardState();
            _currentGamePadState = new GamePadState();
            _currentMouseState = new MouseState();
            _currentVirtualState = new GamePadState();

            _lastKeyboardState = new KeyboardState();
            _lastGamePadState = new GamePadState();
            _lastMouseState = new MouseState();
            _lastVirtualState = new GamePadState();

            _manager = manager;

            _cursorIsVisible = false;
            _cursorMoved = false;
#if WINDOWS_PHONE
            _cursorIsValid = false;
#else
            _cursorIsValid = true;
#endif
            _cursor = Vector2.Zero;

            _handleVirtualStick = false;
        }
Пример #6
0
        public Coh()
        {
            Window.Title = "Change of Heart";
            _graphics = new GraphicsDeviceManager(this);
            _graphics.PreferMultiSampling = true;
            #if WINDOWS || XBOX
            _graphics.PreferredBackBufferWidth = 1024;
            _graphics.PreferredBackBufferHeight = 768;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(24f);
            IsFixedTimeStep = true;
            #elif WINDOWS_PHONE
            _graphics.PreferredBackBufferWidth = 500;
            _graphics.PreferredBackBufferHeight = 500;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(16f);
            IsFixedTimeStep = false;
            #endif
            #if WINDOWS
            _graphics.IsFullScreen = false;
            #elif XBOX || WINDOWS_PHONE
            _graphics.IsFullScreen = true;
            #endif

            Content.RootDirectory = "Content";

            //new-up components and add to Game.Components
            ScreenManager = new ScreenManager(this);
            Components.Add(ScreenManager);

            var frameRateCounter = new FrameRateCounter(ScreenManager)
                {
                    DrawOrder = 101
                };
            Components.Add(frameRateCounter);
        }
Пример #7
0
 public Tower(Side side, float xPosition, ScreenManager screenManager)
 {
     _screenManager = screenManager;
     Side = side;
     Health = MaxHealth;
     _font = screenManager.Content.Load<SpriteFont>("Fonts/font");
     Position = new Vector2(
         ConvertUnits.ToSimUnits(xPosition),
         ConvertUnits.ToSimUnits(screenManager.GraphicsDevice.Viewport.Height * 0.5f - Size * _sprite.Texture.Height * 0.5f)
         );
 }
Пример #8
0
        public Map(MainGame game, World world, ScreenManager screenManager)
        {
            _screenManager = screenManager;
            _floorSprite = new Sprite(screenManager.Content.Load<Texture2D>("bg/Environment_Floor_Tilable"));

            float oneSixth = screenManager.GraphicsDevice.Viewport.Width*0.175f;
            Size = new Vector2(ConvertUnits.ToSimUnits(screenManager.GraphicsDevice.Viewport.Width * 2.5f + oneSixth*2),
                            ConvertUnits.ToSimUnits(screenManager.GraphicsDevice.Viewport.Height));

            CreateTowers(screenManager, oneSixth);
            _gameBorder = new GameBorder(world, game, Size);
        }
 public FrameRateCounter(ScreenManager screenManager)
     : base(screenManager.Game)
 {
     _screenManager = screenManager;
     _format = new NumberFormatInfo();
     _format.NumberDecimalSeparator = ".";
     #if XBOX
     _position = new Vector2(55, 35);
     #else
     _position = new Vector2(30, 25);
     #endif
 }
Пример #10
0
        protected Actor(Side side, string character)
            : base(MainGame.World, Vector2.Zero)
        {
            _screenManager = MainGame.ScreenManager;
            Character = character;
            IsVisible = true;
            IsGrounded = false;
            Health = MaxHealth;

            Side = side;
            Action = "default";

            CreateCapsuleCollider(Width, Height, Density, null);
            BodyType = BodyType.Dynamic;
            FixedRotation = true;
            DetectWhenGrounded();
        }
Пример #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="position">Where it will be drawn</param>
        /// <param name="texture">Texture</param>
        /// <param name="world">World where it will appear</param>
        /// <param name="letter">Letter which will display</param>
        /// <param name="screenManager">Screen manager that will draw this object</param>
        public KeyboardLetter(Vector2 position, Texture2D texture, Texture2D fillTexture, World world, String letter, ScreenManager screenManager, SpriteFont letterFont, Color color)
        {
            this.Position = position;
            this.Texture = texture;
            this.Letter = letter;

            this.circleFillTexture = fillTexture;
            this.PercentageHovered = 0.0f;
            this.Radius = texture.Width/2;

            this.LetterSprite = new Sprite(texture);

            this.letterFont = letterFont;
            this.color = color;

            randomGenerator = new Random(DateTime.Now.Millisecond);
            this.isHovered = false;
        }
Пример #12
0
        public SubMenu(Dictionary<String, AbstractHoverButton.ButtonClickedHandler> buttonHandlers, ScreenManager screenManager, String name)
        {
            background = new Sprite(screenManager.Content.Load<Texture2D>("notebook"));
            Texture2D animationTexture = screenManager.Content.Load<Texture2D>("Common/AnimationStrip");
            SelectAnimation selectAnimation = new SelectAnimation(1500, new Vector2(), animationTexture, 0.3f);
            font = screenManager.Content.Load<SpriteFont>("Font");

            int i = 0;
            this.buttons = new List<AbstractHoverButton>();
            this.itemNames = new List<string>();
            foreach (var pair in buttonHandlers)
            {
                itemNames.Add(pair.Key);
                AbstractHoverButton button = new AbstractHoverButton(screenManager.Content.Load<Texture2D>("Common/stick"), itemsPosition + new Vector2(30, -50 + i* offsetBetweenItems), 0.5f, new SelectAnimation(1500, new Vector2(), animationTexture, 0.3f));
                button.buttonClicked += new AbstractHoverButton.ButtonClickedHandler(pair.Value);
                buttons.Add(button);
                i++;
            }
            this.name = name;
        }
Пример #13
0
        public Wheel(ScreenManager screenManager, MenuDelegate menuDelegate, World world, float radius, Vector2 centerPosition, String[] entryStrings, Sprite background)
        {
            this.menuDelegate = menuDelegate;
            this.radius = radius;
            this.entries = new Dictionary<int,String>(entryStrings.Length);
            for(int i=0;i<entryStrings.Length;i++){
                this.entries.Add(i, entryStrings[i]);
            }
            this.world = world;
            this.screenManager = screenManager;
            wheelBody = BodyFactory.CreateCircle(world, radius, 1f);
            wheelBody.BodyType = BodyType.Dynamic;
            wheelBody.Restitution = .7f;
            wheelBody.Friction = .2f;

            FixedRevoluteJoint rollingJoint = JointFactory.CreateFixedRevoluteJoint(world, wheelBody, Vector2.Zero, Vector2.Zero);
            wheelSprite = new Sprite(screenManager.Content.Load<Texture2D>("wheel-5"));

            jointTexture = screenManager.Content.Load<Texture2D>("joint");
            this.background = background;
            phone = new Sprite(screenManager.Content.Load<Texture2D>("phone"));
        }
Пример #14
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.PreferMultiSampling = true;

            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 480;
            ConvertUnits.SetDisplayUnitToSimUnitRatio(16f);
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);
#if WINDOWS
            graphics.IsFullScreen = false;
#elif XBOX || WINDOWS_PHONE
            graphics.IsFullScreen = true;
#endif
            
            screenManager = new ScreenManager(this);
            this.Components.Add(screenManager);
            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);
        }
Пример #15
0
 public void Draw(ScreenManager screenManager)
 {
     foreach (KeyboardLetter keyboardLetter in letters)
     {
         keyboardLetter.Draw(screenManager);
     }
 }
Пример #16
0
 public Base(Side side, float xLocation, ScreenManager screenManager)
     : base(side, xLocation, screenManager)
 {
 }
Пример #17
0
 public void LoadContent(ScreenManager screenmanager)
 {
     Texture = screenmanager.Content.Load<Texture2D>("Common/bullet");
 }
Пример #18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="position">Position of first letter of the keyboard</param>
        /// <param name="world">World where keyboard will be</param>
        /// <param name="screenManager">Screen manager which will draw letters</param>
        public KeyboardBody(Vector2 position, World world, ScreenManager screenManager, SpriteFont scoreFont)
        {
            this.scoreFont = scoreFont;
            letters = new List<KeyboardLetter>();
            letterTexture = screenManager.Content.Load<Texture2D>("letter");
            letterFillTexture = screenManager.Content.Load<Texture2D>("circle_fill");

            xSpace = (float)(letterTexture.Width * 1.5);
            ySpace = (float)(letterTexture.Height * 1.5);

            float tempX = position.X;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "<-", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "OK", screenManager, scoreFont, Color.Yellow));

            position.Y += ySpace;
            position.X = tempX;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "Q", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "W", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "E", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "R", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "T", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "Y", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "U", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "I", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "O", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "P", screenManager, scoreFont, Color.Yellow));

            position.X = tempX;
            position.Y += ySpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "A", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "S", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "D", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "F", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "G", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "H", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "J", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "K", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "L", screenManager, scoreFont, Color.Yellow));

            position.X = tempX;
            position.Y += ySpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "Z", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "X", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "C", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "V", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "B", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "N", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, "M", screenManager, scoreFont, Color.Yellow));
            position.X += xSpace;
            letters.Add(new KeyboardLetter(position, letterTexture, letterFillTexture, world, " ", screenManager, scoreFont, Color.Yellow));

            foreach (KeyboardLetter letter in letters)
            {
                letter.ActivationChanged += new EventHandler(letter_ActivationChanged);
            }
        }
Пример #19
0
        public void Draw(ScreenManager screenManager)
        {
            Vector2 positionToDraw = new Vector2(Position.X + randomGenerator.Next(-1, 1), Position.Y + randomGenerator.Next(-1, 1));

            screenManager.SpriteBatch.Draw(Texture, ConvertUnits.ToDisplayUnits(positionToDraw),
                null,
                Color.White, 0, ConvertUnits.ToDisplayUnits(LetterSprite.Origin), 1f,
                SpriteEffects.None, 0f);

            if (isHovered)
            {
                screenManager.SpriteBatch.Draw(circleFillTexture, ConvertUnits.ToDisplayUnits(positionToDraw),
                    null,
                    Color.White, 0, ConvertUnits.ToDisplayUnits(LetterSprite.Origin), PercentageHovered,
                    SpriteEffects.None, 0f);
            }

            screenManager.SpriteBatch.DrawString(letterFont, Letter, new Vector2(positionToDraw.X - letterFont.MeasureString(Letter).X/2, positionToDraw.Y - letterFont.MeasureString(Letter).Y/2), color);
        }