/// <summary>
 /// This isn't really the singleton pattern, but eh.
 /// </summary>
 /// <param name="game"></param>
 /// <returns></returns>
 public static GameStateManager Instance(Project2Game game)
 {
     if (instance == null) {
         return new GameStateManager(game);
     }
     return instance;
 }
        /// <summary>
        /// Initialise the input system. Note that accelerometer input defaults to off.
        /// </summary>
        /// <param name="game"></param>
        public InputManager(Project2Game game) : base(game)
        {

            // initialisation
            useMouseDelta = false;
            accelerometerEnabled = false;
            mouseDelta = new Vector2();

            keyboardManager = new KeyboardManager(game);
            mouseManager = new MouseManager(game);
            pointerManager = new PointerManager(game);
            keyMapping = new KeyMapping();

            // get the accelerometer. Returns null if no accelerometer found
            accelerometer = Accelerometer.GetDefault();
            window = Window.Current.CoreWindow;

            // Set up the gesture recognizer.  In this game, it only responds to TranslateX, TranslateY and Tap events
            gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX | 
                GestureSettings.ManipulationTranslateY | GestureSettings.Tap;
            
            // Register event handlers for pointer events
            window.PointerPressed += OnPointerPressed;
            window.PointerMoved += OnPointerMoved;
            window.PointerReleased += OnPointerReleased;
            
            // automatically enable accelerometer if we have one
            this.AccelerometerEnabled(true);
            this.MouseDeltaEnabled(true);
            
        }
示例#3
0
 public BallMovement(Project2Game game)
 {
     this.game = game;
     reset();
     //accelerate = new Vector3(0, -0.007f, 0);
     //velocity = new Vector3(0, -0.03f, 0);
     //heights = game.landscape.pHeights;
 }
示例#4
0
 public BallMovement(Project2Game game)
 {
     this.game = game;
     reset();
     //accelerate = new Vector3(0, -0.007f, 0);
     //velocity = new Vector3(0, -0.03f, 0);
     //heights = game.landscape.pHeights;
 }
        Jitter.Collision.CollisionSystem collisionSystem = new Jitter.Collision.CollisionSystemPersistentSAP(); // SAP = Scan and Prune (good for large scenes, bruteforce might be fine for small scenes too)

        public PhysicsSystem(Project2Game game)
            : base(game)
        {
            this.game = game;

            World = new JitterWorld(collisionSystem); // whole_new_world.wav
            // gravity defaults to -9.8 m.s^-2
            // World.Gravity = new JVector(0f, -20, 0);
            accuracy = PersistentStateManager.physicsAccuracy;   // lower this for higher FPS (accuracy = 1 still seems to work okay, it's just not ideal)
        }
示例#6
0
文件: GameModel.cs 项目: 2666fff/demo
        public GameModel(Model model, Game game, float x, float y, float z)
        {
            this.game = (Project2Game) game;
            this.model = model;
            effect = game.Content.Load<Effect>("ObjectShader");
            this.position = new Vector3(x, y, z);
            World = Matrix.Identity;

            lightPointPositions = new [] {
                new Vector3(0, 180, 0),
                new Vector3(-this.game.landscape.baord_size_public , 180, 0),
                new Vector3(this.game.landscape.baord_size_public, 180, this.game.landscape.baord_size_public)
            };
        }
示例#7
0
        public GameModel(Model model, Game game, float x, float y, float z)
        {
            this.game     = (Project2Game)game;
            this.model    = model;
            effect        = game.Content.Load <Effect>("ObjectShader");
            this.position = new Vector3(x, y, z);
            World         = Matrix.Identity;

            lightPointPositions = new [] {
                new Vector3(0, 180, 0),
                new Vector3(-this.game.landscape.baord_size_public, 180, 0),
                new Vector3(this.game.landscape.baord_size_public, 180, this.game.landscape.baord_size_public)
            };
        }
        public ThirdPersonCamera(Project2Game game, Vector3 position, Vector3 offset)
        {
            this.game = game;
            this.position = position;
            this.offset = offset;

            this.view = Matrix.LookAtRH(position, Vector3.Zero, Vector3.Up);
            this.projection = Matrix.PerspectiveFovRH(
                (float)Math.PI / 4.0f,
                (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height,
                0.1f,
                500.0f
            );
        }
        public ControllableCamera(Project2Game game, Vector3 position, Vector3 target)
        {
            this.game = game;
            this.position = position;
            this.direction = target - position;
            this.movement = new Vector3(0.0f, 0.0f, 0.0f);

            this.view = Matrix.LookAtLH(position, target, Vector3.Up);
            this.projection = Matrix.PerspectiveFovLH(
                (float)Math.PI / 4.0f,
                (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height,
                0.1f,
                100.0f
            );
        }
示例#10
0
文件: Camera.cs 项目: 2666fff/demo
        public Camera(Project2Game game, MainPage main)
        {
            distance   = new Vector3(0, 0, -15);
            position   = new Vector3(0, 0, 0);
            View       = Matrix.LookAtLH(distance, Vector3.Zero, Vector3.UnitY);
            Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f,
                                                 (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, 500.0f);

            AngleH    = 0;
            AngleV    = -0.7f;
            this.main = main;
            this.game = game;

            mouseManager = new MouseManager(game);
        }
示例#11
0
文件: Camera.cs 项目: 2666fff/demo
        public Camera(Project2Game game, MainPage main)
        {
            distance = new Vector3(0, 0, -15);
            position = new Vector3(0, 0, 0);
            View = Matrix.LookAtLH(distance, Vector3.Zero, Vector3.UnitY);
            Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f,
                (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, 500.0f);

            AngleH = 0;
            AngleV = -0.7f;
            this.main = main;
            this.game = game;

            mouseManager = new MouseManager(game);
        }
示例#12
0
        public Landscape2(Project2Game game)
        {
            MAX_HEIGHT = rnd.NextFloat(INIT_MIN_HEIGHT, INIT_MAX_HEIGHT);      //Randomize the height

            //initlize the world
            vpc      = InitializeGrid();
            vertices = Buffer.Vertex.New <VertexPositionNormalColor>(game.GraphicsDevice, vpc);

            effect = game.Content.Load <Effect>("LandscapeShader");

            effect.Parameters["World"].SetValue(Matrix.Identity);
            effect.Parameters["Projection"].SetValue(game.camera.Projection);
            effect.Parameters["worldInvTrp"].SetValue(Matrix.Transpose(Matrix.Invert(Matrix.Identity)));
            effect.Parameters["maxHeight"].SetValue(COLOUR_SCALE);

            inputLayout = VertexInputLayout.FromBuffer <VertexPositionNormalColor>(0, (Buffer <VertexPositionNormalColor>)vertices);
            this.game   = game;
        }
示例#13
0
        public MainPage()
        {
            InitializeComponent();
            focussld = false;
            game     = new Project2Game(this);
            game.Run(this);
            timer.Start();

            //initialize positions
            startScreen.Width      = getScreenWidth();
            startScreen.Height     = getScreenHeight();
            bstart.Margin          = new Thickness(startScreen.Width - 400, 180, 0, 0);
            bstart_practise.Margin = new Thickness(startScreen.Width - 400, 300, 0, 0);
            bcontrol.Margin        = new Thickness(startScreen.Width - 400, 420, 0, 0);
            babout.Margin          = new Thickness(startScreen.Width - 400, 540, 0, 0);
            sldforce.Margin        = new Thickness(20, startScreen.Height - 100, 0, 0);
            btnhit.Margin          = new Thickness(startScreen.Width - 280, startScreen.Height - 280, 0, 0);
            menuBar.Margin         = new Thickness(startScreen.Width - 400, 0, 0, 0);
            displayText.Margin     = new Thickness(10, 180, 0, 0);
            displayText.Visibility = Visibility.Collapsed;
        }
示例#14
0
        public MainPage()
        {
            InitializeComponent();
            focussld = false;
            game = new Project2Game(this);
            game.Run(this);
            timer.Start();

            //initialize positions
            startScreen.Width = getScreenWidth();
            startScreen.Height = getScreenHeight();
            bstart.Margin = new Thickness(startScreen.Width - 400, 180, 0, 0);
            bstart_practise.Margin = new Thickness(startScreen.Width - 400, 300, 0, 0);
            bcontrol.Margin = new Thickness(startScreen.Width - 400, 420, 0, 0);
            babout.Margin = new Thickness(startScreen.Width - 400, 540, 0, 0);
            sldforce.Margin = new Thickness(20, startScreen.Height - 100, 0, 0);
            btnhit.Margin = new Thickness(startScreen.Width - 280, startScreen.Height - 280, 0, 0);
            menuBar.Margin = new Thickness(startScreen.Width - 400, 0, 0, 0);
            displayText.Margin = new Thickness(10, 180, 0, 0);
            displayText.Visibility = Visibility.Collapsed;
        }
 protected GameStateManager(Project2Game game) : base(game) {
     this.game = game;
 }
示例#16
0
 public ObjectMovement(Project2Game game)
 {
     this.game = game;
     velocity = Vector3.Zero;
 }
示例#17
0
 public DebugDrawer(Project2Game game)
     : base(game)
 {
     this.game = game;
 }
示例#18
0
 public ObjectMovement(Project2Game game)
 {
     this.game = game;
     velocity  = Vector3.Zero;
 }
示例#19
0
        public Landscape2(Project2Game game)
        {
            MAX_HEIGHT = rnd.NextFloat(INIT_MIN_HEIGHT, INIT_MAX_HEIGHT);      //Randomize the height

            //initlize the world
            vpc = InitializeGrid();
            vertices = Buffer.Vertex.New<VertexPositionNormalColor>(game.GraphicsDevice, vpc);

            effect = game.Content.Load<Effect>("LandscapeShader");

            effect.Parameters["World"].SetValue(Matrix.Identity);
            effect.Parameters["Projection"].SetValue(game.camera.Projection);
            effect.Parameters["worldInvTrp"].SetValue(Matrix.Transpose(Matrix.Invert(Matrix.Identity)));
            effect.Parameters["maxHeight"].SetValue(COLOUR_SCALE);

            inputLayout = VertexInputLayout.FromBuffer<VertexPositionNormalColor>(0, (Buffer<VertexPositionNormalColor>) vertices);
            this.game = game;
        }