Пример #1
0
        /// <summary>
        /// Render the scene
        /// </summary>
        public override void Render()
        {
            if (!mGameReady)
            {
                return;
            }

            mCamera.Apply();

            Menu menu = null;

            if (mGameState == GameState.SHOW_INVENTORY || mGameState == GameState.DROP_INVENTORY)
            {
                menu = mMenuInventory;
            }
            else if (mGameState == GameState.SHOW_HELP)
            {
                menu = mMenuHelp;
            }
            else if (mGameState == GameState.LEVEL_UP)
            {
                menu = mMenuLevelUp;
            }
            else if (mGameState == GameState.CHARACTER_SCREEN)
            {
                menu = mMenuCharacterScreen;
            }

            RenderFunctions.RenderAll(mGameState, mPlayer, menu, mConsole);

            //// mFloodMap.DebugRender();

            RB.CameraReset();
        }
Пример #2
0
        /// <summary>
        /// Update scene
        /// </summary>
        /// <returns>True if update consumed</returns>
        public override bool Update()
        {
            // If game is not ready for some reason then bail out to Main Menu
            if (!mGameReady)
            {
                var game = (RetroDungeoneerGame)RB.Game;
                game.ChangeScene(SceneEnum.MAIN_MENU);
                return(false);
            }

            if (mFOVRecompute)
            {
                mGameMap.RecomputeFov(mPlayer, C.FOV_RADIUS);
                mFOVRecompute = false;
            }

            if (mFloodRecompute)
            {
                mFloodMap.Refresh(mPlayer.e.pos, (C.SCREEN_WIDTH / 2) + 2);
                mFloodRecompute = false;
            }

            if (mGameState == GameState.ENEMY_TURN)
            {
                DoEnemyTurn();
                ChangeState(GameState.PLAYER_TURN);
            }
            else
            {
                if (!mInputLocked && DoPlayerTurn())
                {
                    if (mGameState != GameState.LEVEL_UP)
                    {
                        ChangeState(GameState.ENEMY_TURN);
                    }
                }
            }

            mCamera.Follow(mPlayer);

            RenderFunctions.Update();

            SoundBank.Instance.Process();
            EffectManager.Instance.Update(mResultSet);
            HandleEffectResults();

            if (mInputLocked && !RB.AnyKeyDown())
            {
                mInputLocked = false;
            }

            return(false);
        }
        /// <summary>
        /// Initialize your game here.
        /// </summary>
        /// <returns>Return true if successful</returns>
        public bool Initialize()
        {
            assets.LoadAll();

            // You can load a spritesheet here
            RB.SpriteSheetSet(assets.spriteSheet);

            RB.EffectSet(RB.Effect.Scanlines, 0.5f);

            EntityFunctions.Initialize();
            S.InitializeAnims();

            SoundSerializer.Initialize();

            InitializeNewGame.InitializeConstants();

            RenderFunctions.Initialize();

            mSceneGame     = new SceneGame();
            mSceneMainMenu = new SceneMainMenu();
            mSceneMessage  = new SceneMessage();

            // Generate tile grid, this is a one time operation, we can keep reusing the grid
            var gridColor = Color.white;

            for (int x = 0; x < RB.MapSize.width; x++)
            {
                for (int y = 0; y < RB.MapSize.height; y++)
                {
                    RB.MapSpriteSet(C.LAYER_GRID, new Vector2i(x, y), S.GRID, gridColor);
                }
            }

            ChangeScene(SceneEnum.MAIN_MENU);

            RB.MapLayerSpriteSheetSet(C.LAYER_GRID, assets.spriteSheet);
            RB.MapLayerSpriteSheetSet(C.LAYER_TERRAIN, assets.spriteSheet);
            RB.MapLayerSpriteSheetSet(C.LAYER_VISIBILITY, assets.spriteSheet);

            // Collect any garbage created during initilization to avoid a performance hiccup later.
            System.GC.Collect();

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Initialize your game here.
        /// </summary>
        /// <returns>Return true if successful</returns>
        public bool Initialize()
        {
            // You can load a spritesheet here
            RB.SpriteSheetSetup(0, "Demos/RetroDungeoneer/SpritePack", new Vector2i(16, 16));
            RB.SpriteSheetSet(0);

            var fontSprite = RB.PackedSpriteGet(S.FONT_RETROBLIT_DROPSHADOW);
            var fontPos    = new Vector2i(fontSprite.SourceRect.x + 1, fontSprite.SourceRect.y + 1);

            RB.FontSetup(C.FONT_RETROBLIT_DROPSHADOW, '!', (char)((int)'~' + 8), fontPos, 0, new Vector2i(6, 7), ((int)'~' + 8) - (int)'!' + 1, 1, 1, false);

            RB.MusicSetup(C.MUSIC_MAIN_MENU, "Demos/RetroDungeoneer/Music/ReturnToNowhere");
            RB.MusicSetup(C.MUSIC_GAME, "Demos/RetroDungeoneer/Music/DungeonAmbience");
            RB.MusicSetup(C.MUSIC_DEATH, "Demos/RetroDungeoneer/Music/DeathPiano");
            RB.MusicSetup(C.MUSIC_FOREST, "Demos/RetroDungeoneer/Music/ForestAmbience");

            RB.SoundSetup(C.SOUND_MONSTER_DEATH, "Demos/RetroDungeoneer/Sounds/MonsterDeath");
            RB.SoundSetup(C.SOUND_PLAYER_DEATH, "Demos/RetroDungeoneer/Sounds/PlayerDeath");
            RB.SoundSetup(C.SOUND_FOOT_STEP, "Demos/RetroDungeoneer/Sounds/FootStep");
            RB.SoundSetup(C.SOUND_MONSTER_ATTACK, "Demos/RetroDungeoneer/Sounds/MonsterAttack");
            RB.SoundSetup(C.SOUND_PLAYER_ATTACK, "Demos/RetroDungeoneer/Sounds/PlayerAttack");
            RB.SoundSetup(C.SOUND_INVENTORY, "Demos/RetroDungeoneer/Sounds/Inventory");
            RB.SoundSetup(C.SOUND_DRINK, "Demos/RetroDungeoneer/Sounds/Drink");
            RB.SoundSetup(C.SOUND_MENU_OPEN, "Demos/RetroDungeoneer/Sounds/MenuOpen");
            RB.SoundSetup(C.SOUND_MENU_CLOSE, "Demos/RetroDungeoneer/Sounds/MenuClose");
            RB.SoundSetup(C.SOUND_STAIRS, "Demos/RetroDungeoneer/Sounds/Stairs");
            RB.SoundSetup(C.SOUND_POINTER_SELECT, "Demos/RetroDungeoneer/Sounds/PointerSelect");
            RB.SoundSetup(C.SOUND_SELECT_OPTION, "Demos/RetroDungeoneer/Sounds/SelectOption");
            RB.SoundSetup(C.SOUND_LEVEL_UP, "Demos/RetroDungeoneer/Sounds/LevelUp");
            RB.SoundSetup(C.SOUND_FIREBALL, "Demos/RetroDungeoneer/Sounds/Fireball");
            RB.SoundSetup(C.SOUND_LIGHTNING, "Demos/RetroDungeoneer/Sounds/Lightning");
            RB.SoundSetup(C.SOUND_CONFUSE, "Demos/RetroDungeoneer/Sounds/Confuse");
            RB.SoundSetup(C.SOUND_CHEAT, "Demos/RetroDungeoneer/Sounds/CheatMode");
            RB.SoundSetup(C.SOUND_AGGRO1, "Demos/RetroDungeoneer/Sounds/Aggro1");
            RB.SoundSetup(C.SOUND_AGGRO2, "Demos/RetroDungeoneer/Sounds/Aggro2");
            RB.SoundSetup(C.SOUND_PLAYER_FALL_YELL, "Demos/RetroDungeoneer/Sounds/PlayerFallYell");
            RB.SoundSetup(C.SOUND_PORTAL, "Demos/RetroDungeoneer/Sounds/Portal");
            RB.SoundSetup(C.SOUND_JUMP, "Demos/RetroDungeoneer/Sounds/Jump");
            RB.SoundSetup(C.SOUND_BOW_SHOOT, "Demos/RetroDungeoneer/Sounds/BowShoot");
            RB.SoundSetup(C.SOUND_BOW_HIT, "Demos/RetroDungeoneer/Sounds/BowHit");
            RB.SoundSetup(C.SOUND_WEB, "Demos/RetroDungeoneer/Sounds/Web");
            RB.SoundSetup(C.SOUND_TELEPORT, "Demos/RetroDungeoneer/Sounds/Teleport");
            RB.SoundSetup(C.SOUND_SLIME, "Demos/RetroDungeoneer/Sounds/Slime");

            RB.ShaderSetup(C.SHADER_VIGNETTE, "Demos/RetroDungeoneer/DrawVignette");

            RB.EffectSet(RB.Effect.Scanlines, 0.5f);

            EntityFunctions.Initialize();
            S.InitializeAnims();

            InitializeNewGame.InitializeConstants();

            RenderFunctions.Initialize();

            mSceneGame     = new SceneGame();
            mSceneMainMenu = new SceneMainMenu();
            mSceneMessage  = new SceneMessage();

            // Generate tile grid, this is a one time operation, we can keep reusing the grid
            var gridColor = Color.white;

            for (int x = 0; x < RB.MapSize.width; x++)
            {
                for (int y = 0; y < RB.MapSize.height; y++)
                {
                    RB.MapSpriteSet(C.LAYER_GRID, new Vector2i(x, y), S.GRID, gridColor);
                }
            }

            ChangeScene(SceneEnum.MAIN_MENU);

            // Collect any garbage created during initilization to avoid a performance hiccup later.
            System.GC.Collect();

            return(true);
        }