Esempio n. 1
0
        void SetPlayingEnabled(bool enabled)
        {
            var specks = Repository.Behaviors.Where
                         (
                x =>
                x.Group.IndexOf(DirtProducer.DirtSpeck) != -1 &&
                x is Transform         // just to only grab one component from each group
                         );

            // remove all previously made dirt specks
            Behavior[] speckTransforms = specks.ToArray();
            for (int i = 0; i < speckTransforms.Length; i++)
            {
                Repository.Delegater.UnbindAll(speckTransforms[i].Group);
            }

            var results = Repository.Behaviors.Where
                          (
                x =>
                x.Group == Groups.DirtProduction ||
                x.Group == Groups.GameInformation ||
                x.Group == Groups.Statue ||
                x.Group.IndexOf(DirtProducer.DirtSpeck) != -1
                          );

            foreach (var result in results)
            {
                result.Enabled = enabled;

                if (result is Drawable)
                {
                    ((Drawable)result).Visible = enabled;
                }
            }

            if (enabled)
            {
                StatueInformation statueInfo = Repository.Get <StatueInformation>(Groups.Statue);

                GameInformation gameInfo = Repository.Get <GameInformation>(Groups.GameInformation);
                gameInfo.ResetTimer();
                gameInfo.IsCountingTime = true;

                DirtProducer producer = Repository.Get <DirtProducer>(Groups.DirtProduction);
                producer.SpawnContinuously = gameInfo.GameMode == GameMode.Regular ? false : true;
                producer.TimeBetweenSpawns = statueInfo.StatueSettings.TimeBetweenSpawns;
                producer.Spawn(statueInfo.StatueSettings.InitialAmountOfSpecks);

                Vector3 cameraOffset     = new Vector3(0, 0, 1);
                float   distanceToCenter = statueInfo.BoundingSphere.Radius / (float)Math.Sin(MathHelper.PiOver4 / 2);
                Vector3 back             = Vector3.Backward;
                back.X = -back.X;
                Repository.Get <Transform>(Groups.Camera).Position = (back * distanceToCenter) + cameraOffset;
            }
        }
Esempio n. 2
0
        void InitializeBehaviors()
        {
            Delegater delegater = repo.Delegater;

            /*
             * FPS
             */
            fps = new FrameRateCounter();
            delegater.Bind(Groups.FrameRate, fps);

            /*
             * Camera
             */
            DefaultCamera camera = new DefaultCamera(GraphicsDevice)
            {
                ClearColor = Color.CornflowerBlue
            };

            delegater.Bind(Groups.Camera, camera);

            /*
             * Background
             */
            // bug: spritebatch.Begin(AlphaBlend) makes sure that this quad gets drawn in the background
            // which means that some important renderstates are getting set, but not by me
            FullScreenQuad background = new FullScreenQuad()
            {
                Top = new Color(25, 31, 32),
                Bottom = new Color(71, 81, 90),
                DrawOrder = 0
            };

            delegater.Bind(Groups.Background, background);

            /*
             * Statue
             */
            StatueInformation statueInformation = new StatueInformation()
            {
                StatueSettings = StatueSettings[0]
            };

            delegater.Bind(Groups.Statue, statueInformation);

            Statue statue = new Statue()
            {
                DrawOrder = 2 // to fix some troubles with blobs getting viewed through the statue
            };

            delegater.Bind(Groups.Statue, statue);

            StatueMouseController statueController = new StatueMouseController();
            delegater.Bind(Groups.Statue, statueController);

            /*
             * Game Information
             */
            GameInformation gameInfo = new GameInformation()
            {
                GameMode = GameMode.Regular
            };

            delegater.Bind(Groups.GameInformation, gameInfo);

            GameInformationDisplay gameInfoDisplay = new GameInformationDisplay()
            {
                DrawOrder = 3
            };

            delegater.Bind(Groups.GameInformation, gameInfoDisplay);

            /*
             * Blob Production
             */
            DirtProducer blobProducer = new DirtProducer();
            delegater.Bind(Groups.DirtProduction, blobProducer);

            /*
             * Game State Control
             */
            GameStateController stateController = new GameStateController();

            delegater.Bind(Groups.GameStateControl, stateController);

            /*
             * Menu stuff
             */
            StatueInformation menuStatueInformation = new StatueInformation()
            {
                StatueSettings = StatueSettings[0]
            };

            delegater.Bind(Groups.MenuStatuePreview, menuStatueInformation);

            Statue menuStatue = new Statue()
            {
                DrawOrder = 2
            };

            delegater.Bind(Groups.MenuStatuePreview, menuStatue);

            StatuePreviewSpinner statueSpinner = new StatuePreviewSpinner();

            delegater.Bind(Groups.MenuStatuePreview, statueSpinner);

            MenuItemsDisplay menuItems = new MenuItemsDisplay()
            {
                DrawOrder = 3
            };

            delegater.Bind(Groups.MenuItemsDisplay, menuItems);

            /*
             * Intro
             */
            Intro intro = new Intro();

            delegater.Bind(Groups.Intro, intro);

            // omg, lousy hack.. these two lines makes sure we get to see the damn preview model in menu screen :P
            // im too tired to find the reason.. the code is such a mess already
            stateController.GameState = GameState.Playing;
            stateController.GameState = GameState.Menu;
            stateController.GameState = GameState.Intro;
        }