Ejemplo n.º 1
0
        ///////////////////////////////////////  CONSTRUCTOR  /////////////////////////////////////


        public SoundManager(ContentManager content)
        {
            // INSTANTIATE: the content manager
            myContent = new MyContentManager(content);
            // INSTANTIATE: the list of sounds, giving it a limit of 1
            soundEffects = new List <SoundEffectInstance>(1);
        }
        /// <summary>
        /// Loads graphics content for this screen. The background texture is quite
        /// big, so we use our own local ContentManager to load it. This allows us
        /// to unload before going from the menus into the game itself, wheras if we
        /// used the shared ContentManager provided by the Game class, the content
        /// would remain loaded forever.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new MyContentManager(ScreenManager.Game.Services, "Content");

            backgroundTexture = content.Load<Texture2D>("Textures/background");
        }
Ejemplo n.º 3
0
        public enemy1(Vector2 position, int width, int height, Vector2 velocity, float rotation, Vector2 origin, Vector2 scale, Color color, bool islive)
        {
            _texture       = MyContentManager.GetInstance().LoadContent <Texture2D>("pig1_230x85");
            _idleAnimation = new Animation();
            _idleAnimation.AddFrame(new Rectangle(0, 0, 115, 85), TimeSpan.FromSeconds(.25));
            _idleAnimation.AddFrame(new Rectangle(115, 0, 115, 85), TimeSpan.FromSeconds(.25));
            isTurnright = true;

            _upray    = new Ray2D(new Vector2(position.X + width / 2, position.Y), new Vector2(0, -0.01f));
            _downray  = new Ray2D(new Vector2(position.X + width / 2, position.Y + height), new Vector2(0, 0.01f));
            _rightray = new Ray2D(new Vector2(position.X + width, position.Y + height / 2), new Vector2(0.01f, 0));
            _leftray  = new Ray2D(new Vector2(position.X, position.Y + height / 2), new Vector2(-0.01f, 0));

            _canUp    = true;
            _canDown  = true;
            _canRight = true;
            _canLeft  = true;

            _speed      = 2;
            Health      = 10;
            _isfindHero = false;
            _state      = EnemyPigState.XL;

            changetime  = 2.0f;
            changetimer = 0.0f;
            rushtime    = 0.7f;
            rushtimer   = 0.0f;
            stoptime    = 2.0f;
            stoptimer   = 0.0f;

            rnd    = new Random();
            rndnum = 0;

            EnemySprite = new Sprite(position, width, height, velocity, rotation, origin, scale, color, islive);
        }
Ejemplo n.º 4
0
 public tile1()
 {
     _texture  = MyContentManager.GetInstance().LoadContent <Texture2D>("tile1");
     _tileList = new List <Rectangle>();
     _tileList.Add(new Rectangle(0, 0, 100, 100));
     _tileList.Add(new Rectangle(100, 0, 100, 100));
     _tileList.Add(new Rectangle(200, 0, 100, 100));
 }
Ejemplo n.º 5
0
        public smallGun(Vector2 position, int width, int height, Vector2 velocity, float rotation, Vector2 origin, Vector2 scale, Color color, bool islive)
        {
            _bulletData    = MyContentManager.GetInstance().LoadContent <MyXMLData.BulletData.bullet1_data>("bullet1_data");
            _weaponTexture = MyContentManager.GetInstance().LoadContent <Texture2D>("samllgun");
            WeaponSprite   = new Sprite(position, width, height, velocity, rotation, origin, scale, color, islive);
            var tempx = (float)(WeaponSprite.Width * Math.Cos(WeaponSprite.Rotation));
            var tempy = (float)(WeaponSprite.Width * Math.Sin(WeaponSprite.Rotation));

            _firePosition = WeaponSprite.Position + new Vector2(tempx, tempy);
        }
 public GraphicsProperties(Matrix projectionMatrix,
     Matrix viewMatrix,
     MyContentManager contentManager,
     GraphicsDevice graphicsDevice,
     SpriteBatch spriteBatch,
     RenderTarget2D renderTarget)
 {
     pm = projectionMatrix;
     vm = viewMatrix;
     cm = contentManager;
     gd = graphicsDevice;
     sb = spriteBatch;
     rt = renderTarget;
 }
Ejemplo n.º 7
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = WindowsManager.GetInstance().ScreenWidth;
            graphics.PreferredBackBufferHeight = WindowsManager.GetInstance().ScreenHeight;

            Content.RootDirectory = "Content";
            MyContent             = new MyContentManager(Content);
            MyContent.Instance    = MyContent;



            KeyboardObject.Init();
            GameManager.GetInstance();
        }
Ejemplo n.º 8
0
        public boomEffect1(Vector2 position)
        {
            _position              = position;
            BoomAnimation          = new Animation();
            BoomAnimation.IsLoop   = false;
            BoomAnimation.FrameNum = 5;
            Texture = MyContentManager.GetInstance().LoadContent <Texture2D>("boomEffect1");
            BoomAnimation.AddFrame(new Rectangle(0, 0, 33, 32), TimeSpan.FromSeconds(.15));
            BoomAnimation.AddFrame(new Rectangle(33, 0, 33, 32), TimeSpan.FromSeconds(.15));
            BoomAnimation.AddFrame(new Rectangle(66, 0, 33, 32), TimeSpan.FromSeconds(.15));
            BoomAnimation.AddFrame(new Rectangle(99, 0, 33, 32), TimeSpan.FromSeconds(.15));
            BoomAnimation.AddFrame(new Rectangle(132, 0, 33, 32), TimeSpan.FromSeconds(.15));

            _currentAnimation = BoomAnimation;
        }
Ejemplo n.º 9
0
        public EnemyBoom1(Vector2 position)
        {
            _position              = position;
            BoomAnimation          = new Animation();
            BoomAnimation.IsLoop   = false;
            BoomAnimation.FrameNum = 6;
            Texture = MyContentManager.GetInstance().LoadContent <Texture2D>("EnemyBoom1");
            BoomAnimation.AddFrame(new Rectangle(0, 0, 100, 100), TimeSpan.FromSeconds(.1));
            BoomAnimation.AddFrame(new Rectangle(100, 0, 100, 100), TimeSpan.FromSeconds(.1));
            BoomAnimation.AddFrame(new Rectangle(200, 0, 100, 100), TimeSpan.FromSeconds(.1));
            BoomAnimation.AddFrame(new Rectangle(300, 0, 100, 100), TimeSpan.FromSeconds(.1));
            BoomAnimation.AddFrame(new Rectangle(400, 0, 100, 100), TimeSpan.FromSeconds(.1));
            BoomAnimation.AddFrame(new Rectangle(500, 0, 100, 100), TimeSpan.FromSeconds(.1));

            _currentAnimation = BoomAnimation;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            content = new MyContentManager(Services,"Content");

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = GameVariables.win_Width;
            graphics.PreferredBackBufferHeight = GameVariables.win_Height;

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);
        }
Ejemplo n.º 11
0
        public Boss1(Vector2 position, int width, int height, Vector2 velocity, float rotation, Vector2 origin, Vector2 scale, Color color, bool islive)
        {
            _texture       = MyContentManager.GetInstance().LoadContent <Texture2D>("enemyBoss");
            _idleAniamtion = new Animation();
            _idleAniamtion.AddFrame(new Rectangle(0, 0, 163, 154), TimeSpan.FromSeconds(.25));
            _currentAnimation = _idleAniamtion;

            isTurnright  = true;
            _bulletspeed = 10;
            _speed       = 2;
            Health       = 100;
            EnemySprite  = new Sprite(position, width, height, velocity, rotation, origin, scale, color, islive);

            _upray    = new Ray2D(new Vector2(position.X + width / 2, position.Y), new Vector2(0, -0.01f));
            _downray  = new Ray2D(new Vector2(position.X + width / 2, position.Y + height), new Vector2(0, 0.01f));
            _rightray = new Ray2D(new Vector2(position.X + width, position.Y + height / 2), new Vector2(0.01f, 0));
            _leftray  = new Ray2D(new Vector2(position.X, position.Y + height / 2), new Vector2(-0.01f, 0));

            _canUp    = true;
            _canDown  = true;
            _canRight = true;
            _canLeft  = true;

            movetime      = 3.0f;
            rushtime      = 1.5f;
            attacktime    = 2.0f;
            supattacktime = 2.0f;
            delay         = 0.2f;

            movetimer      = 0.0f;
            rushtimer      = 0.0f;
            attacktimer    = 0.0f;
            supattacktimer = 0.0f;
            firetimer      = 0.0f;



            _state = BossState.MOVE;
        }
Ejemplo n.º 12
0
        public enemygGBL(Vector2 position, int width, int height, Vector2 velocity, float rotation, Vector2 origin, Vector2 scale, Color color, bool islive)
        {
            _texture       = MyContentManager.GetInstance().LoadContent <Texture2D>("enemyGBL");
            _idleAniamtion = new Animation();
            _idleAniamtion.AddFrame(new Rectangle(0, 0, 100, 130), TimeSpan.FromSeconds(.25));
            _idleAniamtion.AddFrame(new Rectangle(100, 0, 100, 130), TimeSpan.FromSeconds(.25));
            _currentAnimation = _idleAniamtion;

            isTurnright  = true;
            _bulletspeed = 10;
            _speed       = 2;
            Health       = 10;
            EnemySprite  = new Sprite(position, width, height, velocity, rotation, origin, scale, color, islive);


            _upray    = new Ray2D(new Vector2(position.X + width / 2, position.Y), new Vector2(0, -0.01f));
            _downray  = new Ray2D(new Vector2(position.X + width / 2, position.Y + height), new Vector2(0, 0.01f));
            _rightray = new Ray2D(new Vector2(position.X + width, position.Y + height / 2), new Vector2(0.01f, 0));
            _leftray  = new Ray2D(new Vector2(position.X, position.Y + height / 2), new Vector2(-0.01f, 0));

            _canUp    = true;
            _canDown  = true;
            _canRight = true;
            _canLeft  = true;

            rnd    = new Random();
            _state = GBLSate.XL;
            rndnum = rnd.Next(0, 4);

            changetime  = 2.0f;
            changetimer = 0.0f;
            stoptime    = 2.0f;
            stoptimer   = 0.0f;
            attacktime  = 2.0f;
            attacktimer = 0.0f;
            firetime    = 0.5f;
            firetimer   = 0.0f;
        }
        public DrawingComponents(GraphicsProperties gp)
        {
            this.viewMatrix = gp.ViewMatrix;
            this.projectionMatrix = gp.ViewMatrix;
            this.device = gp.GraphicsDevice;
            this.content = gp.ContentManager;
            this.spriteBatch = gp.SpriteBatch;

            //** set up scene Render taget, main target for all object drawing **/
            PresentationParameters pp = device.PresentationParameters;

            int height = pp.BackBufferHeight;
            int width = pp.BackBufferWidth;
            SurfaceFormat format = pp.BackBufferFormat;

            sceneRenderTarget = gp.RenderTarget;

            renderEffects = content.Load<Effect>("RenderAssets/RenderEffects");
            shieldModel = LoadModel("RenderAssets/cruiserShield", content);

            lightBloom = new LightBloom();
            lightBloom.LoadContent(spriteBatch, content, device, sceneRenderTarget);
        }
Ejemplo n.º 14
0
        public Stage1()
        {
            _wallTexture = MyContentManager.GetInstance().LoadContent <Texture2D>("wall1");
            stagedata    = new MyXMLData.StageData.Stage1Data();
            stagedata    = MyContentManager.GetInstance().LoadContent <MyXMLData.StageData.Stage1Data>("stage1data");

            _tile = new TileObject.tile1();
            for (int i = 0; i < _width; i++)
            {
                for (int j = 0; j < _height; j++)
                {
                    if (stagedata.tilemap[i * _width + j] == 3)
                    {
                        WallObject.wall1 wall = new WallObject.wall1(_wallTexture, new Vector2(i * 100, j * 100));
                        GameManager.GetInstance().AddWall(wall);
                    }
                }
            }

            enemyupdatetime  = delay;
            enemyupdatetimer = 0.0f;

            boss = new EnemyBoosObject.Boss1(new Vector2(1500, 1500), 163, 154, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true);

            _enemyList.Add(new EnemyObject.enemy1(new Vector2(100, 100), 115, 85, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemygGBL(new Vector2(500, 100), 100, 130, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemy1(new Vector2(800, 100), 115, 85, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemygGBL(new Vector2(100, 500), 100, 130, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemy1(new Vector2(100, 800), 115, 85, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemygGBL(new Vector2(500, 500), 100, 130, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemy1(new Vector2(700, 700), 115, 85, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemygGBL(new Vector2(900, 900), 100, 130, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemy1(new Vector2(1000, 1000), 115, 85, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));
            _enemyList.Add(new EnemyObject.enemygGBL(new Vector2(1200, 1100), 100, 130, new Vector2(5, 5), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true));

            SoundManager.Getinstance().PlayBGM();
        }
Ejemplo n.º 15
0
        public Hero(Vector2 position, int width, int height, Vector2 velocity, float rotation, Vector2 origin, Vector2 scale, Color color, bool islive)
        {
            _data    = MyContentManager.GetInstance().LoadContent <MyXMLData.HeroData>("herodata");
            _texture = MyContentManager.GetInstance().LoadContent <Texture2D>(_data.spritePath);
            _sprite  = new Sprite(position, width, height, velocity, rotation, origin, scale, color, islive);

            _weaponPosition = new Vector2(80, 100);

            health       = 10;
            _isMoveRight = true;
            state        = HeroState.NORMAL;
            _blinktime   = 0.0f;

            _idleAnimation = new Animation();
            _idleAnimation.AddFrame(new Rectangle(0, 0, 120, 140), TimeSpan.FromSeconds(.25));
            _idleAnimation.AddFrame(new Rectangle(120, 0, 120, 140), TimeSpan.FromSeconds(.25));
            _idleAnimation.AddFrame(new Rectangle(240, 0, 120, 140), TimeSpan.FromSeconds(.25));
            _idleAnimation.AddFrame(new Rectangle(360, 0, 120, 140), TimeSpan.FromSeconds(.25));

            _isBlinkAnimation = new Animation();
            _isBlinkAnimation.AddFrame(new Rectangle(480, 0, 120, 140), TimeSpan.FromSeconds(.1));
            _isBlinkAnimation.AddFrame(new Rectangle(0, 0, 120, 140), TimeSpan.FromSeconds(.1));

            _upray1 = new Ray2D(new Vector2(position.X + _offset, position.Y), new Vector2(0, -0.01f));
            //_upray1 = new Ray2D(new Vector2(position.X + width - _offset, position.Y), new Vector2(0, -0.01f));
            _downray1 = new Ray2D(new Vector2(position.X + _offset, position.Y + height), new Vector2(0, +0.01f));
            //_downray1 = new Ray2D(new Vector2(position.X + width - _offset, position.Y + height), new Vector2(0, +0.01f));
            _rightray1 = new Ray2D(new Vector2(position.X + width, position.Y + _offset), new Vector2(0.01f, 0));
            //_rightray1 = new Ray2D(new Vector2(position.X + width, position.Y + height - _offset), new Vector2(0.01f, 0));
            _leftray1 = new Ray2D(new Vector2(position.X, position.Y + _offset), new Vector2(-0.01f, 0));
            //_leftray1 = new Ray2D(new Vector2(position.X, position.Y + height - _offset), new Vector2(-0.01f, 0));

            _canUp    = true;
            _canDown  = true;
            _canRight = true;
            _canLeft  = true;
        }
Ejemplo n.º 16
0
 public bossbullet1(Vector2 position, int width, int height, Vector2 velocity, float rotation, Vector2 origin, Vector2 scale, Color color, bool islive)
 {
     _texture     = MyContentManager.GetInstance().LoadContent <Texture2D>("bossbullet");
     BulletSprite = new Sprite(position, width, height, velocity, rotation, origin, scale, color, islive);
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new MyContentManager(ScreenManager.Game.Services, "Content");

            gameFont = content.Load<SpriteFont>("Fonts/gamefont");

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
Ejemplo n.º 18
0
 public override void Initialize()
 {
     _bloodbar = MyContentManager.GetInstance().LoadContent <Texture2D>("bossBoledBar");
     _blood    = MyContentManager.GetInstance().LoadContent <Texture2D>("bossblood");
     base.Initialize();
 }
        private Model LoadModel(string assetName, MyContentManager Content)
        {
            Model newModel = Content.Load<Model>(assetName);

            foreach (ModelMesh mesh in newModel.Meshes)
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    meshPart.Effect = renderEffects.Clone();
                }
            return newModel;
        }
Ejemplo n.º 20
0
 public override void Initialize()
 {
     _heartTexture = MyContentManager.GetInstance().LoadContent <Texture2D>("herohealth");
     _font         = MyContentManager.GetInstance().LoadContent <SpriteFont>("DefaultFomt");
     base.Initialize();
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Initializes the control.
        /// </summary>
        protected override void Initialize()
        {
            if (_isIntialized)
                return;

            // Hook the idle event to constantly redraw our animation.
            Application.Idle += delegate { Invalidate(); };

            /* _scene.GraphicsDevice = (GraphicsDevice)this.Services.
                 GetService(typeof(GraphicsDevice));*/

            _scene.GraphicsDevice = ((IGraphicsDeviceService)this.Services.
                GetService(typeof(IGraphicsDeviceService))).GraphicsDevice;

            contentBuilder = new ContentBuilder();

            contentManager = new MyContentManager(this.Services,
                                                contentBuilder.OutputDirectory);

            dCamera cam = new dCamera(_scene);
            dCamOrth front = new dCamOrth(new Vector3(0,0,10),new Vector3(0,0,0),_scene);
            front.ID = "ƽ��ͼ";
            _scene.Components.Add(front);
            //dCamera cam2 = new dCamera(_scene);
            //new SelectFunction(_scene);
            //new Compass(_scene);

            //_scene.Components.Add(cam);
            _scene.Components.Add(new MouseSelectionManager(_scene));
            _scene.Components.Add(new SelectFunction(_scene));
            _scene.Components.Add(_dataReactor);

            _scene.Services = this.Services;
            _scene.Services.AddService<ContentBuilder>(contentBuilder);
            _scene.Services.AddService<MyContentManager>(contentManager);
            _scene.Services.AddService<ICamera>(cam);

            _scene.Services.AddService<DataReactor>(_dataReactor);

            //
            //this.MouseMove += new MouseEventHandler(RegistMouse);
            //this.MouseLeave += new EventHandler(UnRegistMouse);
               // this.ClientSizeChanged += new EventHandler(OnSizeChanged);

            _isIntialized = true;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load content belonging to the screen manager.
            content = Game.content;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = content.Load<SpriteFont>("Fonts/menufont");
            blankTexture = content.Load<Texture2D>("Textures/blank");

            // Tell each of the screens to load their content.
            foreach (GameScreen screen in screens)
            {
                screen.LoadContent();
            }
        }