Example #1
1
 public LightManager(ProjectGame game)
 {
     packedLights = new PackedLight[MAX_LIGHTS];
     // Set the ambient color equal to the Cosmic latte
     ambientCol = new Vector4(1, 0.9725f, 0.9059f, 1.0f);
     this.game = game;
 }
Example #2
0
        // Set the intil values for the camera
        public Camera(ProjectGame game)
        {
            cameraPos = new Vector3(0, y_camera_position, 0);
            cameraTarget = new Vector3(-platform_midpoint, 0, 0);
            cameraUp = Vector3.UnitY;

            View = Matrix.LookAtRH(cameraPos, cameraTarget, cameraUp);
            Projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, 1000.0f);
            this.game = game;
        }
Example #3
0
 public Cursor(ProjectGame game)
 {
     this.game   = game;
     model       = game.Content.Load <Model>("Cursor");
     basicEffect = new BasicEffect(game.GraphicsDevice)
     {
         World      = Matrix.Identity,
         View       = game.camera.View,
         Projection = game.camera.Projection
     };
     BasicEffect.EnableDefaultLighting(model, true);
 }
Example #4
0
 public Cursor(ProjectGame game)
 {
     this.game = game;
     model = game.Content.Load<Model>("Cursor");
     basicEffect = new BasicEffect(game.GraphicsDevice)
     {
         World = Matrix.Identity,
         View = game.camera.View,
         Projection = game.camera.Projection
     };
     BasicEffect.EnableDefaultLighting(model, true);
 }
Example #5
0
        public MainPage()
        {
            InitializeComponent();
            //Loaded += OnLoaded;

            game = new ProjectGame(this);
            game.Run(this);

            mainMenu = new MainMenu(this);
            //endPage = new EndPage(this);

            this.Children.Add(mainMenu);
            InGameView(Visibility.Collapsed);
            txtCameraPos.Visibility = Visibility.Collapsed;
            txtCameraTarget.Visibility = Visibility.Collapsed;
            txtPlayerPos.Visibility = Visibility.Collapsed;
        }
Example #6
0
        public MainPage()
        {
            InitializeComponent();
            //Loaded += OnLoaded;


            game = new ProjectGame(this);
            game.Run(this);

            mainMenu = new MainMenu(this);
            //endPage = new EndPage(this);

            this.Children.Add(mainMenu);
            InGameView(Visibility.Collapsed);
            txtCameraPos.Visibility    = Visibility.Collapsed;
            txtCameraTarget.Visibility = Visibility.Collapsed;
            txtPlayerPos.Visibility    = Visibility.Collapsed;
        }
Example #7
0
        public Platform(ProjectGame game)
        {
            // Avoid null reference, it changes on the first update
            if (standing_platform == null)
            {
                standing_platform      = this;
                next_standing_platform = this;
            }

            // Less tiles if the difficulty is higher
            min_extra_tiles = (int)(max_extra_tiles - game.difficulty);
            type            = GameObjectType.Platform;

            //Load textures
            textureName = "Platform_Textures";
            texture     = game.Content.Load <Texture2D>(textureName);

            // Store information of the platform and create information for the next one
            platform      = next_platform;
            next_platform = create_platform(platform);

            // Create the vertices based on the platform information
            VertexPositionNormalTexture[] platform_vertices = create_vertices(platform, last_platform, next_platform);
            last_platform = platform;

            // Set the platform Z position of the intance and uptade the new Z position for the next one
            z_position_start = z_position;
            z_position      -= tile_depth;
            z_position_end   = z_position;

            // Calculates midpoint and base
            platfom_midpoint = (platform.GetLength(0) * tile_width) - tile_width / 2;
            platform_base    = Levels[0] - base_offset;

            //Load effects
            effect       = game.Content.Load <Effect>("Phong");
            lightManager = new LightManager(game);
            lightManager.SetLighting(effect);

            // Pass the vertices data
            vertices    = Buffer.Vertex.New(game.GraphicsDevice, platform_vertices);
            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game   = game;
        }
Example #8
0
        public Platform(ProjectGame game)
        {
            // Avoid null reference, it changes on the first update
            if (standing_platform == null)
            {
                standing_platform = this;
                next_standing_platform = this;
            }

            // Less tiles if the difficulty is higher
            min_extra_tiles = (int)(max_extra_tiles - game.difficulty);
            type = GameObjectType.Platform;

            //Load textures
            textureName = "Platform_Textures";
            texture = game.Content.Load<Texture2D>(textureName);

            // Store information of the platform and create information for the next one
            platform = next_platform;
            next_platform = create_platform(platform);

            // Create the vertices based on the platform information
            VertexPositionNormalTexture[] platform_vertices = create_vertices(platform, last_platform, next_platform);
            last_platform = platform;

            // Set the platform Z position of the intance and uptade the new Z position for the next one
            z_position_start = z_position;
            z_position -= tile_depth;
            z_position_end = z_position;

            // Calculates midpoint and base
            platfom_midpoint = (platform.GetLength(0) * tile_width) - tile_width/2;
            platform_base = Levels[0] - base_offset;

            //Load effects
            effect = game.Content.Load<Effect>("Phong");
            lightManager = new LightManager(game);
            lightManager.SetLighting(effect);

            // Pass the vertices data
            vertices = Buffer.Vertex.New(game.GraphicsDevice, platform_vertices);
            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game = game;
        }
Example #9
0
        // Constructor for the player as the shooter
        public Projectile(ProjectGame game, string model_name, Vector3 pos, float velocity, Enemy target, GameObjectType targetType)
        {
            this.game       = game;
            this.pos        = pos;
            this.velocity   = velocity;
            this.target     = target;
            this.targetType = targetType;
            hitRadius       = 5;
            squareHitRadius = hitRadius * hitRadius;
            collisionRadius = squareHitRadius;
            scaling         = 1.5f;

            model       = game.Content.Load <Model>(model_name);
            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                World      = Matrix.Identity,
                View       = game.camera.View,
                Projection = game.camera.Projection
            };
            BasicEffect.EnableDefaultLighting(model, true);
        }
Example #10
0
        // Constructor for the player as the shooter
        public Projectile(ProjectGame game, string model_name, Vector3 pos, float velocity, Enemy target, GameObjectType targetType)
        {
            this.game = game;
            this.pos = pos;
            this.velocity = velocity;
            this.target = target;
            this.targetType = targetType;
            hitRadius = 5;
            squareHitRadius = hitRadius * hitRadius;
            collisionRadius = squareHitRadius;
            scaling = 1.5f;

            model = game.Content.Load<Model>(model_name);
            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                World = Matrix.Identity,
                View = game.camera.View,
                Projection = game.camera.Projection
            };
            BasicEffect.EnableDefaultLighting(model, true);
        }
Example #11
0
        // Constructor with the enemy as the shooter
        public Projectile(ProjectGame game, Enemy shooter, Vector3 pos, float velocity, Vector3 targetPos, GameObjectType targetType)
        {
            this.game       = game;
            this.shooter    = shooter;
            this.pos        = pos;
            this.velocity   = velocity;
            this.targetPos  = targetPos;
            this.targetType = targetType;
            squareHitRadius = hitRadius * hitRadius;
            collisionRadius = squareHitRadius;
            isTargetPlayer  = true;
            scaling         = 8;

            model       = game.Content.Load <Model>("Sphere");
            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                World      = Matrix.Identity,
                View       = game.camera.View,
                Projection = game.camera.Projection
            };
            BasicEffect.EnableDefaultLighting(model, true);
        }
Example #12
0
        // Constructor with the enemy as the shooter
        public Projectile(ProjectGame game, Enemy shooter, Vector3 pos, float velocity, Vector3 targetPos, GameObjectType targetType)
        {
            this.game = game;
            this.shooter = shooter;
            this.pos = pos;
            this.velocity = velocity;
            this.targetPos = targetPos;
            this.targetType = targetType;
            squareHitRadius = hitRadius * hitRadius;
            collisionRadius = squareHitRadius;
            isTargetPlayer = true;
            scaling = 8;

            model = game.Content.Load<Model>("Sphere");
            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                World = Matrix.Identity,
                View = game.camera.View,
                Projection = game.camera.Projection
            };
            BasicEffect.EnableDefaultLighting(model, true);
        }
Example #13
0
        public Player(ProjectGame game,Vector3 initial_pos)
        {
            this.game = game;
            alive = true;
            World = Matrix.Identity;
            type = GameObjectType.Player;
            model = game.Content.Load<Model>("Spaceship");
            basicEffect = new BasicEffect(game.GraphicsDevice);
            BasicEffect.EnableDefaultLighting(model, true);

            WorldInverseTranspose = Matrix.Transpose(Matrix.Invert(World));

            collisionRadius = 5.0f;

            //Set initial position
            pos = initial_pos;
            update_points();

            cursor = new Cursor(game);
            game.gameObjects.Add(cursor);

            //spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));
        }
Example #14
0
        public Enemy(ProjectGame game, Vector3 pos)
        {
            this.game = game;
            type = GameObjectType.Player;
            model = game.Content.Load<Model>("Enemy");

            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                View = game.camera.View,
                Projection = game.camera.Projection,
                World = Matrix.Identity,
            };
            BasicEffect.EnableDefaultLighting(model, true);
            type = GameObjectType.Enemy;

            // Put the Enemy away from the camera
            this.pos = pos;
            this.pos.Z = game.camera.Position.Z + distance_from_screen;

            // Send first direction to the player
            travelTimer = 0;
            setFireTimer();
        }
Example #15
0
        public Enemy(ProjectGame game, Vector3 pos)
        {
            this.game = game;
            type      = GameObjectType.Player;
            model     = game.Content.Load <Model>("Enemy");

            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                View       = game.camera.View,
                Projection = game.camera.Projection,
                World      = Matrix.Identity,
            };
            BasicEffect.EnableDefaultLighting(model, true);
            type = GameObjectType.Enemy;

            // Put the Enemy away from the camera
            this.pos   = pos;
            this.pos.Z = game.camera.Position.Z + distance_from_screen;

            // Send first direction to the player
            travelTimer = 0;
            setFireTimer();
        }
Example #16
0
 // Constructor.
 public EnemyController(ProjectGame game)
 {
     this.game = game;
 }
Example #17
0
 private void OnLoaded(object s, RoutedEventArgs e)
 {
     MainPage newmain = new MainPage();
     game = new ProjectGame(newmain);
     game.Run(swapppy);
 }