コード例 #1
0
ファイル: WheelMenu.cs プロジェクト: yxrkt/AvatarHamsterPanic
        public WheelMenu( MenuScreen screen, Camera camera, float wheelScale, 
            float screenScale, float startX, float activeX, float finishX, float y)
            : base(screen, Vector2.Zero)
        {
            this.wheelScale = wheelScale;
              scaleMatrix = Matrix.CreateScale( wheelScale );
              this.camera = camera;
              angle = MathHelper.PiOver4;

              TransitionOnPosition = new Vector2( startX, y );
              Position = new Vector2( activeX, y );
              TransitionOffPosition = new Vector2( finishX, y );

              rotateSpring = new SpringInterpolater( 1, 50, SpringInterpolater.GetCriticalDamping( 50 ) );

              lastX = startX;

              ContentManager content = screen.ScreenManager.Game.Content;

              entryEffect = content.Load<Effect>( "Effects/basic" ).Clone( Screen.ScreenManager.GraphicsDevice );
              entryEffect.CurrentTechnique = entryEffect.Techniques["DiffuseColor"];
              entryEffect.Parameters["LightingEnabled"].SetValue( false );
              entryWorldEffectParameter = entryEffect.Parameters["World"];
              entryViewEffectParameter = entryEffect.Parameters["View"];
              entryProjectionEffectParameter = entryEffect.Parameters["Projection"];
              entryDiffuseEffectParameter = entryEffect.Parameters["DiffuseMap"];

              wheelModel = content.Load<CustomModel>( "Models/hamsterWheel" );
              foreach ( CustomModel.ModelPart part in wheelModel.ModelParts )
              {
            part.Effect.CurrentTechnique = part.Effect.Techniques["Color"];
            part.Effect.Parameters["Color"].SetValue( new Color( Color.LightGray, 0 ).ToVector4() );
              }
        }
コード例 #2
0
        public OneByOneByOne( GameplayScreen screen )
            : base(screen)
        {
            model = screen.Content.Load<Model>( "Models/1x1x1" );
              texture = screen.Content.Load<Texture2D>( "Textures/plus" );

              Camera camera = Screen.Camera;
              float depth = camera.Position.Z + .5f;
              height = depth * (float)Math.Tan( camera.Fov / 2f );
              width = height * camera.Aspect;

              // cylinder
              cylinder = screen.Content.Load<CustomModel>( "Models/cylinder" );
              foreach ( CustomModel.ModelPart part in cylinder.ModelParts )
              {
            part.Effect.Parameters["Mask"].SetValue( MaskHelper.Glow( 1 ) );
            //part.Effect.Parameters["LightingEnabled"].SetValue( false );
              }
        }
コード例 #3
0
        private LoadingScreen( ScreenManager screenManager, bool loadingIsSlow,
            GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
              this.screensToLoad = screensToLoad;
              doneLoading = false;

              TransitionOnTime = TimeSpan.FromSeconds( 0.5 );

              if ( loadingIsSlow )
              {
            backgroundThread = new Thread( BackgroundWorkerThread );
            backgroundThreadExit = new ManualResetEvent( false );

            graphicsDevice = screenManager.GraphicsDevice;

            screenScale = graphicsDevice.Viewport.Height / 1080f;

            ContentManager content = GameCore.Instance.Content;

            howToPlay = new Texture2D[3];
            for ( int i = 0; i < 3; ++i )
              howToPlay[i] = content.Load<Texture2D>( "Textures/howtoplay" + ( i + 1 ).ToString() );

            loadingText = content.Load<Texture2D>( "Textures/loadingText" );
            pressStartText = content.Load<Texture2D>( "Textures/pressStartText" );
            hamsterBall = content.Load<CustomModel>( "Models/hamsterBall" );
            foreach ( CustomModel.ModelPart part in hamsterBall.ModelParts )
            {
              part.Effect.CurrentTechnique = part.Effect.Techniques["DiffuseColor"];
              part.EffectParamColor.SetValue( new Vector4( .8f, .7f, 1f, .5f ) );
              part.Effect.Parameters["SpecularPower"].SetValue( 400 );
            }
            Viewport viewport = screenManager.GraphicsDevice.Viewport;
            Vector2 viewportSize = new Vector2( viewport.Width, viewport.Height );
            textPosition = new Vector2( viewportSize.X / 2, .93f * viewportSize.Y );
            howToPlayScale = viewportSize.Y / 1080f;
            howToPlayPosition = viewportSize / 2;
            howToPlayOrigin = new Vector2( howToPlay[0].Width, howToPlay[0].Height ) / 2;
              }
        }
コード例 #4
0
        public SignInMenuScreen( ScreenManager screenManager )
        {
            TransitionOnTime = TimeSpan.FromSeconds( 1 );
              TransitionOffTime = TimeSpan.FromSeconds( .25 );

              this.ScreenManager = screenManager;
              ContentManager content = screenManager.Game.Content;
              GraphicsDevice device = screenManager.GraphicsDevice;

              boxModel = content.Load<CustomModel>( "Models/signInBox" );
              foreach ( CustomModel.ModelPart part in boxModel.ModelParts )
              {
            part.Effect.CurrentTechnique = part.Effect.Techniques["Color"];
              }

              camera = new Camera( MathHelper.PiOver4, device.Viewport.AspectRatio, 1, 100,
                           new Vector3( 0, 0, 10 ), new Vector3( 0, 0, 0 ) );

              StaticImageMenuItem item;
              Vector2 itemPosition;

              SpriteFont nameFont = content.Load<SpriteFont>( "Fonts/signInNameFont" );
              Texture2D joinTexture = content.Load<Texture2D>( "Textures/aJoinText" );
              Texture2D addCpuTexture = content.Load<Texture2D>( "Textures/xAddCPUText" );
              Texture2D removeCpuTexture = content.Load<Texture2D>( "Textures/yRemoveCPUText" );
              Texture2D aStartTexture = content.Load<Texture2D>( "Textures/aStartText" );
              Texture2D readyTexture = content.Load<Texture2D>( "Textures/readyText" );

              screenScale = device.Viewport.Height / 1080f;
              textScale *= screenScale;

              Rectangle rectangle = ScreenRects.FourByThree;

              float x = textColumnStart * (float)rectangle.Width + (float)rectangle.X;
              float xStep = (float)rectangle.Width * ( 1f - ( 2f * textColumnStart ) ) / 3f;

              float nameY = nameHeight * (float)rectangle.Height + (float)rectangle.Y;
              float joinY = joinHeight * (float)rectangle.Height + (float)rectangle.Y;
              float cpuY = cpuHeight * (float)rectangle.Height + (float)rectangle.Y;
              float readyY = readyHeight * (float)rectangle.Height + (float)rectangle.Y;

              // Full version required for multiplayer
              Vector2 nagPos = new Vector2( device.Viewport.Width / 2, device.Viewport.Height * .14f );
              nagText = new TextMenuItem( this, nagPos, "Full version required for multiplayer.", nameFont );
              nagText.TransitionOnPosition = nagPos;
              nagText.TransitionOffPosition = nagPos;
              nagText.Centered = true;
              nagText.Color = Color.DarkOrange;
              nagText.DeathBegin = .01f;
              MenuItems.Add( nagText );

              for ( int i = 0; i < 4; ++i )
              {
            // <GAMERTAG>
            itemPosition = new Vector2( x, nameY );
            TextMenuItem textItem = new TextMenuItem( this, itemPosition, null, nameFont );
            textItem.Centered = true;
            textItem.MaxWidth = xStep;
            textItem.Scale = screenScale;
            slots[i].NameItem = textItem;
            MenuItems.Add( textItem );

            // A Join
            itemPosition = new Vector2( x, joinY );
            item = new StaticImageMenuItem( this, itemPosition, joinTexture );
            item.SetImmediateScale( textScale );
            slots[i].JoinItem = item;
            MenuItems.Add( item );

            // X Add CPU
            itemPosition = new Vector2( x, cpuY );
            item = new StaticImageMenuItem( this, itemPosition, addCpuTexture );
            item.SetImmediateScale( textScale );
            slots[i].AddCPUItem = item;
            MenuItems.Add( item );

            // Y Add CPU
            itemPosition = new Vector2( x, cpuY );
            item = new StaticImageMenuItem( this, itemPosition, removeCpuTexture );
            item.SetImmediateScale( textScale );
            slots[i].RemoveCPUItem = item;
            MenuItems.Add( item );

            // A Start
            itemPosition = new Vector2( x, readyY );
            item = new StaticImageMenuItem( this, itemPosition, aStartTexture );
            item.SetImmediateScale( textScale );
            slots[i].StartItem = item;
            MenuItems.Add( item );

            // Ready!
            itemPosition = new Vector2( x, readyY );
            item = new StaticImageMenuItem( this, itemPosition, readyTexture );
            item.SetImmediateScale( textScale );
            slots[i].ReadyItem = item;
            MenuItems.Add( item );

            x += xStep;
              }
        }
コード例 #5
0
ファイル: Powerup.cs プロジェクト: yxrkt/AvatarHamsterPanic
        public static void Initialize( GameplayScreen screen )
        {
            Powerup.screen = screen;
              GraphicsDevice device = screen.ScreenManager.GraphicsDevice;
              vertexDeclaration = new VertexDeclaration( device, VertexPositionColor.VertexElements );

              ContentManager content = screen.Content;

              shakeModel = content.Load<CustomModel>( "Models/milkshake" );
              InitializeShakeColors();

              goldShakeModel = content.Load<CustomModel>( "Models/goldshake" );
              foreach ( CustomModel.ModelPart part in goldShakeModel.ModelParts )
              {
            part.Effect.CurrentTechnique = part.Effect.Techniques["Color"];
            part.EffectParamColor.SetValue( ColorHelper.ColorFromUintRgb( 0xCFB53B ).ToVector4() );
            part.Effect.Parameters["Mask"].SetValue( MaskHelper.Glow( .85f ) );
            part.Effect.Parameters["SpecularPower"].SetValue( 180 );
              }

              shrimpModel = content.Load<CustomModel>( "Models/shrimp" );
              foreach ( CustomModel.ModelPart part in shrimpModel.ModelParts )
            part.Effect.CurrentTechnique = part.Effect.Techniques["DiffuseColor"];

              hammerModel = content.Load<CustomModel>( "Models/hammer" );

              laserModel = content.Load<CustomModel>( "Models/gun" );
              foreach ( CustomModel.ModelPart part in laserModel.ModelParts )
            part.Effect.CurrentTechnique = part.Effect.Techniques["DiffuseColor"];

              boltModel = content.Load<CustomModel>( "Models/bolt" );
              foreach ( CustomModel.ModelPart part in boltModel.ModelParts )
            part.Effect.CurrentTechnique = part.Effect.Techniques["DiffuseColor"];

              initialTransforms.Add( shakeModel, Matrix.CreateRotationZ( MathHelper.ToRadians( 15 ) ) );
              initialTransforms.Add( goldShakeModel, Matrix.CreateRotationZ( MathHelper.ToRadians( 15 ) ) );
              initialTransforms.Add( shrimpModel, Matrix.CreateRotationY( MathHelper.PiOver2 ) );
              initialTransforms.Add( hammerModel, Matrix.CreateRotationZ( MathHelper.ToRadians( 30 ) ) );
              initialTransforms.Add( laserModel, Matrix.CreateRotationZ( MathHelper.ToRadians( -20 ) ) );
              initialTransforms.Add( boltModel, Matrix.Identity );

              float maxPowerupSize = 2f;
              Camera camera = screen.Camera;
              float dist = camera.Position.Z + maxPowerupSize / 2f;
              float height = dist * (float)Math.Tan( camera.Fov / 2f );
              DeathLine = height + maxPowerupSize / 2f;

              const int poolSize = 20;
              pool = new Powerup[poolSize];
              for ( int i = 0; i < poolSize; ++i )
            pool[i] = new Powerup( screen );
        }
コード例 #6
0
ファイル: LaserBeam.cs プロジェクト: yxrkt/AvatarHamsterPanic
        public static void Initialize()
        {
            model = GameplayScreen.Instance.Content.Load<CustomModel>( "Models/cylinder" );

              Vector4 color = new Color( Color.Green, 1f ).ToVector4();
              Vector4 maskValue = MaskHelper.Glow( 1f );
              foreach ( CustomModel.ModelPart part in model.ModelParts )
              {
            part.Effect.CurrentTechnique = part.Effect.Techniques["Color"];
            part.Effect.Parameters["Color"].SetValue( color );
            part.Effect.Parameters["Mask"].SetValue( maskValue );
            //part.Effect.Parameters["LightingEnabled"].SetValue( false );
              }
        }
コード例 #7
0
        public ScoreboardMenuScreen( ScreenManager screenManager, Slot[] slots )
        {
            TransitionOnTime = TimeSpan.FromSeconds( 0 );

              ScreenManager = screenManager;

              ContentManager content = ScreenManager.Game.Content;

              podiumModel = content.Load<CustomModel>( "Models/podium" );
              foreach ( CustomModel.ModelPart part in podiumModel.ModelParts )
              {
            part.Effect.CurrentTechnique = part.Effect.Techniques["DiffuseColor"];
              }

              swipeMask = content.Load<Texture2D>( "Textures/swipeMask" );

              podiumTransform = Matrix.CreateScale( podiumSize );

              spriteBatch = ScreenManager.SpriteBatch;

              float aspect = ScreenManager.GraphicsDevice.Viewport.AspectRatio;
              camera = new Camera( MathHelper.PiOver4, aspect, 1f, 100f, new Vector3( 0, 2, 10 ), new Vector3( 0, 2, 0 ) );

              device = ScreenManager.GraphicsDevice;
              renderState = device.RenderState;

              screenScale = (float)device.Viewport.Height / 1080f;

              screenTextureQuad = new VertexPositionTexture[4];
              screenTextureQuad[0].Position = new Vector3( 0, 0, 0 );
              screenTextureQuad[1].Position = new Vector3( device.Viewport.Width, 0, 0 );
              screenTextureQuad[2].Position = new Vector3( device.Viewport.Width, device.Viewport.Height, 0 );
              screenTextureQuad[3].Position = new Vector3( 0, device.Viewport.Height, 0 );
              screenTextureQuad[0].TextureCoordinate = new Vector2( 0, 0 );
              screenTextureQuad[1].TextureCoordinate = new Vector2( 1, 0 );
              screenTextureQuad[2].TextureCoordinate = new Vector2( 1, 1 );
              screenTextureQuad[3].TextureCoordinate = new Vector2( 0, 1 );

              screenColorQuad = new VertexPositionColor[4];
              screenColorQuad[0].Position = new Vector3( 0, 0, 0 );
              screenColorQuad[1].Position = new Vector3( device.Viewport.Width, 0, 0 );
              screenColorQuad[2].Position = new Vector3( device.Viewport.Width, device.Viewport.Height, 0 );
              screenColorQuad[3].Position = new Vector3( 0, device.Viewport.Height, 0 );
              for ( int i = 0; i < 4; ++i )
            screenColorQuad[i].Color = Color.Black;

              swipeQuad = new VertexPositionTexture[4];
              float a = device.Viewport.Width / 2;
              float b = device.Viewport.Height / 2;
              maskRadius = (float)Math.Sqrt( a * a + b * b );
              float xMin = a - maskRadius;
              float xMax = a + maskRadius;
              float yMin = b - maskRadius;
              float yMax = b + maskRadius;
              swipeQuad[0].Position = new Vector3( xMin, yMin, 0 );
              swipeQuad[1].Position = new Vector3( xMax, yMin, 0 );
              swipeQuad[2].Position = new Vector3( xMax, yMax, 0 );
              swipeQuad[3].Position = new Vector3( xMin, yMax, 0 );
              swipeQuad[0].TextureCoordinate = new Vector2( 0, 0 );
              swipeQuad[1].TextureCoordinate = new Vector2( 1, 0 );
              swipeQuad[2].TextureCoordinate = new Vector2( 1, 1 );
              swipeQuad[3].TextureCoordinate = new Vector2( 0, 1 );

              vertexBuffer = new VertexPositionTexture[4];
              vertexBuffer[0].TextureCoordinate = new Vector2( 0, 0 );
              vertexBuffer[1].TextureCoordinate = new Vector2( 1, 0 );
              vertexBuffer[2].TextureCoordinate = new Vector2( 1, 1 );
              vertexBuffer[3].TextureCoordinate = new Vector2( 0, 1 );

              screenCenter = new Vector3( a, b, 0 );

              effect = ScreenQuadEffect.CreateScreenQuadEffect( device, content );

              dadtOut = MathHelper.Pi * maskRadius * maskRadius / swipeOutDuration;
              dadtIn = MathHelper.Pi * maskRadius * maskRadius / swipeInDuration;

              players = new ScoreboardPlayer[4];

              places = new Vector3[4];
              places[0] = podiumTransform.Translation + new Vector3( 0, podiumSize, 0 );
              places[1] = places[0] + new Vector3( -podiumSize, -.4f * podiumSize, 0 );
              places[2] = places[0] + new Vector3( podiumSize, -.5f * podiumSize, 0 );
              places[3] = podiumTransform.Translation + new Vector3( 3 * podiumSize, .125f, 0 );

              animSpeeds = new float[4];
              animSpeeds[0] = .95f;
              animSpeeds[1] = .8f;
              animSpeeds[2] = 1.1f;
              animSpeeds[3] = 1f;

              popupScreen = new ScoreboardPopupMenuScreen( screenManager, slots );

              pressAToContinueText = content.Load<Texture2D>( "Textures/pressAToContinueText" );
              pressAPosition = new Vector2( screenCenter.X, .8f * device.Viewport.Height );
              pressAOrigin = new Vector2( pressAToContinueText.Width, pressAToContinueText.Height ) / 2;

              loserBoxModel = content.Load<CustomModel>( "Models/loserBox" );
              foreach ( CustomModel.ModelPart part in loserBoxModel.ModelParts )
            part.Effect.CurrentTechnique = part.Effect.Techniques["Color"];
              loserBoxTransform = Matrix.CreateTranslation( 3 * podiumSize, 0, 0 );

              int rectWidth  = (int)( 900 * screenScale + .5f );
              int rectHeight = (int)( 245 * screenScale + .5f );
              scoreboardRect = new Rectangle( ( device.Viewport.Width - rectWidth ) / 2,
                                      (int)( 60 * screenScale + .5f ),
                                      rectWidth, rectHeight );

              playerScoreBar = content.Load<Texture2D>( "Textures/playerScoreboardBar" );
              playerNameBox = content.Load<Texture2D>( "Textures/playerNameBox" );
              scoreText = content.Load<Texture2D>( "Textures/scoreText" );
              winsText = content.Load<Texture2D>( "Textures/winsText" );

              playerScoreBarPositions = new Vector2[4];
              int y = scoreboardRect.Top + (int)( 41 * screenScale + .5f );
              for ( int i = 0; i < 4; ++i )
              {
            playerScoreBarPositions[i] = new Vector2( scoreboardRect.Left + 1, y );
            y += (int)( playerScoreBar.Height * screenScale ) + (int)( 4 * screenScale + .5f );
              }

              playerNameBoxPositions = new Vector2[4];
              for ( int i = 0; i < 4; ++i )
              {
            Vector2 pos = Vector2.Zero;
            pos.X = scoreboardRect.Left + 58 * screenScale;
            pos.Y = playerScoreBarPositions[i].Y + 5 * screenScale;
            playerNameBoxPositions[i] = pos;
              }

              scoreboardFont = content.Load<SpriteFont>( "Fonts/scoreboardFont" );
              scoreboardNumberFont = content.Load<SpriteFont>( "Fonts/scoreboardNumberFont" );
              scoreboardSubscriptFont = content.Load<SpriteFont>( "Fonts/scoreboardSubscriptFont" );
              stringBuffer = new StringBuilder( 2 );
              cpuNameString = "CPU";

              addColorEffect = content.Load<Effect>( "Effects/addColorEffect" );
              addColorEffect.CurrentTechnique = addColorEffect.Techniques[0];

              background = content.Load<Texture2D>( "Textures/menuBackground" );

              scoresRecorded = false;
        }