コード例 #1
0
        public Game1()
        {
            Content.RootDirectory = "Content";
            graphics = new GraphicsDeviceManager(this);
            //this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 54f);
            #if WINDOWS_PHONE
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 480;
            #endif

            #if XBOX || WINDOWS
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            #endif
            graphics.PreferMultiSampling = true;
            parameters.MultiSampleCount = 16;
            graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
            graphics.ApplyChanges();

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Camera.ViewportWidth = graphics.PreferredBackBufferWidth;
            Camera.ViewportHeight = graphics.PreferredBackBufferHeight;
            Camera.SetScreenRectangle();

            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new PressStartScreen(), null);

            //Guide.SimulateTrialMode = false;
        }
コード例 #2
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(1);
            TransitionOffTime = TimeSpan.FromSeconds(1);
        }
コード例 #3
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
                                PlayerIndex? controllingPlayer,
                                params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }
コード例 #4
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw(MenuScreen screen, bool isSelected, GameTime gameTime, float alpha)
        {
            // there is no such thing as a selected item on Windows Phone, so we always
            // force isSelected to be false
            #if WINDOWS_PHONE
            isSelected = false;
            #endif

            // Draw the selected entry in color, otherwise white.
            if (isText)
            {
                color = isSelected ? GameSettings.ShotPathColor : Color.White;
            }
            else color = Color.White;

            // Pulsate the size of the selected menu entry.
            time = (float)gameTime.TotalGameTime.TotalSeconds;

            //float pulsate = (float)Math.Sin(time * 6)+1;
            //scale = Math.Max(1.0f, (1 + pulsate * 0.05f * selectionFade));
            //if (!isSelected) scale = Math.Min(scale, lastscale); //ensures that while transitioning away from being seleced, the scale cant increase
            //lastscale = scale;

            // Modify the alpha to fade text out during transitions.
            color *= screen.TransitionAlpha;

            // Draw text, centered on the middle of each line.
            screenManager = screen.ScreenManager;

            if (isText)
            {
                //this origin line broke it?
                //Vector2 origin = new Vector2(-screen.ScreenManager.SmallFont.MeasureString(Text).X/2, -screen.ScreenManager.SmallFont.MeasureString(Text).Y/2);
                DrawStringHelper(screenManager.SpriteBatch, screenManager.smallFont, text, position, color, Vector2.Zero, scale, SpriteEffects.None, alpha);
            }

            if (isTexture)
            {
                origin = new Vector2((float)texture.Width / 2f, (float)texture.Height / 2f);
                xpos = position.X + origin.X - (float)texture.Width / 2f;
                ypos = position.Y + origin.Y - (float)texture.Height / 2f;

                //shadow
                if (isSelected)
                {
                    screenManager.SpriteBatch.Draw(texture, new Rectangle((int)xpos - 5, (int)ypos - 5, (int)((float)texture.Width * scale + 10), (int)((float)texture.Height * scale + 10)),
                                     new Rectangle(0, 0, texture.Width, texture.Height), new Color(0, 0, 0, 30));
                    screenManager.SpriteBatch.Draw(texture, new Rectangle((int)xpos - 4, (int)ypos - 4, (int)((float)texture.Width * scale + 8), (int)((float)texture.Height * scale + 8)),
                                     new Rectangle(0, 0, texture.Width, texture.Height), new Color(0, 0, 0, 60));
                    screenManager.SpriteBatch.Draw(texture, new Rectangle((int)xpos - 3, (int)ypos - 3, (int)((float)texture.Width * scale + 6), (int)((float)texture.Height * scale + 6)),
                                     new Rectangle(0, 0, texture.Width, texture.Height), new Color(0, 0, 0, 90));
                    screenManager.SpriteBatch.Draw(texture, new Rectangle((int)xpos - 2, (int)ypos - 2, (int)((float)texture.Width * scale + 4), (int)((float)texture.Height * scale + 4)),
                                     new Rectangle(0, 0, texture.Width, texture.Height), new Color(0, 0, 0, 120));
                    screenManager.SpriteBatch.Draw(texture, new Rectangle((int)xpos - 1, (int)ypos - 1, (int)((float)texture.Width * scale + 2), (int)((float)texture.Height * scale + 2)),
                                     new Rectangle(0, 0, texture.Width, texture.Height), new Color(0, 0, 0, 150));
                }

                screenManager.SpriteBatch.Draw(texture, new Rectangle((int)xpos, (int)ypos, (int)((float)texture.Width * scale), (int)((float)texture.Height * scale)),
                                     new Rectangle(0, 0, texture.Width, texture.Height), color);

                //level box elements
                if (isLevelBox)
                {
                    boxCenter = new Vector2(position.X + origin.X, position.Y + origin.Y);
                    medalFrame += 12 * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    if (medalFrame >= 10f) medalFrame -= 10f;

                    //draw star
                    if (isStarCollected)
                    {
                        screenManager.SpriteBatch.Draw(levelWithStar, new Rectangle((int)xpos, (int)ypos, levelWithStar.Width, levelWithStar.Height),
                            new Rectangle(0, 0, levelWithStar.Width, levelWithStar.Height), color);
                        float starXpos, starYpos;
                        starXpos = boxCenter.X +36 - (levelStar.Width * 1.25f * 0.5f);
                        starYpos = boxCenter.Y +20 - (levelStar.Height * 1.25f * 0.5f);
                        starRotation += 0.04f;
                        screenManager.SpriteBatch.Draw(levelStar, new Vector2((int)starXpos, (int)starYpos),
                        new Rectangle(0, 0, levelStar.Width, levelStar.Height), color, starRotation, new Vector2(31,33), 1.25f, SpriteEffects.None, 0f);
                    }

                    //draw number
                    int row = (int)number / 5;
                    int column = (int)(number - (row * 5));
                    int boss = 0;
                    if (LevelDataManager.nextworld == 5 && number == 14) boss = 1;
                    screenManager.SpriteBatch.Draw(numbers, new Rectangle((int)boxCenter.X-75, (int)boxCenter.Y-75, 144, 144),new Rectangle(column*160, (row+boss)*160, 160, 160), color);

                    if (isBronze) screenManager.SpriteBatch.Draw(levelBronze, new Rectangle((int)boxCenter.X - 59, (int)boxCenter.Y + 25, 32, 32),new Rectangle (4+(68*(int)medalFrame),4,64,64), color);
                    if (isSilver) screenManager.SpriteBatch.Draw(levelSilver, new Rectangle((int)boxCenter.X-19, (int)boxCenter.Y+25, 32, 32),new Rectangle (4+(68*(int)medalFrame),4,64,64), color);
                    if (isGold) screenManager.SpriteBatch.Draw(levelGold, new Rectangle((int)boxCenter.X+21, (int)boxCenter.Y+25, 32, 32),new Rectangle (4+(68*(int)medalFrame),4,64,64), color);
                    if (isLock && GameSettings.LocksOn) screenManager.SpriteBatch.Draw(levelLock, new Rectangle((int)boxCenter.X-72, (int)boxCenter.Y-72, 144, 144), color);
                }

                if (!isSelected)
                {
                    screenManager.SpriteBatch.Draw(texture, new Rectangle((int)xpos, (int)ypos, (int)((float)texture.Width * scale), (int)((float)texture.Height * scale)),
                                     new Rectangle(0, 0, texture.Width, texture.Height), new Color(0, 0, 0, 128));
                }
            }
        }