Пример #1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
Пример #2
0
 //enemy constructor
 public Enemy(Game1 game)
 {
     this.game = game;
     //creates a new collision box for the enemy |location|size X,Y,Z|is dynamic or not|
     enemyColBox = new Box(getNewLocation(), 1, 1, 1, 0.1f);
     //is enemy affected by gravity
     enemyColBox.IsAffectedByGravity = false;
     // Model transforms
     Matrix transform = Matrix.CreateScale(enemyColBox.Width, enemyColBox.Height, enemyColBox.Length);
     //Loads the enemy model and places it an the correct position then scales, rotates
     EntityModel enemyModel = new EntityModel(enemyColBox, game.Content.Load<Model>("Models/enemyShip1"), Matrix.Identity * Matrix.CreateScale(0.03f) * Matrix.CreateRotationX(30f), game);
     //adds enemy collision box to the game
     game.space.Add(enemyColBox);
     //adds enemy moddel to the game
     game.Components.Add(enemyModel);
     enemyColBox.Tag = enemyModel;
     //sets the enemy positon at a new random location
     targetLocation = getNewLocation();
 }
Пример #3
0
 //Player Constructor
 public Player(Game1 game)
 {
     this.game = game;
     //creates a new collision box for the player |location|size X,Y,Z|
     shipColBox = new Box(shipPos, 1f, 1f, 1f);
     //sets its mass
     shipColBox.Mass = 2.0f;
     // sets if its affected by gravity
     shipColBox.IsAffectedByGravity = false;
     //add collision box to game
     game.space.Add(shipColBox);
     //Loads the ship model and applys transforms
     shipModel = new EntityModel(shipColBox, game.Content.Load<Model>("Models/Ship"), Matrix.Identity * Matrix.CreateScale(0.0005f), game);
     //load laser sound
     laser = game.Content.Load<SoundEffect>("Audio/Laser");
     //add ship model to game
     game.Components.Add(shipModel);
     shipColBox.Tag = shipModel;
     //resets position of player in world space
     //collision rule to prevent the bullet colliding  with the player ship
     //CollisionRules.AddRule(shipColBox, game.bullet, CollisionRule.NoBroadPhase);
     //set bullet collision information with game objects
     shipColBox.CollisionInformation.Events.InitialCollisionDetected += ShipCollision;
 }
Пример #4
0
        public void DrawTurrets(Game1 game)
        {
            turretColBox = new Box(turretPos, 2f, 2f, 2f);
            turretModel = new EntityModel(turretColBox, game.Content.Load<Model>("Models/turret"), (Matrix.CreateScale(0.020f) * Matrix.CreateRotationX(30f) * Matrix.CreateTranslation(0f,0f,-7f)), game);
            game.space.Add(turretColBox);
            game.Components.Add(turretModel);
            turretColBox.Tag = turretModel;

            turretColBox1 = new Box(turretPos1, 2f, 2f, 2f);
            turretModel = new EntityModel(turretColBox1, game.Content.Load<Model>("Models/turret"), (Matrix.CreateScale(0.020f) * Matrix.CreateRotationX(30f) * Matrix.CreateTranslation(0f, 0f, -7f)), game);
            game.space.Add(turretColBox1);
            game.Components.Add(turretModel);
            turretColBox1.Tag = turretModel;

            turretColBox2 = new Box(turretPos2, 2f, 2f, 2f);
            turretModel = new EntityModel(turretColBox2, game.Content.Load<Model>("Models/turret"), (Matrix.CreateScale(0.020f) * Matrix.CreateRotationX(30f) * Matrix.CreateTranslation(0f, 0f, -7f)), game);
            game.space.Add(turretColBox2);
            game.Components.Add(turretModel);
            turretColBox2.Tag = turretModel;

            turretColBox3 = new Box(turretPos3, 2f, 2f, 2f);
            turretModel = new EntityModel(turretColBox3, game.Content.Load<Model>("Models/turret"), (Matrix.CreateScale(0.020f) * Matrix.CreateRotationX(30f) * Matrix.CreateTranslation(0f, 0f, -7f)), game);
            game.space.Add(turretColBox3);
            game.Components.Add(turretModel);
            turretColBox3.Tag = turretModel;
        }
Пример #5
0
        public void DrawTerrain(Game1 game)
        {
            //===============================TERRAIN================================================
            //Create a physical environment from a triangle mesh.
            //First, collect the the mesh data from the model using a helper function.
            //This special kind of vertex inherits from the TriangleMeshVertex and optionally includes
            //friction/bounciness data.
            //The StaticTriangleGroup requires that this special vertex type is used in lieu of a normal TriangleMeshVertex array.
            Vector3[] vertices;
            int[] indices;
            TriangleMesh.GetVerticesAndIndicesFromModel(terrain, out vertices, out indices);
            //Give the mesh information to a new StaticMesh.
            //Give it a transformation which scoots it down below the kinematic box entity we created earlier.
            var mesh = new StaticMesh(vertices, indices, new AffineTransform(new Vector3(0, -30, 0)));

            //Add it to the space!
            game.space.Add(mesh);
            //Make it visible too.
            game.Components.Add(new StaticModel(terrain, mesh.WorldTransform.Matrix, game));
            //======================================================================================
        }
Пример #6
0
 public void DrawBuidlings(Game1 game)
 {
     buildingColBox = new Box(buildingPos, 6f, 3f, 3f);
     buildingModel = new EntityModel(buildingColBox, game.Content.Load<Model>("Models/shack"), Matrix.Identity * (Matrix.CreateScale(0.05f)*Matrix.CreateRotationX(30.0f)), game);
     game.space.Add(buildingColBox);
     game.Components.Add(buildingModel);
     buildingColBox.Tag = buildingModel;
 }