public ScreenSolarSystem(Game1 game, BackgroundScrollable background)
     : base(game, background)
 {
     rocket      = new Rocket(game, new Animation(game.textureRocket, 68, 126), background.bgAnimation.displayWidth / 2, background.bgAnimation.displayHeight / 2);
     listPlanets = new List <Planet>();
     InitPlanets();
 }
Esempio n. 2
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            BackgroundScrollable backgroundScrollable = (BackgroundScrollable)this.background;

            backgroundScrollable.Draw(gameTime, spriteBatch);

            spriteBatch.DrawString(game.arialFont, "Visited:" + visited / listPlanets.Count, Vector2.Zero, Color.Red);

            Rectangle currRectangle;
            Animation animation;
            Point     topLeftBG = backgroundScrollable.GetTopLeftCoordinate();

            foreach (Planet planet in listPlanets)
            {
                animation     = planet.animation;
                currRectangle = new Rectangle(planet.centerX - animation.displayWidth / 2, planet.centerY - animation.displayHeight / 2, animation.displayWidth, animation.displayHeight);
                if (backgroundScrollable.IsRectangleWithinVisibility(currRectangle))
                {
                    planet.Draw(gameTime, spriteBatch, (int)topLeftBG.X, (int)topLeftBG.Y, backgroundScrollable.scale);
                    if (planet.Intersects(rocket, topLeftBG.X, topLeftBG.Y, backgroundScrollable.scale))
                    {
                        buttonEnterPlanet.Draw(gameTime, spriteBatch);
                    }
                }
            }

            rocket.Draw(gameTime, spriteBatch);
        }
Esempio n. 3
0
        public override void Update(GameTime gameTime, TouchCollection touchCollection)
        {
            ProcessTouch(gameTime, touchCollection);
            BackgroundScrollable bgs = (BackgroundScrollable)this.background;
            Point topLeftBG          = bgs.GetTopLeftCoordinate();

            foreach (Planet planet in listPlanets)
            {
                if (planet.Intersects(rocket, (int)topLeftBG.X, (int)topLeftBG.Y, bgs.scale))
                {
                    if (touchCollection.Count > 0)
                    {
                        TouchLocation touch = touchCollection[0];
                        if (touch.State == TouchLocationState.Pressed)
                        {
                            if (buttonEnterPlanet.IsPressed((int)touch.Position.X, (int)touch.Position.Y))
                            {
                                if (!planet.isVisited)
                                {
                                    visited++;
                                    planet.isVisited = true;
                                }
                                if (planet.name.Equals("Mercury"))
                                {
                                    NextScreen = game.GetNewScreenMercury();
                                }
                                else if (planet.name.Equals("Venus"))
                                {
                                    NextScreen = game.GetNewScreenVenus();
                                }
                                else if (planet.name.Equals("Earth"))
                                {
                                    NextScreen = game.GetNewScreenEarth();
                                }
                                else if (planet.name.Equals("Mars"))
                                {
                                    NextScreen = game.GetNewScreenMars();
                                }
                                else if (planet.name.Equals("Jupiter"))
                                {
                                    NextScreen = game.GetNewScreenJupiter();
                                }
                                else if (planet.name.Equals("Saturn"))
                                {
                                    NextScreen = game.GetNewScreenSaturn();
                                }
                                else if (planet.name.Equals("Uranus"))
                                {
                                    NextScreen = game.GetNewScreenUranus();
                                }
                                else if (planet.name.Equals("Neptune"))
                                {
                                    NextScreen = game.GetNewScreenNeptune();
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public ScreenSolarSystem(Game1 game, BackgroundScrollable background)
            : base(game, background)
        {
            int rocketWidth = (int)(0.5 * 80);

            rocket      = new Rocket(game, new Animation(game.textureRocket, rocketWidth, rocketWidth * 126 / 68), background.bgAnimation.displayWidth / 2, background.bgAnimation.displayHeight / 2);
            listPlanets = new List <Planet>();
            InitPlanets();
            accelerometer     = new Accelerometer();
            buttonEnterPlanet = new Button(new Animation(game.textureButtonEnterPlanet, 100, 50), "enterPlanet", 10, 10);
        }
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            BackgroundScrollable backgroundScrollable = (BackgroundScrollable)this.background;

            backgroundScrollable.Draw(gameTime, spriteBatch);
            rocket.Draw(gameTime, spriteBatch);

            Rectangle currRectangle;
            Animation animation;
            Point     topLeftBG = backgroundScrollable.GetTopLeftCoordinate();

            foreach (Planet planet in listPlanets)
            {
                animation     = planet.animation;
                currRectangle = new Rectangle(planet.centerX - animation.displayWidth / 2, planet.centerY - animation.displayHeight / 2, animation.displayWidth, animation.displayHeight);
                if (backgroundScrollable.IsRectangleWithinVisibility(currRectangle))
                {
                    planet.Draw(gameTime, spriteBatch, (int)topLeftBG.X, (int)topLeftBG.Y, backgroundScrollable.scale);
                }
            }
        }