コード例 #1
0
ファイル: Game1.cs プロジェクト: kayorga/3DSP
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            audio    = new AudioManager(Content);
            camera   = new Camera(GraphicsDevice.Viewport.AspectRatio);
            world    = new World(Content, GraphicsDevice);
            data     = new GameData(Content, GraphicsDevice, audio, world);
            screen   = new TitleScreen(Content, GraphicsDevice, audio, data);
            myAction = new ActionScreen(Content, GraphicsDevice, audio, data, camera, world);
            audio.playBackground(0);

            fading        = false;
            fadeOut       = true;
            fadeFrames    = 0;
            maxFadeFrames = 30;
            fadeRectangle = new Rectangle(0, 0, 1024, 768);

            base.Initialize();
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: kayorga/3DSP
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (Constants.DEBUG && (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Tab)))
            {
                this.Exit();
            }

            if (fading)          //is fading at the moment
            {
                if (fade())      //if fade ends
                {
                    if (fadeOut) //if fading out
                    {
                        if (nextScreen == myAction)
                        {
                            if (screen.nextZone != world.mapID)
                            {
                                world.warp(screen.nextZone, screen.nextTheme);
                                world.setupSpawners(data.missions.activeMission);
                                audio.playBackground(screen.nextTheme);
                            }
                            myAction.reset();

                            myAction.update(gameTime);
                            camera.reset();
                            data.player.update(gameTime, data.npcs, data.bullets, camera, false);
                            camera.Update(gameTime, data.player.position);
                        }
                        screen = nextScreen;

                        fadeFrames = maxFadeFrames;
                        fadeOut    = false;
                    }
                    else            //if fading in
                    {
                        fading = false;
                    }
                }
            }
            else
            {
                int updateState = screen.update(gameTime);
                switch (updateState)
                {
                case Constants.CMD_EXIT: Exit(); break;

                case Constants.CMD_NONE: break;

                case Constants.CMD_NEW:
                {
                    nextScreen = myAction;
                    fading     = true;
                    fadeFrames = maxFadeFrames;
                    fadeOut    = true;
                    //myAction.reset();
                    break;
                }

                case Constants.CMD_PAUSE:
                    screen = new PauseScreen(Content, GraphicsDevice, audio, data, world, camera); break;

                case Constants.CMD_JOURNAL:
                    screen = new BriefingScreen(Content, GraphicsDevice, audio, data, world, camera); break;

                case Constants.CMD_MOD:
                    screen = new ModificationScreen(Content, GraphicsDevice, audio, data, world, camera); break;

                case Constants.CMD_MISSIONCOMPLETE:
                    screen = new MissionCompleteScreen(Content, GraphicsDevice, audio, data, world, camera); break;

                case Constants.CMD_BACK:
                {
                    screen            = myAction;
                    myAction.canShoot = false;
                    break;
                }

                case Constants.CMD_MISSIONINFO:
                    screen = new MissionInfoScreen(Content, GraphicsDevice, audio, data, world, camera); break;

                case Constants.CMD_INTRO:
                    screen = new IntroductionScreen(Content, GraphicsDevice, audio, data, spriteBatch); break;

                case Constants.CMD_DEX:
                    screen = new DexScreen(Content, GraphicsDevice, data, audio, world, camera); break;

                case Constants.CMD_CREDITS:
                    screen = new CreditsScreen(Content, GraphicsDevice, audio, data); break;

                case Constants.CMD_TITLE:
                    screen = new TitleScreen(Content, GraphicsDevice, audio, data); break;

                case Constants.CMD_GAMEOVER:
                    screen = new GameOverScreen(Content, GraphicsDevice, audio, data, world, camera); break;

                case Constants.CMD_CHARINFO:
                    screen = new CharScreen(Content, GraphicsDevice, audio, data, world, camera); break;

                case Constants.CMD_HELP:
                {
                    if (screen is TitleScreen)
                    {
                        screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_TITLE);
                    }
                    else if (screen is PauseScreen)
                    {
                        screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_PAUSE);
                    }
                    else if (screen is DexScreen)
                    {
                        screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_DEX);
                    }
                    else if (screen is MissionCompleteScreen)
                    {
                        screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_MISSIONCOMPLETE);
                    }
                    else if (screen is MissionInfoScreen)
                    {
                        screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_MISSIONINFO);
                    }
                    else if (screen is CharScreen)
                    {
                        screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_CHARINFO);
                    }
                    else if (screen is BriefingScreen)
                    {
                        screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_JOURNAL);
                    }
                    break;
                }

                case Constants.CMD_STORY:
                    screen = new StoryScreen(Content, GraphicsDevice, audio, data, spriteBatch); break;

                default: break;
                }

                if (updateState != Constants.CMD_NONE)
                {
                    Mouse.SetPosition(512, 384);
                }

                audio.update();
            }
            base.Update(gameTime);
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: kayorga/3DSP
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            audio = new AudioManager(Content);
            camera = new Camera(GraphicsDevice.Viewport.AspectRatio);
            world = new World(Content, GraphicsDevice);
            data = new GameData(Content, GraphicsDevice, audio, world);
            screen = new TitleScreen(Content, GraphicsDevice, audio, data);
            myAction = new ActionScreen(Content, GraphicsDevice, audio, data, camera, world);
            audio.playBackground(0);

            fading = false;
            fadeOut = true;
            fadeFrames = 0;
            maxFadeFrames = 30;
            fadeRectangle = new Rectangle(0, 0, 1024, 768);

            base.Initialize();
        }