Exemplo n.º 1
0
        public InGameMenu(App root, LevelHandler levelHandler)
        {
            this.root         = root;
            this.levelHandler = levelHandler;

            root.Immersive = true;

#if MULTIPLAYER
            bool isMultiplayerSession = (levelHandler is MultiplayerLevelHandler);
#else
            bool isMultiplayerSession = false;
#endif

            DualityApp.Sound.PauseGameplaySpecificSounds();

            levelHandler.EnableLowpassOnMusic(true);

            rootObject = new GameObject();
            rootObject.AddComponent(new LocalController(this));
            AddObject(rootObject);

            // Setup camera
            GameObject camera = new GameObject();
            camera.AddComponent <Transform>();

            Camera cameraInner = camera.AddComponent <Camera>();
            cameraInner.Projection = ProjectionMode.Orthographic;
            cameraInner.NearZ      = 10;
            cameraInner.FarZ       = 1000;

            cameraInner.RenderingSetup = new MainMenuRenderSetup();
            camera.Parent = rootObject;

            canvas = new Canvas();

            // Load resources
            fontSmall  = new BitmapFont(canvas, "_custom/font_small");
            fontMedium = new BitmapFont(canvas, "_custom/font_medium");

            metadata = ContentResolver.Current.RequestMetadata("UI/MainMenu");

            // Get game screen
            Camera           cameraLevel = levelHandler.FindComponent <Camera>();
            LevelRenderSetup renderSetup = cameraLevel.ActiveRenderSetup as LevelRenderSetup;
            if (renderSetup != null)
            {
                finalMaterial = new Material(DrawTechnique.Solid, renderSetup.RequestBlurredInGame());
            }

            InitPlatformSpecific();

            // Show Begin section
            sectionStack = new Stack <MenuSection>();

            SwitchToSection(new InGameMenuBeginSection(isMultiplayerSession));
        }