コード例 #1
0
        public Game()
        {   // Demo/Select Screen
            this.roundNum = 1;
            TextureManager.Create(2, 2);
            ImageManager.Create(5, 2);
            SpriteManager.Create(5, 2);
            SpriteBoxManager.Create(1, 1);
            SpriteBatchManager.Create(2, 1);
            TimerManager.Create(3, 1);
            GameObjectManager.Create(3, 1);
            ProxySpriteManager.Create(10, 5);
            CollisionPairManager.Create(2, 1);
            SoundManager.Create(9, 1);
            FontManager.Create(26, 10);
            ScoreManager.Initialize();

            //---------------------------------------------------------------------------------------------------------
            // Load Textures
            //---------------------------------------------------------------------------------------------------------
            Texture pSpritesTexture = TextureManager.Add(TextureName.Sprites, "Sprites.tga");
            Texture pShieldTexture  = TextureManager.Add(TextureName.Shields, "Shield.tga");

            TextureManager.Add(TextureName.Consolas36pt, "consolas36pt.tga");
            FontManager.AddXml("Consolas36pt.xml", FontName.Consolas36pt, TextureName.Consolas36pt);

            //---------------------------------------------------------------------------------------------------------
            // Load Sounds
            //---------------------------------------------------------------------------------------------------------
            SoundManager.Add(SoundName.explosion);
            SoundManager.Add(SoundName.fastInvader1);
            SoundManager.Add(SoundName.fastInvader2);
            SoundManager.Add(SoundName.fastInvader3);
            SoundManager.Add(SoundName.fastInvader4);
            SoundManager.Add(SoundName.invaderKilled);
            SoundManager.Add(SoundName.shoot);
            SoundManager.Add(SoundName.ufoHighPitch);
            SoundManager.Add(SoundName.ufoLowPitch);

            //---------------------------------------------------------------------------------------------------------
            // Create SpriteBatches
            //---------------------------------------------------------------------------------------------------------
            SpriteBatch sbAliens  = SpriteBatchManager.Add(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes   = SpriteBatchManager.Add(SpriteBatchName.Boxes);
            SpriteBatch sbShips   = SpriteBatchManager.Add(SpriteBatchName.Ships);
            SpriteBatch sbSplats  = SpriteBatchManager.Add(SpriteBatchName.Splats);
            SpriteBatch sbShields = SpriteBatchManager.Add(SpriteBatchName.Shields);
            SpriteBatch sbFonts   = SpriteBatchManager.Add(SpriteBatchName.Fonts);

            InitializeImageManager();

            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------
            SpriteManager.Add(SpriteBaseName.UFO, ImageName.UFO, 200.0f, 200.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.UFOBomb, ImageName.Missile, 100.0f, 700.0f, 5.0f, 32.0f);
            SpriteManager.Add(SpriteBaseName.Squid, ImageName.SquidA, 100.0f, 800.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Crab, ImageName.CrabA, 100.0f, 750.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Octopus, ImageName.OctopusA, 100.0f, 700.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Ship, ImageName.Ship, 100.0f, 700.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Missile, ImageName.Missile, 100.0f, 700.0f, 5.0f, 32.0f);
            SpriteManager.Add(SpriteBaseName.BombStraight, ImageName.BombStraightA, 100.0f, 100.0f, 10.0f, 60.0f);
            SpriteManager.Add(SpriteBaseName.BombDagger, ImageName.BombDaggerA, 100.0f, 100.0f, 20.0f, 60.0f);
            SpriteManager.Add(SpriteBaseName.BombZigZag, ImageName.BombZigZagA, 200.0f, 200.0f, 20.0f, 60.0f);
            SpriteManager.Add(SpriteBaseName.Brick, ImageName.Brick, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickLeftTop0, ImageName.BrickLeftTop0, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickLeftTop1, ImageName.BrickLeftTop1, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickLeftBottom, ImageName.BrickLeftBottom, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickRightTop0, ImageName.BrickRightTop0, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickRightTop1, ImageName.BrickRightTop1, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickRightBottom, ImageName.BrickRightBottom, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.Splat, ImageName.AlienExplosion, 200.0f, 200.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Explosion, ImageName.ShipExplosion, 200.0f, 200.0f, 50.0f, 50.0f);

            // Input
            InputSubject inputSubject;

            inputSubject = InputManager.GetOneSubject();
            inputSubject.RegisterObserver(new OnePlayerObserver());

            inputSubject = InputManager.GetArrowLeftSubject();
            inputSubject.RegisterObserver(new MoveLeftObserver());

            inputSubject = InputManager.GetArrowRightSubject();
            inputSubject.RegisterObserver(new MoveRightObserver());

            inputSubject = InputManager.GetSpaceSubject();
            inputSubject.RegisterObserver(new ShootObserver());
            //inputSubject = InputManager.GetTwoSubject();
            //inputSubject.RegisterObserver(new TwoPlayerObserver());

            TimerManager.Add(TimerEventName.SetGameState, TimerManager.GetCurrentTime() + 5.0f, TimerManager.GetCurrentTime() + 5.0f, new GameSelectEvent());
        }