Ejemplo n.º 1
0
        public Level deepcopy()
        {
            Enemy[] Enemiescopy = new Enemy[Enemies.Length];
            // Make a clone army
            for (int i = 0; i < Enemies.Length; i++)
            {
                // Pick the current enemy to clone
                Enemy goon = Enemies[i];
                if (goon != null)
                {
                    Enemiescopy[i] = goon.deepcopy();
                }
                else
                {
                    Enemiescopy[i] = null;
                }
            }
            Checkpoint[] Checkpointscopy = new Checkpoint[Checkpoints.Length];
            for (int i = 0; i < Checkpoints.Length; i++)
            {
                Checkpoint c = Checkpoints[i];
                if (c != null)
                {
                    Vector2    tempo     = new Vector2(c.origin.X, c.origin.Y);
                    Vector2    tempos    = new Vector2(c.position.X, c.position.Y);
                    Checkpoint tempcheck = new Checkpoint(c.off, c.on, tempo, tempos);
                    Checkpointscopy[i] = tempcheck;
                }
                else
                {
                    Checkpointscopy[i] = null;
                }
            }
            Surface[] Trackscopy = new Surface[Tracks.Length];
            for (int i = 0; i < Tracks.Length; i++)
            {
                Surface t = Tracks[i];
                if (t != null)
                {
                    Trackscopy[i] = t.deepcopy();
                }
                else
                {
                    Trackscopy[i] = null;
                }
            }
            Scene[] Backgroundscopy = new Scene[Backgrounds.Length];
            for (int i = 0; i < Backgrounds.Length; i++)
            {
                Scene s = Backgrounds[i];
                if (s != null)
                {
                    Backgroundscopy[i] = new Scene(Backgrounds[i].image, new Vector2(s.position.X, s.position.Y));
                }
                else
                {
                    Backgroundscopy[i] = null;
                }
            }
            Scene[] Foregroundscopy = new Scene[Foregrounds.Length];
            for (int i = 0; i < Foregrounds.Length; i++)
            {
                Scene s = Foregrounds[i];
                if (s != null)
                {
                    Foregroundscopy[i] = new Scene(Foregrounds[i].image, new Vector2(s.position.X, s.position.Y));
                }
                else
                {
                    Foregroundscopy[i] = null;
                }
            }
            Fuel[] Fuelscopy = new Fuel[Fuels.Length];
            for (int i = 0; i < Foregrounds.Length; i++)
            {
                Fuel f = Fuels[i];
                if (f != null)
                {
                    Fuelscopy[i] = f.deepcopy();
                }
                else
                {
                    Fuelscopy[i] = null;
                }
            }

            Level copy = new Level(Backgroundscopy, Foregroundscopy, Enemiescopy, Checkpointscopy, Trackscopy, Fuelscopy);

            copy.mostrecent = mostrecent;

            return(copy);
        }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            player1   = Content.Load <Texture2D>("images/minecart1");
            player2   = Content.Load <Texture2D>("images/minecart2");
            playerori = new Vector2(26, 20);
            player    = new Player(player1, playerori, stagevelocity);

            lvl1background1pos   = new Vector2(200, -150);
            lvl1background1image = Content.Load <Texture2D>("images/lvl1background1");
            //lvl1background1 = new Scene(lvl1background1image, lvl1background1pos);
            lvl1background2pos   = new Vector2(460, -150);
            lvl1background2image = Content.Load <Texture2D>("images/lvl1background2");
            //lvl1background2 = new Scene(lvl1background2image, lvl1background2pos);

            lvl1foreground1image = Content.Load <Texture2D>("images/lvl1foreground1");
            lvl1foreground1pos   = new Vector2(1008, 470);
            //lvl1foreground1 = new Scene(lvl1foreground1image, lvl1foreground1pos);

            //Texture2D longtrack =
            Texture2D emptylongtrack = Content.Load <Texture2D>("images/emptylongtrack");
            Texture2D slanttrack     = Content.Load <Texture2D>("images/4Slantmod");
            // lvl1track.alpha = -.2f;
            // lvl1track.acceleration = new Vector2(0, -.8f);
            Texture2D curve = Content.Load <Texture2D>("images/curvetoflat"); // slanttocurve x:+164 y:158-
            Texture2D cart  = Content.Load <Texture2D>("images/enemy");
            Texture2D fuel  = Content.Load <Texture2D>("images/Fuel");

            //Curves have to come before Slants

            lvl1track1ori   = new Vector2(0, 8);
            lvl1track1pos   = new Vector2(-824, 550);
            lvl1track1image = Content.Load <Texture2D>("images/1470track");
            lvl1track1      = new Surface(lvl1track1image, lvl1track1ori, lvl1track1pos);

            lvl1track2ori   = new Vector2(0, 8);
            lvl1track2pos   = new Vector2(720, 600);
            lvl1track2image = Content.Load <Texture2D>("images/416track");
            lvl1track2      = new Surface(lvl1track2image, lvl1track2ori, lvl1track2pos);

            lvl1track3ori   = new Vector2(0, 8);
            lvl1track3pos   = new Vector2(1280, 600);
            lvl1track3image = Content.Load <Texture2D>("images/416track");
            lvl1track3      = new Surface(lvl1track3image, lvl1track3ori, lvl1track3pos);

            lvl1track4ori   = new Vector2(0, 8);
            lvl1track4pos   = new Vector2(842, 814);//814
            lvl1track4image = Content.Load <Texture2D>("images/1470track");
            lvl1track4      = new Surface(lvl1track4image, lvl1track4ori, lvl1track4pos);

            lvl1track5ori           = new Vector2(0, 4);
            lvl1track5pos           = new Vector2(1696, 600);
            lvl1track5image         = Content.Load <Texture2D>("images/shortslantdown");
            lvl1track5              = new Surface(lvl1track5image, lvl1track5ori, lvl1track5pos);
            lvl1track5.alpha        = .02f;
            lvl1track5.acceleration = new Vector2(0, .33f);
            lvl1track5.max          = 5;
            lvl1track5.enemy        = false;

            lvl1track6ori           = new Vector2(0, 218);
            lvl1track6pos           = new Vector2(1696, 814);//814
            lvl1track6image         = Content.Load <Texture2D>("images/shortslantdown");
            lvl1track6              = new Surface(lvl1track6image, lvl1track6ori, lvl1track6pos);
            lvl1track6.alpha        = .0025f;
            lvl1track6.acceleration = new Vector2(0, -.061f);
            lvl1track6.player       = false;
            lvl1track6.max          = -2;

            lvl1track7ori           = new Vector2(0, 4);
            lvl1track7pos           = new Vector2(2300, 814);
            lvl1track7image         = Content.Load <Texture2D>("images/shortslantdown");
            lvl1track7              = new Surface(lvl1track7image, lvl1track7ori, lvl1track7pos);
            lvl1track7.alpha        = .02f;
            lvl1track7.acceleration = new Vector2(0, .33f);
            lvl1track7.max          = 5;
            lvl1track7.enemy        = false;

            lvl1enemy1ori   = new Vector2(23, 26);
            lvl1enemy1pos   = new Vector2(2000, 800);
            lvl1enemy1vel   = new Vector2(-2, 0);
            lvl1enemy1image = cart;
            lvl1enemy1      = new Enemy(lvl1enemy1image, lvl1enemy1ori, lvl1enemy1pos, lvl1enemy1vel);
            lvl1enemy2ori   = new Vector2(23, 26);
            lvl1enemy2pos   = new Vector2(2050, 800);
            lvl1enemy2vel   = new Vector2(-2, 0);
            lvl1enemy2image = cart;
            lvl1enemy2      = new Enemy(lvl1enemy2image, lvl1enemy2ori, lvl1enemy2pos, lvl1enemy2vel);

            checkpointori      = new Vector2(5, 20);
            lvl1checkpoint1pos = new Vector2(800, 600);
            checkpointoff      = Content.Load <Texture2D>("images/checkpointoff");
            checkpointon       = Content.Load <Texture2D>("images/checkpointon");
            lvl1checkpoint1    = new Checkpoint(checkpointoff, checkpointon, checkpointori, lvl1checkpoint1pos);

            lvl1fuel1pos = new Vector2(-100, 525);
            lvl1fuel1    = new Fuel(fuel, lvl1fuel1pos);
            lvl1fuel2pos = new Vector2(-50, 525);
            lvl1fuel2    = new Fuel(fuel, lvl1fuel2pos);
            lvl1fuel3pos = new Vector2(0, 525);
            lvl1fuel3    = new Fuel(fuel, lvl1fuel3pos);
            lvl1fuel4pos = new Vector2(50, 525);
            lvl1fuel4    = new Fuel(fuel, lvl1fuel4pos);

            lvl1backgrounds[0] = lvl1background1;
            lvl1backgrounds[1] = lvl1foreground1;
            lvl1tracks[0]      = lvl1track1;
            lvl1tracks[1]      = lvl1track2;
            lvl1tracks[2]      = lvl1track3;
            lvl1tracks[3]      = lvl1track4;
            lvl1tracks[4]      = lvl1track5;
            lvl1tracks[5]      = lvl1track6;
            lvl1tracks[6]      = lvl1track7;
            //lvl1enemies[0] = lvl1enemy1;
            //lvl1enemies[1] = lvl1enemy2;
            lvl1checkpoints[0] = lvl1checkpoint1;
            //lvl1fuels[0] = lvl1fuel1;
            //lvl1fuels[1] = lvl1fuel2;
            //lvl1fuels[2] = lvl1fuel3;
            //lvl1fuels[3] = lvl1fuel4;

            lvl1 = new Level(lvl1backgrounds, lvl1foregrounds, lvl1enemies, lvl1checkpoints, lvl1tracks, lvl1fuels);

            lvls[0] = lvl1;

            stage = lvls[currentlevel];

            save(stage.Checkpoints[0]);

            debugspot = Content.Load <Texture2D>("images/debug");
            dothis    = Content.Load <Texture2D>("images/dothis");
        }