Пример #1
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);
            AwesomeAsteroid = ObjModelLoader.LoadFromFile("Models/rock.obj");
            asteroid = Texture2D.FromFile(graphics.GraphicsDevice,"Models/rock.jpg",256,256);

            gamePadTexture = Content.Load<Texture2D> ("gamepad.png");
            var ship1t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship.pdf";
            var ship2t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship-thrust.pdf";
            var ship1 = Texture2D.FromFile(graphics.GraphicsDevice,ship1t,35,35);
            var ship2 = Texture2D.FromFile(graphics.GraphicsDevice,ship2t,35,35);
            ship = new Ship (ship1,ship2);
            //ship.Scale = .05f;
            bullet = new Sprite (Content.Load<Texture2D> ("shot-frame1"));
            //bullet.Scale = .05f;
            ReloadAsteroids();

            myFont = Content.Load<SpriteFont> ("Fonts/SpriteFont1");

            banner = Content.Load<Texture2D> ("BANNER");

            var gamePadH = ScreenHeight - 100;
            var gamePadLeft = ScreenWidth -80;
            //Console.WriteLine (gamePadH);
            // Set the virtual GamePad
            ButtonDefinition BButton = new ButtonDefinition ();
            BButton.Texture = gamePadTexture;
            BButton.Position = new Vector2 (gamePadLeft, gamePadH + 10);
            BButton.Type = Buttons.B;
            BButton.TextureRect = new Rectangle (72, 77, 36, 36);

            ButtonDefinition AButton = new ButtonDefinition ();
            AButton.Texture = gamePadTexture;
            AButton.Position = new Vector2 (gamePadLeft - 75, gamePadH + 10);
            AButton.Type = Buttons.A;
            AButton.TextureRect = new Rectangle (73, 114, 36, 36);

            GamePad.ButtonsDefinitions.Add (BButton);
            GamePad.ButtonsDefinitions.Add (AButton);

            ThumbStickDefinition thumbStick = new ThumbStickDefinition ();
            thumbStick.Position = new Vector2 (50, gamePadH);
            thumbStick.Texture = gamePadTexture;
            thumbStick.TextureRect = new Rectangle (2, 2, 68, 68);

            GamePad.LeftThumbStickDefinition = thumbStick;
        }
Пример #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        public override void LoadContent()
        {
            ScreenWidth = ScreenManager.Width;
            ScreenHeight = ScreenManager.Height;
            gameType = Settings.GameType;
            useAccel = Settings.UseAccel;
            if (Content == null)
                Content = new ContentManager (ScreenManager.Game.Services, "Content");
            // Create a new SpriteBatch, which can be used to draw textures.
            //spriteBatch = ScreenManager.SpriteBatch;
            //AwesomeAsteroid = ObjModelLoader.LoadFromFile ("Models/rock.obj");
            //asteroid = Texture2D.FromFile (ScreenManager.GraphicsDevice, "Models/rock.jpg", 256, 256);
            pauseButtonTexture = Content.Load<Texture2D> ("pause.png");
            var ship1t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship.pdf";
            var ship2t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship-thrust.pdf";
            var ship1 = Texture2D.FromFile (ScreenManager.GraphicsDevice, ship1t, 35, 35);
            var ship2 = Texture2D.FromFile (ScreenManager.GraphicsDevice, ship2t, 35, 35);
            ship = new Ship (ship1, ship2);
            freeManSprite = new Sprite (ship2);
            //ship.Scale = .05f;
            bullet = new Sprite (Content.Load<Texture2D> ("shot-frame1"));
            //bullet.Scale = .05f;
            ReloadAsteroids ();

            myFont = Content.Load<SpriteFont> ("Fonts/SpriteFont1");

            alienFired = ScreenManager.Game.Content.Load<SoundEffect> ("fire");
            alienDied = ScreenManager.Game.Content.Load<SoundEffect> ("Alien_Hit");
            playerFired = ScreenManager.Game.Content.Load<SoundEffect> ("fire");
            playerDied = ScreenManager.Game.Content.Load<SoundEffect> ("Player_Hit");

            //Console.WriteLine (gamePadLeft);
            // Set the virtual GamePad
            GamePad.ButtonsDefinitions.Clear ();
            var gamePadH = ScreenHeight - 100;
            var gamePadLeft = ScreenWidth - 80;

            ButtonDefinition XButton = new ButtonDefinition ();
            XButton.Texture = pauseButtonTexture;
            XButton.Position = new Vector2 (gamePadLeft, 0 + 10 + (int)myFont.FontSize + 10);
            XButton.Type = Buttons.X;
            XButton.TextureRect = new Rectangle (0, 0, 30, 30);
            GamePad.ButtonsDefinitions.Add (XButton);

            if (!useAccel) {
                //Setup the controller if they are not using the accelerometer
                gamePadTexture = Content.Load<Texture2D> ("gamepad.png");
                //leftButtonTexture = Content.Load<Texture2D>("leftArrow.png");
                //rightButtonTexture = Content.Load<Texture2D>("rightArrow.png");
                //upButtonTexture = Content.Load<Texture2D>("upArrow.png");
                //ButtonDefinition left = new ButtonDefinition();
                //Console.WriteLine (gamePadH);
                // Set the virtual GamePad
                                /*
                ButtonDefinition BButton = new ButtonDefinition ();
                BButton.Texture = gamePadTexture;
                BButton.Position = new Vector2 (gamePadLeft, gamePadH + 10);
                BButton.Type = Buttons.B;
                BButton.TextureRect = new Rectangle (72, 77, 36, 36);

                ButtonDefinition AButton = new ButtonDefinition ();
                AButton.Texture = gamePadTexture;
                AButton.Position = new Vector2 (gamePadLeft - 75, gamePadH + 10);
                AButton.Type = Buttons.A;
                AButton.TextureRect = new Rectangle (73, 114, 36, 36);

                ButtonDefinition LeftButton = new ButtonDefinition();
                LeftButton.Texture = leftButtonTexture;
                LeftButton.Position = new Vector2(50,gamePadH);
                LeftButton.Type = Buttons.DPadLeft;
                LeftButton.TextureRect = new Rectangle(0,0,40,40);

                ButtonDefinition RightButton = new ButtonDefinition();
                RightButton.Texture = rightButtonTexture;
                RightButton.Position = new Vector2(50 + 40 +4,gamePadH);
                RightButton.Type = Buttons.DPadRight;
                RightButton.TextureRect = new Rectangle(0,0,40,40);

                ButtonDefinition UpButton = new ButtonDefinition();
                UpButton.Texture = upButtonTexture;
                UpButton.Position = new Vector2(50 + 22,gamePadH - 44);
                UpButton.Type = Buttons.DPadUp;
                UpButton.TextureRect = new Rectangle(0,0,40,40);

                GamePad.ButtonsDefinitions.Add(LeftButton);
                GamePad.ButtonsDefinitions.Add(RightButton);
                GamePad.ButtonsDefinitions.Add(UpButton);
                GamePad.ButtonsDefinitions.Add (BButton);
                GamePad.ButtonsDefinitions.Add (AButton);
                */

                ThumbStickDefinition thumbStick = new ThumbStickDefinition ();
                thumbStick.Position = new Vector2 (50, gamePadH);
                thumbStick.Texture = gamePadTexture;
                thumbStick.TextureRect = new Rectangle (2, 2, 68, 68);

                GamePad.LeftThumbStickDefinition = thumbStick;

            } else {
                GamePad.LeftThumbStickDefinition = null;
            }
            SetupGame ();

            if (gameType != GameType.Retro)
                particles = new ParticleSystem (ScreenManager.Game.Content, ScreenManager.SpriteBatch);
            ScreenManager.Game.ResetElapsedTime ();
        }