/// <summary>
        /// Initialize
        /// </summary>
        /// <returns>True if successful</returns>
        public bool Initialize()
        {
            assets.LoadAll();

            if (!LoadMap())
            {
                return(false);
            }

            RB.MusicVolumeSet(0.5f);
            RB.MusicPlay(assets.musicGame);

            SceneTitle scene = new SceneTitle();

            scene.Initialize();

            SwitchScene(scene);

            RB.EffectSet(RB.Effect.Scanlines, 0.25f);
            RB.EffectSet(RB.Effect.Noise, 0.05f);

            if (!mStandalone)
            {
                RB.PresentDisable();
            }

            return(true);
        }
        /// <summary>
        /// Render
        /// </summary>
        public override void Render()
        {
            var demo = (DemoReel)RB.Game;

            RB.Clear(DemoUtil.IndexToRGB(22));

            int spriteFrame = ((int)RB.Ticks % 40) > 20 ? 1 : 0;

            if (mMap != null)
            {
                RB.DrawMapLayer(0);
                RB.DrawMapLayer(1);
            }

            RB.EffectSet(RB.Effect.Noise, 0.15f);
            RB.EffectSet(RB.Effect.Scanlines, 1.0f);
            RB.EffectSet(RB.Effect.Desaturation, (Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f);

            RB.EffectApplyNow();
            RB.EffectReset();

            if (mMap != null)
            {
                RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16));
            }
            else
            {
                RB.Print(new Vector2i(2, 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity");
            }

            mFormatStr.Set("@C// Specify when post-processing effects should be applied\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected](@L1@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L0.15f@N);\n");
            mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L1.0f@N);\n");
            mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L").Append((Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f, 2).Append("f@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@L").Append(0 + spriteFrame).Append("@N, @Knew@N Vector2i(@L").Append(13 * 16).Append("@N, @L").Append(16 * 16).Append("@N));");

            var size = RB.PrintMeasure(DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            size.x += 4;
            size.y += 4;

            var rect = new Rect2i((RB.DisplaySize.width / 2) - (size.x / 2), (RB.DisplaySize.height / 2) - (size.y / 2), size.x, size.y);

            rect.y -= 64;

            RB.DrawRectFill(rect, DemoUtil.IndexToRGB(1));
            RB.DrawRect(rect, DemoUtil.IndexToRGB(4));
            RB.Print(new Vector2i(rect.x + 2, rect.y + 2), DemoUtil.IndexToRGB(0), mFinalStr);
        }
Exemple #3
0
    public bool Initialize()
    {
        networkConfig.AddChannel(QosType.ReliableSequenced);

        RB.EffectSet(RB.Effect.Desaturation, 0.5F);

        RB.SpriteSheetSetup(SPRITEPACK_BATTLE, "Sprites/Battle", new Vector2i(12, 12));
        RB.SpriteSheetSet(SPRITEPACK_BATTLE);

        RB.SoundSetup(AUDIO_BUTTON, "Audio/Select");
        RB.SoundSetup(AUDIO_ROLL, "Audio/Roll");
        RB.SoundSetup(AUDIO_HURT, "Audio/Hurt");
        RB.SoundSetup(AUDIO_HEAL, "Audio/Heal");

        OpenScreen(new MainScreen(this, RB.DisplaySize));
        return(true);
    }
Exemple #4
0
        /// <summary>
        /// Render transition effect
        /// </summary>
        public virtual void Render()
        {
            RB.CameraReset();

            if (mTransitionState == TransitionState.ENTERING)
            {
                RB.EffectSet(RB.Effect.Pinhole, 1.0f - mTransitionProgress, new Vector2i(RB.DisplaySize.width / 2, RB.DisplaySize.height / 2), Color.black);
            }
            else if (mTransitionState == TransitionState.EXITING)
            {
                RB.EffectSet(RB.Effect.Pinhole, mTransitionProgress, new Vector2i(RB.DisplaySize.width / 2, RB.DisplaySize.height / 2), Color.black);
            }
            else
            {
                RB.EffectSet(RB.Effect.Pinhole, 0);
            }
        }
        /// <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);
        }
Exemple #6
0
        /// <summary>
        /// Animate game state change, allowing for nice transitions between screens
        /// </summary>
        public void AnimateStateChange()
        {
            if (mPendingState != GameState.NONE)
            {
                mStateChange -= 0.025f;
                if (mStateChange < 0.0f)
                {
                    mState       = mPendingState;
                    mStateChange = 0.0f;

                    if (mState == GameState.LEVEL)
                    {
                        int levelIndex = 0;
                        if (mLevel != null)
                        {
                            levelIndex = mLevel.Index + 1;
                        }

                        mLevel = new GameLevel(levelIndex);
                    }

                    if (mState != GameState.LEVEL)
                    {
                        mLevel = null;
                    }

                    mPendingState = GameState.NONE;
                }

                RB.EffectSet(RB.Effect.Slide, new Vector2i((int)(Mathf.Sin((1.0f - mStateChange) * Mathf.PI / 2) * (RB.DisplaySize.width + 16)), 0));
            }
            else
            {
                mStateChange += 0.025f;
                if (mStateChange > 1)
                {
                    mStateChange = 1;
                }

                RB.EffectSet(RB.Effect.Slide, new Vector2i((int)(Mathf.Sin((1.0f - mStateChange) * Mathf.PI / 2) * (RB.DisplaySize.width + 16)), 0));
            }
        }
Exemple #7
0
        /// <summary>
        /// Initialize
        /// </summary>
        /// <returns>True if successful</returns>
        public bool Initialize()
        {
            RB.SpriteSheetSetup(SPRITESHEET_SPRITES, "Demos/SuperFlagRun/Sprites", new Vector2i(16, 16));
            RB.SpriteSheetSetup(SPRITESHEET_TITLE, "Demos/SuperFlagRun/SpritesTitle", new Vector2i(16, 16));
            RB.SpriteSheetSetup(SPRITESHEET_TERRAIN, "Demos/SuperFlagRun/TilemapTerrain", new Vector2i(16, 16));
            RB.SpriteSheetSetup(SPRITESHEET_DECO, "Demos/SuperFlagRun/TilemapDeco", new Vector2i(16, 16));

            RB.SpriteSheetSet(SPRITESHEET_SPRITES);

            RB.FontSetup(GAME_FONT, 'A', 'Z', new Vector2i(0, 130), 0, new Vector2i(12, 12), 6, 1, -1, false);

            if (!LoadMap())
            {
                return(false);
            }

            RB.SoundSetup(SOUND_JUMP, "Demos/SuperFlagRun/Jump");
            RB.SoundSetup(SOUND_PICKUP_FLAG, "Demos/SuperFlagRun/Pickup");
            RB.SoundSetup(SOUND_DROP_FLAG, "Demos/SuperFlagRun/DropFlag");
            RB.SoundSetup(SOUND_START_GAME, "Demos/SuperFlagRun/StartGame");
            RB.SoundSetup(SOUND_FOOT_STEP, "Demos/SuperFlagRun/FootStep");

            RB.MusicSetup(0, "Demos/SuperFlagRun/Music/GoLucky");
            RB.MusicVolumeSet(0.5f);
            RB.MusicPlay(0);

            SceneTitle scene = new SceneTitle();

            scene.Initialize();

            SwitchScene(scene);

            RB.EffectSet(RB.Effect.Scanlines, 0.25f);
            RB.EffectSet(RB.Effect.Noise, 0.05f);

            if (!mStandalone)
            {
                RB.PresentDisable();
            }

            return(true);
        }
Exemple #8
0
 public void Render()
 {
     RB.EffectApplyNow();
     RB.EffectSet(RB.Effect.Noise, .2F);
     RB.Clear(background);
     RB.EffectSet(RB.Effect.Noise, 0F);
     if (currentScreen != null)
     {
         currentScreen.Render();
     }
     if (message.Length > 0)
     {
         RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.x, RB.DisplaySize.y), Color.Lerp(Color.black, Color.clear, 0.5F));
         Vector2i msgSize = RB.PrintMeasure(message);
         Rect2i   msgRect = new Rect2i(RB.DisplaySize.x / 2 - msgSize.x / 2, RB.DisplaySize.y / 2 - msgSize.y / 2, msgSize.x, msgSize.y).Expand(2);
         RB.DrawRectFill(msgRect, Color.white);
         RB.DrawRect(msgRect, Color.black);
         RB.Print(msgRect, Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, message);
     }
 }
Exemple #9
0
        /// <summary>
        /// Update, your game logic should live here. Update is called at a fixed interval of 60 times per second.
        /// </summary>
        public void Update()
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            if (mState == GameState.MAIN_MENU)
            {
                mMainMenu.Update();
            }
            else if (mState == GameState.LEVEL)
            {
                mLevel.Update();
            }

            RB.EffectSet(RB.Effect.Shake, mShake);
            mShake *= 0.85f;

            AnimateStateChange();
        }
Exemple #10
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/BrickBust/Sprites", new Vector2i(10, 10));
            RB.SpriteSheetSet(0);

            mMainMenu = new MainMenu();

            RB.EffectSet(RB.Effect.Scanlines, 0.2f);
            RB.EffectSet(RB.Effect.Noise, 0.01f);

            RB.ShaderSetup(C.SHADER_SHADOW, "Demos/BrickBust/DrawShaderShadow");
            RB.ShaderSpriteSheetTextureSet(C.SHADER_SHADOW, "_SpritesTexture", 0);

            RB.SoundSetup(C.SOUND_HIT_BRICK, "Demos/BrickBust/Sounds/hit");
            RB.SoundSetup(C.SOUND_HIT_WALL, "Demos/BrickBust/Sounds/hit2");
            RB.SoundSetup(C.SOUND_EXPLODE, "Demos/BrickBust/Sounds/explode");
            RB.SoundSetup(C.SOUND_DEATH, "Demos/BrickBust/Sounds/death");
            RB.SoundSetup(C.SOUND_START, "Demos/BrickBust/Sounds/start");
            RB.SoundSetup(C.SOUND_POWERUP, "Demos/BrickBust/Sounds/powerup");
            RB.SoundSetup(C.SOUND_LASERSHOT, "Demos/BrickBust/Sounds/lasershot");
            RB.SoundSetup(C.SOUND_LASERHIT, "Demos/BrickBust/Sounds/laserhit");

            RB.MusicSetup(C.MENU_MUSIC, "Demos/BrickBust/Music/BossFight");
            RB.MusicSetup(C.LEVEL_MUSIC, "Demos/BrickBust/Music/Stage2");

            RB.MusicVolumeSet(0.4f);

            LevelDef.Initialize();

            ChangeState(GameState.MAIN_MENU);

            if (UnityEngine.Application.isMobilePlatform)
            {
                C.ACTION_VERB = "TAP";
            }

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

            mMainMenu = new MainMenu();

            RB.EffectSet(RB.Effect.Scanlines, 0.2f);
            RB.EffectSet(RB.Effect.Noise, 0.01f);

            RB.MusicVolumeSet(0.4f);

            LevelDef.Initialize();

            ChangeState(GameState.MAIN_MENU);

            if (UnityEngine.Application.isMobilePlatform)
            {
                Global.ACTION_VERB = "TAP";
            }

            return(true);
        }
Exemple #12
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);
        }
        private void ApplyEffect()
        {
            var demo = (DemoReel)RB.Game;

            float progress = Mathf.Sin((RB.Ticks % 250) / 150f * Mathf.PI);

            progress = Mathf.Clamp(progress, 0, 1);

            Color32 rgb;

            switch (mEffect)
            {
            case RB.Effect.Scanlines:
            case RB.Effect.Noise:
            case RB.Effect.Desaturation:
            case RB.Effect.Curvature:
            case RB.Effect.Negative:
            case RB.Effect.Pixelate:
                RB.EffectSet(mEffect, progress);
                mParamsText.Set(", ").Append(progress, 2);
                break;

            case RB.Effect.Shake:
                RB.EffectSet(mEffect, progress * 0.1f);
                mParamsText.Set(", ").Append(progress * 0.1f, 2);
                break;

            case RB.Effect.Zoom:
                RB.EffectSet(mEffect, (progress * 5.0f) + 0.5f);
                mParamsText.Set(", ").Append((progress * 5.0f) + 0.5f, 2);
                break;

            case RB.Effect.Slide:
            case RB.Effect.Wipe:
                Vector2i slide = new Vector2i((int)(progress * RB.DisplaySize.width), 0);
                RB.EffectSet(mEffect, slide);
                mParamsText.Set(", new Vector2i(").Append(slide.x).Append(", ").Append(slide.y).Append(")");
                break;

            case RB.Effect.Rotation:
                RB.EffectSet(mEffect, progress * 360.0f);
                mParamsText.Set(", ").Append(progress * 360.0f, 0);
                break;

            case RB.Effect.ColorFade:
                RB.EffectSet(mEffect, progress, Vector2i.zero, DemoUtil.IndexToRGB(20));
                rgb = DemoUtil.IndexToRGB(20);
                mParamsText.Set(", ").Append(progress, 2).Append(", Vector2i.zero, new Color32").Append(rgb);

                break;

            case RB.Effect.ColorTint:
                RB.EffectSet(mEffect, progress, Vector2i.zero, DemoUtil.IndexToRGB(31));
                rgb = DemoUtil.IndexToRGB(31);
                mParamsText.Set(", ").Append(progress, 2).Append(", Vector2i.zero, new Color32").Append(rgb);

                break;

            case RB.Effect.Fizzle:
                RB.EffectSet(mEffect, progress, Vector2i.zero, DemoUtil.IndexToRGB(11));
                rgb = DemoUtil.IndexToRGB(11);
                mParamsText.Set(progress, 2).Append(", Vector2i.zero, new Color32").Append(rgb);

                break;

            case RB.Effect.Pinhole:
            case RB.Effect.InvertedPinhole:
                Vector2i pos =
                    new Vector2i(
                        (int)((Mathf.Sin(progress * 8) * (RB.DisplaySize.width / 6.0f)) + (RB.DisplaySize.width / 6.0f)),
                        (int)((Mathf.Cos(progress * 8) * (RB.DisplaySize.width / 6.0f)) + (RB.DisplaySize.width / 6.0f)));

                RB.EffectSet(mEffect, progress, pos, DemoUtil.IndexToRGB(0));
                rgb = DemoUtil.IndexToRGB(0);
                mParamsText.Set(", ").Append(progress, 2).Append(", new Vector2i").Append(pos).Append(", new Color32").Append(rgb);

                break;
            }
        }