public void automove(staticmesh rightside, staticmesh bottomwall, model3d enemybot, Vector3 rot)
        {
            if (visible)
            {
                if (MathHelper.ToDegrees(rotation.Y) >= 360)
                {
                    rotation.Y = 0;
                }
                if (MathHelper.ToDegrees(rotation.Y) < 0)
                {
                    rotation.Y = MathHelper.ToRadians(359);
                }

                velocity.X += 50;

                // Work out the direction R2 is facing
                direction.Z = (float)(Math.Cos(rotation.Y));
                direction.X = (float)(Math.Sin(rotation.Y));
                if (enemybot.bsphere.Intersects(rightside.bbox))
                {
                    velocity.X = -velocity.X;
                }
                //if (enemybot.bsphere.Intersects(rightside.bbox))
                //{
                //    velocity.X = -velocity.X;
                //}
                if (enemybot.bsphere.Intersects(bottomwall.bbox))
                {
                    velocity.Z = -velocity.Z;
                }
                //if (enemybot.bsphere.Intersects(bottomwall.bbox))
                //{
                //    velocity.Z = -velocity.Z;
                //}

                position += velocity;
            }
        }
Esempio n. 2
0
        // Reset values for the start of a new game
        void reset()
        {
            gameover = false;

            // Load the 3D models for the static objects in the game from the ContentManager
            ground = new staticmesh(Content, "sground", 100f, new Vector3(0, -40, 0), new Vector3(0, 0, 0));

            // Initialise robot1 object
            robot = new model3d(Content, "r2d2v2", 2f, new Vector3(1000, 0, 1000), new Vector3(0, 0, 0), 0.002f, 0.05f, 10);

            for (int i = 0; i < numberoftrees; i++)
            {
                if (i % 2 == 0)
                {
                    tree[i] = new staticmesh(Content, "tree", (float)(randomiser.Next(20) + 1) / 10,
                        new Vector3(randomiser.Next(6000) - 3000, 0, randomiser.Next(6000) - 3000),
                       new Vector3(0, randomiser.Next(7), 0));
                    tree[i].position.Y = tree[i].radius/2; 
                }
                else
                {
                    tree[i] = new staticmesh(Content, "lamppost", (float)(randomiser.Next(20) + 1) / 3,
                                    new Vector3(randomiser.Next(6000) - 3000, 0, randomiser.Next(6000) - 3000),
                                        new Vector3(0, randomiser.Next(7), 0));
                    tree[i].position.Y = tree[i].size * 40;
                }
            }

            tree[50] = new staticmesh(Content, "tank", (float)(randomiser.Next(20) + 1) / 10,
                                    new Vector3(randomiser.Next(6000), 140, randomiser.Next(6000)),
                                        new Vector3(0, randomiser.Next(7), 0));
            tree[50].position.Y = tree[50].radius;
            tree[51] = new staticmesh(Content, "ship", (float)(randomiser.Next(20) + 1) / 10,
                                    new Vector3(randomiser.Next(6000) - 3000, 1000, randomiser.Next(6000) - 3000),
                                        new Vector3(0, randomiser.Next(7), 0));
        }
Esempio n. 3
0
        void reset()
        {
            // Reset everything for a new game
            gameover = false;
            uservehicle.position = new Vector3(1000, 0, 1000);
            uservehicle.rotation = new Vector3(0, 0, 0);
            uservehicle.velocity = new Vector3(0, 0, 0);

            // Randomly intialise trees and lampposts
            for (int i = 0; i < numberoftrees; i++)
            {
                if (i % 2 == 0)
                    tree[i] = new staticmesh(Content, "tree", (float)(randomiser.Next(20) + 1) / 10,
                                    new Vector3(randomiser.Next(6000) - 3000, 0, randomiser.Next(6000) - 3000),
                                        new Vector3(0, randomiser.Next(7), 0));
                else
                {
                    tree[i] = new staticmesh(Content, "lamppost", (float)(randomiser.Next(20) + 1) / 3,
                                    new Vector3(randomiser.Next(6000) - 3000, 0, randomiser.Next(6000) - 3000),
                                        new Vector3(0, randomiser.Next(7), 0));
                    tree[i].position.Y = tree[i].size * 40;
                }
            }

            int numbertospawn = 10 + randomiser.Next(100);

            for (int i = 0; i < numbertospawn; i++)
            {
                ufos.Add(new staticmesh(Content, "ship",
                    (float)(1 + randomiser.Next(20) / 10),
                    new Vector3(randomiser.Next(12000) - 6000, 600 + randomiser.Next(3000), randomiser.Next(12000) - 6000),
                    new Vector3(0, 0, 0)));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            mainfont = Content.Load<SpriteFont>("quartz4");  // Load the quartz4 font

            background = new graphic2d(Content, "Background for Menus", displaywidth, displayheight);

            up = new sprite2d(Content, "up", 105, displayheight - 180, 0.3f, Color.White, true);
            down = new sprite2d(Content, "down",105, displayheight - 50, 0.3f, Color.White, true);
            left = new sprite2d(Content, "left", 50, displayheight - 115, 0.3f, Color.White, true);
            right = new sprite2d(Content, "right", 160, displayheight - 115, 0.3f, Color.White, true);
            left2 = new sprite2d(Content, "left", displaywidth-180, displayheight - 100, 0.3f, Color.White, true);
            right2 = new sprite2d(Content, "right", displaywidth-60, displayheight - 100, 0.3f, Color.White, true);

            menuoptions[0] = new sprite2d(Content, "player1", displaywidth / 2, 150, 1, Color.White, true);
            menuoptions[1] = new sprite2d(Content, "options", displaywidth / 2, 220, 1, Color.White, true);
            menuoptions[2] = new sprite2d(Content, "highscore", displaywidth / 2, 290, 1, Color.White, true);
            menuoptions[3] = new sprite2d(Content, "exit", displaywidth / 2, 360, 1, Color.White, true);

            // Load the 3D models for the static objects in the game from the ContentManager
            ground = new staticmesh(Content, "sground", 100f, new Vector3(0, -40, 0), new Vector3(0, 0, 0));

            // Initialise robot1 object
            uservehicle = new model3d(Content, "tiefighter", 2f, new Vector3(1000, 0, 1000), new Vector3(0, 0, 0), 0.002f, 0.06f, 10);

            /*
            tree[50] = new staticmesh(Content, "tank", (float)(randomiser.Next(20) + 1) / 10,
                                    new Vector3(randomiser.Next(6000) - 3000, 200, randomiser.Next(6000) - 3000),
                                        new Vector3(0, randomiser.Next(7), 0));
            tree[51] = new staticmesh(Content, "ship", (float)(randomiser.Next(20) + 1) / 10,
                                    new Vector3(randomiser.Next(6000) - 3000, 200, randomiser.Next(6000) - 3000),
                                        new Vector3(0, randomiser.Next(7), 0));
            tree[52] = new staticmesh(Content, "stars", 10,
                                    new Vector3(randomiser.Next(6000) - 3000, 200, randomiser.Next(6000) - 3000),
                                        new Vector3(0, randomiser.Next(7), 0));
            */

            // Load High Scores in
            using (IsolatedStorageFile savegamestorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (savegamestorage.FileExists("highscores.txt"))
                {
                    using (IsolatedStorageFileStream fs = savegamestorage.OpenFile("highscores.txt", System.IO.FileMode.Open))
                    {
                        using (StreamReader sr = new StreamReader(fs))
                        {
                            string line;
                            for (int i = 0; i < numberofhighscores; i++)
                            {
                                line = sr.ReadLine();
                                highscores[i] = Convert.ToInt32(line);
                            }

                            sr.Close();
                        }
                    }
                }
            }
            // Sort high scores
            Array.Sort(highscores);
            Array.Reverse(highscores);

        }
Esempio n. 5
0
        public void resetstart()// used for loading, placing and moving enemies
        {

            for (int i = 0; i < numberofenemys; i++)
            {
                enemy[i] = new model3d(Content, "r2d2v2", 8f, new Vector3(0, 0, 0), new Vector3(0, MathHelper.ToRadians(90), 0), 0.002f, 0.5f, 10, true);//-59000

            }

            enemy[0].position = new Vector3(-20000, 760, -52000);
            enemy[1].position = new Vector3(-20000, 760, -54000);
            enemy[2].position = new Vector3(-29000, 760, -53000);
            enemy[3].position = new Vector3(-29000, 760, -51000);
            enemy[2].rotation = new Vector3(0, MathHelper.ToRadians(90), 0);
            enemy[3].rotation = new Vector3(0, MathHelper.ToRadians(90), 0);
            enemy[4].position = new Vector3(-27010, 760, -36220);
            enemy[4].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[5].position = new Vector3(-7000, 760, -36320);
            enemy[5].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[6].position = new Vector3(8000, 760, -36420);
            enemy[6].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[7].position = new Vector3(3000, 760, -36520);
            enemy[7].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[8].position = new Vector3(0, 760, -36620);
            enemy[8].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[9].position = new Vector3(-20000, 760, -36120);
            enemy[9].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[10].position = new Vector3(-30850, 760, -27620);
            enemy[10].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[11].position = new Vector3(-30850, 760, -26720);
            enemy[11].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[12].position = new Vector3(-20850, 760, -27720);
            enemy[12].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[13].position = new Vector3(-20850, 760, -26720);
            enemy[13].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[14].position = new Vector3(-10850, 760, -27720);
            enemy[14].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[15].position = new Vector3(-10850, 760, -26720);
            enemy[15].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[16].position = new Vector3(-25700, 760, -17420);
            enemy[16].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[17].position = new Vector3(-15850, 760, -16800);
            enemy[17].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[18].position = new Vector3(0, 760, -17800);
            enemy[18].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[19].position = new Vector3(15000, 760, -17000);
            enemy[19].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[20].position = new Vector3(30000, 760, -26720);
            enemy[20].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[21].position = new Vector3(30000, 760, -28720);
            enemy[21].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[22].position = new Vector3(20000, 760, -26720);
            enemy[22].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[23].position = new Vector3(20000, 760, -28720);
            enemy[23].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[24].position = new Vector3(-5200, 760, -28720);
            enemy[24].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[25].position = new Vector3(-4400, 760, -7020);
            enemy[25].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[25].position = new Vector3(16400, 760, -5720);
            enemy[25].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[26].position = new Vector3(14400, 760, -3720);
            enemy[26].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[27].position = new Vector3(24400, 760, 1720);
            enemy[27].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);


            enemy[28].position = new Vector3(12000, 760, -3720);
            enemy[28].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[29].position = new Vector3(-14400, 760, 2520);
            enemy[29].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[30].position = new Vector3(24400, 760, 3000);
            enemy[30].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[31].position = new Vector3(34400, 760, 4000);
            enemy[31].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[32].position = new Vector3(-10000, 760, 6000);
            enemy[32].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);

            enemy[28].position = new Vector3(10000, 760, 5050);
            enemy[28].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[29].position = new Vector3(5400, 760, -120);
            enemy[29].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[30].position = new Vector3(400, 760, -2200);
            enemy[30].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[31].position = new Vector3(-4400, 760, -5000);
            enemy[31].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[32].position = new Vector3(-8000, 760, -700);
            enemy[32].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[33].position = new Vector3(-27000, 760, -6500);
            enemy[33].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[34].position = new Vector3(-30000, 760, -6300);
            enemy[34].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[35].position = new Vector3(-20000, 760, 20300);
            enemy[36].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[36].position = new Vector3(-30000, 760, 19300);
            enemy[36].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[37].position = new Vector3(0, 760, 21300);
            enemy[37].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[38].position = new Vector3(30000, 760, 22300);
            enemy[38].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[39].position = new Vector3(20000, 760, 23000);
            enemy[39].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[40].position = new Vector3(10000, 760, 24000);
            enemy[40].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[41].position = new Vector3(0, 760, 19000);
            enemy[41].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            enemy[42].position = new Vector3(-10000, 760, 22000);
            enemy[42].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);
            //enemy[36].size = 200;
            //30010, ground[0].position.Y + 725, 30750

            // moves enemys
            enemy[0].velocity = new Vector3(-10, 0, -2);
            enemy[1].velocity = new Vector3(-10, 0, 2);
            enemy[2].velocity = new Vector3(10, 0, 0);
            enemy[3].velocity = new Vector3(10, 0, -4);
            enemy[4].velocity = new Vector3(30, 0, 0);
            enemy[5].velocity = new Vector3(-30, 0, 0);
            enemy[6].velocity = new Vector3(-30, 0, 0);
            enemy[6].velocity = new Vector3(30, 0, 0);
            enemy[7].velocity = new Vector3(30, 0, 0);
            enemy[8].velocity = new Vector3(30, 0, 0);
            enemy[9].velocity = new Vector3(30, 0, 0);
            enemy[10].velocity = new Vector3(30, 0, 0);
            enemy[11].velocity = new Vector3(30, 0, 0);
            enemy[12].velocity = new Vector3(30, 0, 0);
            enemy[13].velocity = new Vector3(30, 0, 0);
            enemy[14].velocity = new Vector3(30, 0, 0);
            enemy[15].velocity = new Vector3(30, 0, 0);
            enemy[16].velocity = new Vector3(30, 0, 0);
            enemy[17].velocity = new Vector3(30, 0, 0);
            enemy[18].velocity = new Vector3(30, 0, 0);
            enemy[19].velocity = new Vector3(30, 0, 0);
            enemy[20].velocity = new Vector3(30, 0, 0);
            enemy[21].velocity = new Vector3(30, 0, 0);
            enemy[22].velocity = new Vector3(30, 0, 0);
            enemy[23].velocity = new Vector3(30, 0, 0);
            enemy[24].velocity = new Vector3(30, 0, 30);
            enemy[25].velocity = new Vector3(30, 0, 0);
            enemy[26].velocity = new Vector3(30, 0, 0);
            enemy[27].velocity = new Vector3(30, 0, 0);
            enemy[28].velocity = new Vector3(40, 0, 0);
            enemy[29].velocity = new Vector3(30, 0, 30);
            enemy[30].velocity = new Vector3(40, 0, 0);
            enemy[31].velocity = new Vector3(30, 0, 30);
            enemy[32].velocity = new Vector3(30, 0, 30);
            enemy[33].velocity = new Vector3(30, 0, -30);
            enemy[34].velocity = new Vector3(40, 0, -10);
            enemy[35].velocity = new Vector3(40, 0, 0);
            enemy[36].velocity = new Vector3(40, 0, 0);
            enemy[37].velocity = new Vector3(40, 0, 10);
            enemy[38].velocity = new Vector3(0, 0, 40);
            enemy[39].velocity = new Vector3(40, 0, 0);
            enemy[40].velocity = new Vector3(40, 0, 0);
            enemy[41].velocity = new Vector3(40, 0, 0);
            enemy[42].velocity = new Vector3(40, 0, 0);
            //enemy[43].velocity = new Vector3(40, 0, 0);


            for (int i = 0; i < numberofenemys; i++)// creats bounding shpere around the enemies
            {
                ibsphere[i] = new model3d(Content, "r2d2v2", 8f, new Vector3(0, 0, 0), new Vector3(0, MathHelper.ToRadians(90), 0), 0.002f, 0.05f, 10, false);
                ibsphere[i].position = enemy[i].position;
                ibsphere[i].velocity = enemy[i].velocity;
            }


            // used for semi cut sceen at start of game
            bodyparts[0] = new staticmesh(Content, "limb", 40f, new Vector3(-24710, 550, -52320), new Vector3(0, 0, MathHelper.ToRadians(61)), true);
            bodyparts[1] = new staticmesh(Content, "limb", 30f, new Vector3(-25110, 550, -52320), new Vector3(0, 0, MathHelper.ToRadians(61)), true);
            bodyparts[2] = new staticmesh(Content, "limb", 40f, new Vector3(-24710, 550, -53120), new Vector3(0, 0, MathHelper.ToRadians(61)), true);
            bodyparts[3] = new staticmesh(Content, "limb", 30f, new Vector3(-24110, 550, -53120), new Vector3(0, 0, MathHelper.ToRadians(61)), true);
            bodyparts[4] = new staticmesh(Content, "head", 20f, new Vector3(-25710, 550, -52720), new Vector3(0, 0, MathHelper.ToRadians(61)), true);
            bodyparts[5] = new staticmesh(Content, "thurso", 40f, new Vector3(-25010, 450, -52720), new Vector3(MathHelper.ToRadians(90), 0, MathHelper.ToRadians(90)), true);

            //enemystartingposition();
        }
Esempio n. 6
0
        //public void enemystartingposition()
        //{
        //    for (int u = 0; u < numberofenemys; u++)
        //        if (robot[1].position.X - enemy[u].position.X > 8000)
        //            for (int i = 0; i < numberofenemys; i++)
        //                if (robot[1].visible == false)
        //                {
        //                    enemy[0].position = new Vector3(-20000, 760, -52000);
        //                    enemy[1].position = new Vector3(-20000, 760, -54000);
        //                    enemy[2].position = new Vector3(-29000, 760, -52900);
        //                    enemy[3].position = new Vector3(-29000, 760, -51000);
        //                    enemy[2].rotation = new Vector3(0, MathHelper.ToRadians(90), 0);
        //                    enemy[3].rotation = new Vector3(0, MathHelper.ToRadians(90), 0);
        //                    enemy[4].position = new Vector3(-27010, 760, -36220);
        //                    enemy[4].rotation = new Vector3(0, MathHelper.ToRadians(180), 0);

        //                    enemy[0].velocity = new Vector3(-20, 0, 0);
        //                    enemy[1].velocity = new Vector3(-20, 0, 0);
        //                    enemy[2].velocity = new Vector3(20, 0, 0);
        //                    enemy[3].velocity = new Vector3(20, 0, 0);
        //                    enemy[4].velocity = new Vector3(30, 0, 0);
        //                }
        //}


        public void checkcollisionmesh(staticmesh mesh)// used to check for collsion between robot and meshes 
        {
            for (int i = 0; i < numberofrobots; i++)
                //for (int i = 0; i < numberofhouses; i++)
                if (robot[i].bsphere.Intersects(mesh.bbox))
                {
                    robot[i].position.X = mesh.position.X;
                    robot[i].position.Y = mesh.position.Y;
                    robot[i].position.Z = mesh.position.Z;

                    robot[i].velocity.X = -robot[i].velocity.X;
                    robot[i].velocity.Y = -robot[i].velocity.Y;
                    robot[i].velocity.Z = -robot[i].velocity.Z;
                    robot[i].position = robot[i].oldposition;
                }
                else
                {
                    robot[i].oldposition = robot[i].position;
                }

        }
Esempio n. 7
0
 public void bulletcollisionmesh(staticmesh mesh)// check for hit between buttes and meshes
 {
     for (int i = 0; i < numberofbullets; i++)
         if (bullet[i].bsphere.Intersects(mesh.bbox))
         {
             bullet[i].visible = false;
         }
 }
Esempio n. 8
0
        // Reset values for the start of a new game
        void reset()
        {
            gameover = false;

            // Load the 3D models for the static objects in the game from the ContentManager
            //ground[0] = new staticmesh(Content, "sground", 1000f, new Vector3(0, -40, 100), new Vector3(0, 0, 0));
            //ground[1] = new staticmesh(Content, "sground", 100f, new Vector3(-10000, -40, 0), new Vector3(0, 0, 0));
            //ground[2] = new staticmesh(Content, "sground", 100f, new Vector3(10000, -40, 0), new Vector3(0, 0, 0));
            //ground[3] = new staticmesh(Content, "sground", 100f, new Vector3(-5000, -40, 0), new Vector3(0, 0, 0));
            //ground[4] = new staticmesh(Content, "sground", 100f, new Vector3(5000, -40, 0), new Vector3(0, 0, 0));
            //ground[5] = new staticmesh(Content, "sground", 100f, new Vector3(5000, -40, -10000), new Vector3(0, 0, 0));
            //ground[6] = new staticmesh(Content, "sground", 100f, new Vector3(-5000, -40, 10000), new Vector3(0, 0, 0));
            //ground[7] = new staticmesh(Content, "sground", 100f, new Vector3(-300000, -40, -300000), new Vector3(0, 0, 0));
            //ground[8] = new staticmesh(Content, "sground", 100f, new Vector3(300000, -40, 300000), new Vector3(0, 0, 0));
            //ground[9] = new staticmesh(Content, "sground", 100f, new Vector3(300, -40, 0), new Vector3(0, 0, 0));
            //ground[10] = new staticmesh(Content, "sground", 100f, new Vector3(-300, -40, 0), new Vector3(0, 0, 0));
            //ground[11] = new staticmesh(Content, "sground", 100f, new Vector3(0, -40, 300), new Vector3(0, 0, 0));
            //ground[12] = new staticmesh(Content, "sground", 100f, new Vector3(0, -40, -300), new Vector3(0, 0, 0));

            for (int i = 0; i < numberofground; i++)
                ground[i] = new staticmesh(Content, "tgrounds", 1000f, new Vector3(0, 0, 0), new Vector3(0, 0, 0), true);

            // Initialise robot1 object
            robot[0] = new model3d(Content, "r2d2v2", 4f, new Vector3(-31010, 460, 19300), new Vector3(0, MathHelper.ToRadians(75), 0), 0.002f, 0.05f, 10, true);//-36220
            robot[1] = new model3d(Content, "r2d2v2", 7f, new Vector3(-25010, 660, -52820), new Vector3(0, MathHelper.ToRadians(75), 0), 0.002f, 0.05f, 10, true);//-59000

            spray = new model3d(Content, "spray", 8f, new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0, 0, 0, false);
            for (int i = 0; i < numberofbullets; i++)
            {
                bullet[i] = new model3d(Content, "ballbullet", 40f, new Vector3(robot[0].position.X, robot[0].position.Y + 100, robot[0].position.Z), new Vector3(0, 0, 0), 0.002f, 0.05f, 10, false);
            }


            barrel[0] = new staticmesh(Content, "barrel", 300, new Vector3(-30000, 545, -49000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            barrel[1] = new staticmesh(Content, "barrel", 300, new Vector3(-23000, 545, -55000), new Vector3(0, MathHelper.ToRadians(270), 0), true);
            barrel[2] = new staticmesh(Content, "barrel", 300, new Vector3(-12200, 950, -48000), new Vector3(0, MathHelper.ToRadians(110), 0), true);
            barrel[3] = new staticmesh(Content, "barrel", 300, new Vector3(11000, 545, -49000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            barrel[4] = new staticmesh(Content, "barrel", 300, new Vector3(31000, 745, -58000), new Vector3(0, MathHelper.ToRadians(90), 0), true);

            tree1[0] = new staticmesh(Content, "broadleavedtreeB_mesh", 100, new Vector3(-6000, 1170, -47500), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            tree1[1] = new staticmesh(Content, "broadleavedtreeB_mesh", 400, new Vector3(5500, 1870, -46900), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            tree1[2] = new staticmesh(Content, "broadleavedtreeB_mesh", 600, new Vector3(-26500, 1170, -23000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            tree1[3] = new staticmesh(Content, "broadleavedtreeB_mesh", 800, new Vector3(30050, 1170, -17000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            tree1[4] = new staticmesh(Content, "broadleavedtreeB_mesh", 800, new Vector3(10000, 1170, -19000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            tree1[5] = new staticmesh(Content, "broadleavedtreeB_mesh", 1000, new Vector3(-5000, 1170, -18500), new Vector3(0, MathHelper.ToRadians(90), 0), true);

            horse[0] = new staticmesh(Content, "horsebrownhair", 150, new Vector3(-30900, 1000, -6500), new Vector3(0, MathHelper.ToRadians(270), 0), true);
            horse[1] = new staticmesh(Content, "horsegreyhair", 150, new Vector3(-29100, 1000, -8000), new Vector3(0, 0, 0), true);


            mark[0] = new staticmesh(Content, "simplebox", 1000, new Vector3(-20000, 500, -8000), new Vector3(0, 0, 0), true);
            mark[1] = new staticmesh(Content, "simplebox", 1000, new Vector3(33010, 500, -55320), new Vector3(0, 0, 0), true);
            mark[2] = new staticmesh(Content, "simplebox", 1000, new Vector3(-28520, 860, -40000), new Vector3(0, 0, MathHelper.ToRadians(45)), true);
            mark[3] = new staticmesh(Content, "simplebox", 1000, new Vector3(-27665, 500, -40000), new Vector3(0, 0, 0), true);
            mark[4] = new staticmesh(Content, "simplebox", 1000, new Vector3(-5000, 500, -40000), new Vector3(0, 0, 0), true);
            mark[5] = new staticmesh(Content, "simplebox", 1000, new Vector3(20000, 500, -7600), new Vector3(0, 0, 0), true);
            mark[6] = new staticmesh(Content, "simplebox", 1000, new Vector3(600, 500, -7600), new Vector3(0, 0, 0), true);
            mark[7] = new staticmesh(Content, "simplebox", 1000, new Vector3(-30000, 500, 4000), new Vector3(0, 0, 0), true);
            mark[8] = new staticmesh(Content, "simplebox", 1000, new Vector3(0, 500, 4000), new Vector3(0, 0, 0), true);
            mark[9] = new staticmesh(Content, "simplebox", 1000, new Vector3(20000, 500, 4000), new Vector3(0, 0, 0), true);

            for (int i = 0; i < numberofbtrees1; i++)
            {
                tree2[0] = new staticmesh(Content, "fir_mesh", 600, new Vector3(29000, 1170, -8500), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                tree2[i] = new staticmesh(Content, "fir_mesh", 600f, new Vector3(tree2[0].position.X - (i * 3010 * 5f), 1170, -8500), new Vector3(0, 0, 0), true);
            }
            //tree2[1] = new staticmesh(Content, "fir_mesh", 400, new Vector3(5500, 1870, -46900), new Vector3(0, MathHelper.ToRadians(90), 0));
            //tree2[2] = new staticmesh(Content, "fir_mesh", 600, new Vector3(-26500, 1170, -23000), new Vector3(0, MathHelper.ToRadians(90), 0));
            //tree2[3] = new staticmesh(Content, "fir_mesh", 800, new Vector3(30050, 1170, -17000), new Vector3(0, MathHelper.ToRadians(90), 0));
            //tree2[4] = new staticmesh(Content, "fir_mesh", 800, new Vector3(10000, 1170, -19000), new Vector3(0, MathHelper.ToRadians(90), 0));
            //tree2[5] = new staticmesh(Content, "fir_mesh", 1000, new Vector3(-5000, 1170, -18500), new Vector3(0, MathHelper.ToRadians(90), 0));


            resetstart();// calls restart

            car[0] = new staticmesh(Content, "Ferrari2", 400, new Vector3(-500, 475, -49500), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            car[1] = new staticmesh(Content, "Lamborghini2", 400, new Vector3(-7100, 820, -49500), new Vector3(0, MathHelper.ToRadians(90), 0), true);

            for (int i = 0; i < numberofhouses; i++)
            {
                house1[0] = new staticmesh(Content, "houseA", 1000f, new Vector3(30010, 460, -57320), new Vector3(0, 0, 0), true);
                house1[i] = new staticmesh(Content, "houseA", 1000f, new Vector3(house1[0].position.X - (i * 1010 * 5f), 460, -57320), new Vector3(0, 0, 0), true);
            }
            for (int i = 0; i < numberofhouses2; i++)
            {
                house2[0] = new staticmesh(Content, "houseB_mesh", 1000f, new Vector3(30010, 460, -47320), new Vector3(0, MathHelper.ToRadians(180), 0), true);
                house2[i] = new staticmesh(Content, "houseB_mesh", 1000f, new Vector3(house2[0].position.X - (i * 1010 * 5.9f), 460, -47320), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }
            for (int i = 0; i < numberofhouses2; i++)
            {
                house3[0] = new staticmesh(Content, "houseB_mesh", 1000f, new Vector3(30010, 460, -41960), new Vector3(0, 0, 0), true);
                house3[i] = new staticmesh(Content, "houseB_mesh", 1000f, new Vector3(house3[0].position.X - (i * 1010 * 5.9f), 460, -41960), new Vector3(0, MathHelper.ToRadians(0), 0), true);
            }
            for (int i = 0; i < numberofhouses; i++)
            {
                house4[0] = new staticmesh(Content, "houseC_mesh", 1000f, new Vector3(30010, 490, -32320), new Vector3(0, MathHelper.ToRadians(180), 0), true);
                house4[i] = new staticmesh(Content, "houseC_mesh", 1000f, new Vector3(house3[0].position.X - (i * 1010 * 5f), ground[0].position.Y + 490, -32320), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }
            for (int i = 0; i < numberofhouses; i++)
            {
                house5[0] = new staticmesh(Content, "houseC_mesh", 1000f, new Vector3(30010, ground[0].position.Y + 525, -13040), new Vector3(0, MathHelper.ToRadians(180), 0), true);
                house5[i] = new staticmesh(Content, "houseC_mesh", 1000f, new Vector3(house3[0].position.X - (i * 1010 * 5f), ground[0].position.Y + 525, -13040), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }

            for (int i = 0; i < numberofhouses; i++)
            {
                house6[0] = new staticmesh(Content, "houseD_mesh", 1000f, new Vector3(30010, 560, 10040), new Vector3(0, MathHelper.ToRadians(180), 0), true);
                house6[i] = new staticmesh(Content, "houseD_mesh", 1000f, new Vector3(house3[0].position.X - (i * 1010 * 5f), 560, 10040), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }
            for (int i = 0; i < numberofhouses; i++)
            {
                house7[0] = new staticmesh(Content, "houseD_mesh", 1000f, new Vector3(30010, 560, 15310), new Vector3(0, 0, 0), true);
                house7[i] = new staticmesh(Content, "houseD_mesh", 1000f, new Vector3(house3[0].position.X - (i * 1010 * 5f), 560, 15310), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }
            for (int i = 0; i < numberofhouses3; i++)
            {
                house8[0] = new staticmesh(Content, "houseF_mesh", 1000f, new Vector3(30010, 560, 30750), new Vector3(0, 0, 0), true);
                house8[i] = new staticmesh(Content, "houseF_mesh", 1000f, new Vector3(house3[0].position.X - (i * 2110 * 5f), 560, 30750), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }
            for (int i = 0; i < numberofhouses3; i++)
            {
                house9[0] = new staticmesh(Content, "houseE_mesh", 270f, new Vector3(30010, ground[0].position.Y + 725, 24750), new Vector3(0, 0, 0), true);
                house9[i] = new staticmesh(Content, "houseE_mesh", 270f, new Vector3(house3[0].position.X - (i * 1990 * 5f), 760, 24750), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }
            for (int i = 0; i < numberofhouses3; i++)
            {
                house10[0] = new staticmesh(Content, "houseE_mesh", 1000f, new Vector3(30010, ground[0].position.Y + 725, 30750), new Vector3(0, 0, 0), true);
                house10[i] = new staticmesh(Content, "houseE_mesh", 1000f, new Vector3(house3[0].position.X - (i * 2110 * 5f), 760, 30750), new Vector3(0, MathHelper.ToRadians(180), 0), true);
            }



            for (int i = 0; i < numberofshops; i++)
                shop[0] = new staticmesh(Content, "cornershop_mesh", 1000f, new Vector3(30850, 4560, -22222), new Vector3(0, 0, 0), true);

            shop[1] = new staticmesh(Content, "cornershop_mesh", 1000f, new Vector3(-29840, 4560, -22022), new Vector3(0, MathHelper.ToRadians(180), 0), true);

            church[0] = new staticmesh(Content, "church_mesh", 1000f, new Vector3(-26750, 560, 0), new Vector3(0, MathHelper.ToRadians(90), 0), true);
            //       church[1] = new staticmesh(Content, "church_mesh", 1000f, new Vector3(-216750, 360, 0), new Vector3(0, MathHelper.ToRadians(90), 0));


            shop2[0] = new staticmesh(Content, "shop_mesh", 985f, new Vector3(14860, 350, -26400), new Vector3(0, 0, 0), true);
            shop2[1] = new staticmesh(Content, "shop_mesh", 985f, new Vector3(-10390, 560, -26400), new Vector3(0, 0, 0), true);
            shop3[0] = new staticmesh(Content, "shop_mesh", 650f, new Vector3(4685, 560, -27500), new Vector3(0, 0, 0), true);
            shop3[1] = new staticmesh(Content, "shop_mesh", 650, new Vector3(-290, 560, -27500), new Vector3(0, 0, 0), true);

            for (int i = 0; i < 14; i++)// creats and positions lampost
            {

                {
                    lamppost[0] = new staticmesh(Content, "lamppost", 30,
                                  new Vector3(31710, 1860, -54020),
                                      new Vector3(0, MathHelper.ToRadians(270), 0), true);

                    lamppost[i] = new staticmesh(Content, "lamppost", 30,
                                    new Vector3(lamppost[0].position.X - (i * 1010 * 5f), 1860, -54020),
                                        new Vector3(0, MathHelper.ToRadians(270), 0), true);


                    //tree[i].position.Y = tree[i].size * 40;
                }
            }



            //for (int i = 13; i < numberoftrees; i++)
            //{
            //    lamppost[i] = new staticmesh(Content, "lamppost", 30f, new Vector3(lamppost[0].position.X - (i * 1010 * 5f), 460, -54020), new Vector3(0, 0, 0));
            //    lamppost[i].position.Y = lamppost[i].size * 40;
            //}


            for (int i = 0; i < 9; i++)
            {
                leftwall[i] = new staticmesh(Content, "wall", 10f, new Vector3(-30000, 460, -70000), new Vector3(0, 0, 0), true);
                leftwall[i] = new staticmesh(Content, "wall", 10f, new Vector3(leftwall[0].position.X + i * 8000, 460, -60000), new Vector3(0, 0, 0), true);
                leftwall[i].rotation = new Vector3(0, MathHelper.ToRadians(90), 0);
            }

            for (int i = 9; i < numberofleftwalls; i++)
            {
                leftwall[9] = new staticmesh(Content, "wall", 10f, new Vector3(-30000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[10] = new staticmesh(Content, "wall", 10f, new Vector3(-22000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[11] = new staticmesh(Content, "wall", 10f, new Vector3(-14000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[12] = new staticmesh(Content, "wall", 10f, new Vector3(-6000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[13] = new staticmesh(Content, "wall", 10f, new Vector3(2000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[14] = new staticmesh(Content, "wall", 10f, new Vector3(10000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[15] = new staticmesh(Content, "wall", 10f, new Vector3(18000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[16] = new staticmesh(Content, "wall", 10f, new Vector3(26000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[17] = new staticmesh(Content, "wall", 10f, new Vector3(32000, 460, 40000), new Vector3(0, MathHelper.ToRadians(90), 0), true);
                leftwall[i].rotation = new Vector3(0, MathHelper.ToRadians(90), 0);
            }



            for (int i = 0; i < 15; i++)
            {
                rightwall[0] = new staticmesh(Content, "wall", 10f, new Vector3(-34000, 460, -56000), new Vector3(0, 0, 0), true);

                rightwall[i] = new staticmesh(Content, "wall", 10f, new Vector3(-34000, 460, rightwall[0].position.Z + i * 8000), new Vector3(0, 0, 0), true);
            }


            rightwall[15] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, -56000), new Vector3(0, 0, 0), true);
            rightwall[16] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, -48000), new Vector3(0, 0, 0), true);
            rightwall[17] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, -40000), new Vector3(0, 0, 0), true);
            rightwall[18] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, -32000), new Vector3(0, 0, 0), true);
            rightwall[19] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, -24000), new Vector3(0, 0, 0), true);
            rightwall[20] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, -16000), new Vector3(0, 0, 0), true);
            rightwall[21] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, -8000), new Vector3(0, 0, 0), true);
            rightwall[22] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 0), new Vector3(0, 0, 0), true);
            rightwall[23] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 8000), new Vector3(0, 0, 0), true);
            rightwall[24] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 16000), new Vector3(0, 0, 0), true);
            rightwall[25] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 24000), new Vector3(0, 0, 0), true);
            rightwall[26] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 32000), new Vector3(0, 0, 0), true);
            rightwall[27] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 40000), new Vector3(0, 0, 0), true);
            rightwall[28] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 48000), new Vector3(0, 0, 0), true);
            rightwall[29] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 56000), new Vector3(0, 0, 0), true);
            rightwall[30] = new staticmesh(Content, "wall", 10f, new Vector3(35000, 460, 56000), new Vector3(0, 0, 0), true);



            for (int count = 0; count < leftwall.Length; count++)// creatrs a bounding box around the object
            {
                leftwall[count].bboxsize = new Vector3(4000, 1000, 100);
                leftwall[count].updateobject();
            }
            for (int count = 0; count < rightwall.Length; count++)
            {
                rightwall[count].bboxsize = new Vector3(100, 1000, 4000);
                rightwall[count].updateobject();
            }
            for (int count = 0; count < house1.Length; count++)
            {
                house1[count].bboxsize = new Vector3(2200, 6000, 2570);
                house1[count].updateobject();
            }
            for (int count = 0; count < house2.Length; count++)
            {
                house2[count].bboxsize = new Vector3(2700, 6000, 2700);
                house2[count].updateobject();
            }
            for (int count = 0; count < house3.Length; count++)
            {
                house3[count].bboxsize = new Vector3(2700, 6000, 2700);
                house3[count].updateobject();
            }
            for (int count = 0; count < house4.Length; count++)
            {
                house4[count].bboxsize = new Vector3(2090, 6000, 2650);
                house4[count].updateobject();
            }
            for (int count = 0; count < house5.Length; count++)
            {
                house5[count].bboxsize = new Vector3(2090, 6000, 2650);
                house5[count].updateobject();
            }
            for (int count = 0; count < house6.Length; count++)
            {
                house6[count].bboxsize = new Vector3(2090, 6000, 2650);
                house6[count].updateobject();
            }
            for (int count = 0; count < house7.Length; count++)
            {
                house7[count].bboxsize = new Vector3(2090, 6000, 2650);
                house7[count].updateobject();
            }
            for (int count = 0; count < house8.Length; count++)
            {
                house8[count].bboxsize = new Vector3(4080, 6000, 6000);
                house8[count].updateobject();
            }
            for (int count = 0; count < house9.Length; count++)
            {
                house9[count].bboxsize = new Vector3(1480, 4000, 160);
                house9[count].updateobject();
            }
            for (int count = 0; count < house8.Length; count++)
            {
                house10[count].bboxsize = new Vector3(480, 6000, 660);
                house10[count].updateobject();
            }

            for (int count = 0; count < shop.Length; count++)
            {
                shop[count].bboxsize = new Vector3(4090, 6000, 4050);
                shop[count].updateobject();
            }
            for (int count = 0; count < shop2.Length; count++)
            {
                shop2[count].bboxsize = new Vector3(2120, 6000, 3280);
                shop2[count].updateobject();
            }
            for (int count = 0; count < shop3.Length; count++)
            {
                shop3[count].bboxsize = new Vector3(1400, 6000, 2165);
                shop3[count].updateobject();
            }
            for (int count = 0; count < church.Length; count++)
            {
                church[count].bboxsize = new Vector3(6540, 6000, 3050);
                church[count].updateobject();
            }
            for (int count = 0; count < car.Length; count++)
            {
                car[count].bboxsize = new Vector3(6540, 6000, 3050);
                car[count].updateobject();
            }
            for (int count = 0; count < barrel.Length; count++)
            {
                barrel[count].bboxsize = new Vector3(6540, 6000, 3050);
                barrel[count].updateobject();
            }
            for (int count = 0; count < tree1.Length; count++)
            {
                tree1[count].bboxsize = new Vector3(100, 6000, 100);
                tree1[count].updateobject();
            }
            for (int count = 0; count < tree2.Length; count++)
            {
                tree2[count].bboxsize = new Vector3(100, 6000, 100);
                tree2[count].updateobject();
            }
            for (int count = 0; count < horse.Length; count++)
            {
                horse[count].bboxsize = new Vector3(130, 6000, 670);
                horse[count].updateobject();
            }
            for (int count = 0; count < mark.Length; count++)
            {
                mark[count].bboxsize = new Vector3(500, 1000, 500);
                mark[count].updateobject();
            }

            for (int count = 0; count < robot.Length; count++)
            {
                robot[count].bboxsize = new Vector3(100, 300, 100);
                robot[count].updateobject();
            }
            for (int count = 0; count < ibsphere.Length; count++)
            {
                ibsphere[count].bboxsize = new Vector3(400, 300, 400);
                ibsphere[count].updateobject();
            }

            moveplayer = Content.Load<SoundEffect>("LASER19");// loads player sound effect
            playermove = moveplayer.CreateInstance();// creats sound track of sound effect
            playermove.IsLooped = true;// repeats trck
            playermove.Volume = 0.2f;// set the volume to 0.2
            track = Content.Load<SoundEffect>("explosion");
            music = track.CreateInstance();
            music.IsLooped = true;
            music.Volume = 0.2f;
            jump = Content.Load<SoundEffect>("TALK");
            moan = Content.Load<SoundEffect>("zombiemaon");
            moaned = moan.CreateInstance();
            moaned.IsLooped = false;
            moaned.Volume = 0.5f;



        }
Esempio n. 9
0
        //public void checkcollisionehite(model3d mesh)// used to check for collsion between robot and meshes 
        //{
 
        //    for (int count = 0; count < numberofenemys; count++)
        //        for (int i = 0; i < numberofenemys; i++)

       
        //        //for (int i = 0; i < numberofhouses; i++)
        //        if (enemy[i].bsphere.Intersects(mesh.bbox))
        //        {
        //            enemy[i].position.X = enemy[i].position.X;
        //            enemy[i].position.Y = enemy[i].position.Y;
        //            enemy[i].position.Z = enemy[i].position.Z;

        //            enemy[i].velocity.X = -enemy[i].velocity.X;
        //            enemy[i].velocity.Y = -enemy[i].velocity.Y;
        //            enemy[i].velocity.Z = -enemy[i].velocity.Z;
        //            enemy[i].position = enemy[i].oldposition;
        //        }
        //        else
        //        {
        //            enemy[i].oldposition = enemy[i].position;
        //        }

        //}

        public void checkenemycollisionmesh(staticmesh mesh)// used to check for colliosn between enmies and meshes
        {
            for (int i = 0; i < numberofenemys; i++)
                //for (int i = 0; i < numberofhouses; i++)
                if (enemy[i].bsphere.Intersects(mesh.bbox))
                {
                    //enemy[i].position.X = mesh.position.X;
                    //enemy[i].position.Y = mesh.position.Y;
                    //enemy[i].position.Z = mesh.position.Z;

                    enemy[i].velocity.X = -enemy[i].velocity.X;
                    enemy[i].velocity.Y = -enemy[i].velocity.Y;
                    enemy[i].velocity.Z = -enemy[i].velocity.Z;

                    if (enemy[i].velocity.Length() < 20)  // If the enemy has been chasing player then its velocity might be low so we reset it.
                    {
                        enemy[i].velocity.Normalize();
                        enemy[i].velocity *= 30;
                    }
                    enemy[i].position = enemy[i].oldposition;
             
                }
                else
                {
                    enemy[i].oldposition = enemy[i].position;
                }

        }
        public void automove(staticmesh rightside, staticmesh bottomwall, model3d enemybot, Vector3 rot)
        {
            if (visible)
            {
                if (MathHelper.ToDegrees(rotation.Y) >= 360) rotation.Y = 0;
                if (MathHelper.ToDegrees(rotation.Y) < 0) rotation.Y = MathHelper.ToRadians(359);

                velocity.X += 50;

                // Work out the direction R2 is facing
                direction.Z = (float)(Math.Cos(rotation.Y));
                direction.X = (float)(Math.Sin(rotation.Y));
                if (enemybot.bsphere.Intersects(rightside.bbox))
                {
                    velocity.X = -velocity.X;
                }
                //if (enemybot.bsphere.Intersects(rightside.bbox))
                //{
                //    velocity.X = -velocity.X;
                //}
                if (enemybot.bsphere.Intersects(bottomwall.bbox))
                {
                    velocity.Z = -velocity.Z;
                }
                //if (enemybot.bsphere.Intersects(bottomwall.bbox))
                //{
                //    velocity.Z = -velocity.Z;
                //}

                position += velocity;
            }
        }
Esempio n. 11
0
 void spawnzombie(int zombienumber, float zposition)
 {
     zombies[zombienumber] = new staticmesh(Content, "zombie", 3f,
         new Vector3(randomiser.Next(1600) - 800, 0, randomiser.Next(10000, 50000) + zposition),
             new Vector3(0, 0, 0), new Vector3(0, 0, -(randomiser.Next(10, 50))));
     
     zombies[zombienumber].bboxsize = new Vector3(50, 300, 50);
     zombies[zombienumber].updateobject();
 }
Esempio n. 12
0
        void reset()
        {
            gameover = false;

            gameruntime = 0;
            score = 0;
            health = 6;

            playerchar.position = new Vector3(0, 0, 0);
            playerchar.rotation = new Vector3(0, 0, 0);



            // Load the 3D models for the static objects in the game from the ContentManager
            for (int i = 0; i < numberofgrounds; i++)
            {
                ground[i] = new staticmesh(Content, "groundaxa", 10f, new Vector3(0, -40, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 0));
                if (i > 0)
                    ground[i].position.Z += ground[i - 1].position.Z + 800 * ground[i - 1].size;
            }

            for (int i = 0; i < numberofbullets; i++)
            {
                playerbullet[i] = new staticmesh(Content, "bullet", 1f, new Vector3(playerchar.position.X, playerchar.position.Y, playerchar.position.Z),
                    new Vector3(0, 0, 0), new Vector3(0, 0, 0));
                playerbullet[i].radius = 30;
                playerbullet[i].visible = false;

            }


            for (int i = 0; i < numberofwalls; i++)
            {
                leftwall[i] = new staticmesh(Content, "wallaxa", 10f, new Vector3(-1000, -100, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 0));
                rightwall[i] = new staticmesh(Content, "wallaxa", 10f, new Vector3(1000, -100, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 0));
                if (i > 0)
                {
                    leftwall[i].position.Z += leftwall[i - 1].position.Z + 800 * leftwall[i - 1].size;
                    rightwall[i].position.Z = leftwall[i].position.Z;
                }
            }

            for (int i = 0; i < numberofzombs; i++)
            {
                spawnzombie(i, 1000);
                zombies[i].bboxsize = new Vector3(50, 300, 50);
                zombies[i].updateobject();
            }


        }
Esempio n. 13
0
        void reset()
        {
            gameover = false;
            gameruntime = 0;
            score = 0;

            // Initialise robot1 object
            robot = new model3d(Content, "r2d2v2", 2f, new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.002f, 0.06f, 10);

            // Load the 3D models for the static objects in the game from the ContentManager
            for (int i = 0; i < numberofgrounds; i++)
            {
                ground[i] = new staticmesh(Content, "long_ground", 10f, new Vector3(0, -40, 0), new Vector3(0, 0, 0));
                if (i > 0)
                    ground[i].position.Z += ground[i - 1].position.Z + 800 * ground[i - 1].size;
            }

            for (int i = 0; i < numberofwalls; i++)
            {
                leftwall[i] = new staticmesh(Content, "wall", 10f, new Vector3(-1000, -40, 0), new Vector3(0, 0, 0));
                rightwall[i] = new staticmesh(Content, "wall", 10f, new Vector3(1000, -40, 0), new Vector3(0, 0, 0));
                if (i > 0)
                {
                    leftwall[i].position.Z += leftwall[i - 1].position.Z + 800 * leftwall[i - 1].size;
                    rightwall[i].position.Z = leftwall[i].position.Z;
                }
            }

            for (int i = 0; i < numberoftrees; i++)
            {
                if (i % 2 == 0)
                    tree[i] = new staticmesh(Content, "tree", (float)(randomiser.Next(20) + 1) / 10,
                                    new Vector3(randomiser.Next(1600) - 800, 0, randomiser.Next(40000) + 1000),
                                        new Vector3(0, randomiser.Next(7), 0));
                else
                {
                    tree[i] = new staticmesh(Content, "lamppost", (float)(randomiser.Next(20) + 1) / 3,
                                    new Vector3(randomiser.Next(1600) - 800, 0, randomiser.Next(40000) + 1000),
                                        new Vector3(0, randomiser.Next(7), 0));
                    tree[i].position.Y = tree[i].size * 40;
                }
            }

        }