Example #1
0
 private LaserBeam( GameplayScreen screen )
     : base(screen)
 {
     body = new PhysPolygon( 0f, beamThickness, Vector2.Zero, 1f );
       body.Collided += HandlePlayerCollision;
       body.Flags = BodyFlags.Anchored | BodyFlags.Ghost;
 }
Example #2
0
 FloorBlock( GameplayScreen screen )
     : base(screen)
 {
     BoundingPolygon = new PhysPolygon( Size, Height, Vector2.Zero, 1 );
       BoundingPolygon.Elasticity = 1f;
       BoundingPolygon.Friction = 1.5f;
       BoundingPolygon.Flags = BodyFlags.Anchored;
       BoundingPolygon.Parent = this;
       BoundingPolygon.Collided += KillSelfIfPwnt;
 }
Example #3
0
        public ReadyGo( GameplayScreen screen, Vector2 position )
            : base(screen)
        {
            this.position = position;

              ContentManager content = Screen.Content;

              readyTexture = content.Load<Texture2D>( "Textures/bigReadyText" );
              goTexture = content.Load<Texture2D>( "Textures/goText" );

              currentTexture = readyTexture;

              spring.SetSource( 0 );
              spring.SetDest( 1 );

              screenScale = Screen.ScreenManager.GraphicsDevice.Viewport.Height / 1080f;
        }
Example #4
0
        private Powerup( GameplayScreen screen )
            : base(screen)
        {
            Body = new PhysCircle( 1f, Vector2.Zero, 1f );
              Body.Flags = BodyFlags.Anchored | BodyFlags.Ghost;
              Body.Parent = this;

              Oscillator = new SpringInterpolater( 1, 10, 0 );
              SizeSpring = new SpringInterpolater( 1, 200, .15f * SpringInterpolater.GetCriticalDamping( 200 ) );
              LockToPlayerSpring = new SpringInterpolater( 2, 100, SpringInterpolater.GetCriticalDamping( 100 ) );
              RotationSpring = new SpringInterpolater( 1, 15, SpringInterpolater.GetCriticalDamping( 15 ) );
              Oscillator.Active = true;
              SizeSpring.Active = true;
              LockToPlayerSpring.Active = true;
              RotationSpring.Active = true;

              DrawOrder = 6;
        }
        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 );
              }
        }
Example #6
0
 public GameObject( GameplayScreen screen )
 {
     Screen = screen;
 }
Example #7
0
        public Boundary( GameplayScreen screen, float left, float right, float rowStart, float rowSpacing )
            : base(screen)
        {
            Left  = left;
              Right = right;

              lastFrame = new GameTime( TimeSpan.FromSeconds( 0 ), TimeSpan.FromSeconds( 0 ),
                                TimeSpan.FromSeconds( 1f / 30f ), TimeSpan.FromSeconds( 1f / 60 ) );

              this.rowSpacing = rowSpacing;
              this.rowStart = rowStart;
              minHoleDist = ( FloorBlock.Height + Size ) / 2f;
              lastHole = rowStart;
              lastGoldenShake = 0;

              DrawOrder = 7;

              // this is for objects, such as powerups and players, so they can travel through the tubes
              objects = new List<BoundaryTubeObject>( 10 );
              for ( int i = 0; i < 10; ++i )
            objects.Add( new BoundaryTubeObject() );

              // left polygon
              polyLeft = new PhysPolygon( polyWidth, 100f, new Vector2( left - halfPolyWidth, 0f ), 1f );
              polyLeft.Elasticity = 1f;
              polyLeft.Friction = 1.5f;
              polyLeft.Flags = BodyFlags.Anchored;
              polyLeft.Parent = this;
              screen.PhysicsSpace.AddBody( polyLeft );

              // right polygon
              polyRight = new PhysPolygon( polyWidth, 100f, new Vector2( right + halfPolyWidth, 0f ), 1f );
              polyRight.Elasticity = 1f;
              polyRight.Friction = 1.5f;
              polyRight.Flags = BodyFlags.Anchored;
              polyRight.Parent = this;
              screen.PhysicsSpace.AddBody( polyRight );

              // model
              cageModel = Screen.Content.Load<InstancedModel>( "Models/cageTile" );
              cageHoleModel = Screen.Content.Load<InstancedModel>( "Models/cageHole" );
              teeModel = Screen.Content.Load<InstancedModel>( "Models/tubeTee" );
              cupModel = Screen.Content.Load<InstancedModel>( "Models/tubeCup" );

              Camera camera = screen.Camera;

              float dist = camera.Position.Z + Size / 2f;
              float tanFovyOverTwo = (float)Math.Tan( camera.Fov / 2f );
              deathLine = dist * tanFovyOverTwo + Size / 2f;

              topLine = camera.Position.Y + deathLine - Size;
              lastTopY = camera.Position.Y + deathLine;

              rows = (int)Math.Ceiling( 2f * deathLine / Size );
              nTransforms = rows * 2;

              rotateL = new Matrix( 0, 0,-1, 0,
                            0, 1, 0, 0,
                            1, 0, 0, 0,
                            0, 0, 0, 1 );
              rotateR = new Matrix( 0, 0, 1, 0,
                            0, 1, 0, 0,
                           -1, 0, 0, 0,
                            0, 0, 0, 1 );
              rotateZ = new Matrix( 0, 1, 0, 0,
                           -1, 0, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1 );
              flip = new Matrix(-1, 0, 0, 0,
                         0,-1, 0, 0,
                         0, 0, 1, 0,
                         0, 0, 0, 1 );
              scale = Matrix.CreateScale( Size );

              sidePieces = new SidePiece[nTransforms];
              for ( int i = 0; i < nTransforms; ++i )
              {
            sidePieces[i] = new SidePiece();
            SidePiece piece = sidePieces[i];

            int row = i % rows;
            bool onLeftSide = i / rows == 0;
            piece.Hole = false;
            piece.CagePosition = new Vector3( onLeftSide ? Left : Right, topLine - row * Size, 0f );
            Matrix scaleRotate = scale * ( onLeftSide ? rotateL : rotateR );
            piece.CageTransform = scaleRotate * Matrix.CreateTranslation( piece.CagePosition );
            piece.TubePosition = piece.CagePosition + new Vector3( onLeftSide ? -Size / 2 : Size / 2, 0, 0 );
            piece.TubeTransform = scale * Matrix.CreateTranslation( piece.TubePosition );
            piece.Tube = TubePattern.Cup;
              }
        }
Example #8
0
        public TubeMaze( GameplayScreen screen, float z, float tubeSize )
            : base(screen)
        {
            float alpha = .15f;
              colors = new Vector4[]
              {
            new Vector4( 1f, .7f, .7f, alpha ),
            new Vector4( .7f, 1f, .7f, alpha ),
            new Vector4( .7f, .7f, 1f, alpha ),
            new Vector4( 1f, 1f, .7f,  alpha )
              };

              DrawOrder = 0;

              ContentManager content = screen.Content;

              tubeModels = new InstancedModel[4];
              tubeModels[(int)TubePattern.Elbow] = content.Load<InstancedModel>( "Models/tubeElbow" );
              tubeModels[(int)TubePattern.Cup]   = content.Load<InstancedModel>( "Models/tubeCup" );
              tubeModels[(int)TubePattern.Tee]   = content.Load<InstancedModel>( "Models/tubeTee" );
              tubeModels[(int)TubePattern.Cross] = content.Load<InstancedModel>( "Models/tubeCross" );
              foreach ( InstancedModel model in tubeModels )
            model.SetInstancingTechnique( InstancingTechnique.Color );

              Camera camera = screen.Camera;

              TubeSize = tubeSize;
              float dist = camera.Position.Z - ( z - TubeSize / 2f );
              float tanFovyOverTwo = (float)Math.Tan( camera.Fov / 2f );
              DeathLine = dist * tanFovyOverTwo + TubeSize / 2f;

              rows = (int)Math.Ceiling( 2f * DeathLine / TubeSize );

              float aspect = screen.ScreenManager.GraphicsDevice.Viewport.AspectRatio;
              float fovxOverTwo = (float)Math.Atan( aspect * tanFovyOverTwo );
              float worldWidth = 2f * ( dist * (float)Math.Tan( fovxOverTwo ) + TubeSize / 2f );

              cols = (int)Math.Ceiling( worldWidth / TubeSize );

              tubes = new TubePiece[rows, cols];
              int maxPipes = rows * cols;
              cupRow = ( rows % 2 == 1 );

              scaleMatrix = Matrix.CreateScale( tubeSize );

              topLeft = new Vector3( camera.Position.X - tubeSize * (float)cols / 2f + TubeSize / 2f,
                             camera.Position.Y + DeathLine - TubeSize, z );
              highestRow = 0;

              InitializeGrid();
        }
Example #9
0
        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 );
        }
        /// <summary>
        /// Unload graphics content used by the game.
        /// </summary>
        public override void UnloadContent()
        {
            LaserBeam.Unload();
              PlayerAI.RemoveAllRows();
              ReadOnlyCollection<Player> players = ObjectTable.GetObjects<Player>();
              for ( int i = 0; i < players.Count; ++i )
            players[i].OnDestruct();
              ObjectTable.Clear();
              Game game = ScreenManager.Game;
              ParticleManager.Unload();
              components.Remove( ParticleManager );
              components.Remove( PixieParticleSystem );
              components.Remove( SparkParticleSystem );
              components.Remove( PinkPixieParticleSystem );
              Content.Unload();

              if ( BackgroundMusic != null )
              {
            BackgroundMusic.Dispose();
            BackgroundMusic = null;

            GameCore.Instance.MusicVolumeChanged -= ChangeMusicVolume;
              }

              if ( nextInstance != null )
              {
            instance = nextInstance;
            nextInstance = null;
              }
              else
              {
            instance = null;
              }
        }
Example #11
0
        public static void Initialize( GameplayScreen screen )
        {
            Camera camera = screen.Camera;
              ContentManager content =  screen.Content;

              float depth = camera.Position.Z + Size / 2f;
              float height = depth * (float)Math.Tan( camera.Fov / 2f );
              DeathLine = height + Height / 2f;
              BirthLine = -DeathLine;

              vertexDeclaration = new VertexDeclaration( screen.ScreenManager.GraphicsDevice,
                                                 VertexPositionNormalTexture.VertexElements );

              Model = content.Load<Model>( "Models/block" );
              DiffuseMap = content.Load<Texture2D>( "Textures/glassDiffuse" );
              NormalMap = content.Load<Texture2D>( "Textures/glassNormal" );

              ShatteredModel = content.Load<Model>( "Models/block_broken" );

              effect = content.Load<Effect>( "Effects/basic" );
              effect.CurrentTechnique = effect.Techniques["DiffuseColor"];
              effect.Parameters["DiffuseMap"].SetValue( DiffuseMap );
              effect.Parameters["NormalMap"].SetValue( NormalMap );

              effectParameterWorld = effect.Parameters["World"];
              effectParameterView = effect.Parameters["View"];
              effectParameterProjection = effect.Parameters["Projection"];
              effectParameterEye = effect.Parameters["Eye"];

              for ( int i = 0; i < maxBlocks; ++i )
            pool[i] = new FloorBlock( screen );
        }
Example #12
0
        public Player( GameplayScreen screen, int playerNumber, PlayerIndex playerIndex, Avatar avatar, Vector2 pos, uint id )
            : base(screen)
        {
            WheelModel = screen.Content.Load<CustomModel>( "Models/hamsterBall" );
              foreach ( CustomModelSample.CustomModel.ModelPart part in WheelModel.ModelParts )
              {
            part.Effect.CurrentTechnique = part.Effect.Techniques["Color"];
            part.Effect.Parameters["Color"].SetValue( new Vector4( .8f, .7f, 1f, .225f ) );
            part.Effect.Parameters["SpecularPower"].SetValue( 400 );
            part.Effect.Parameters["Mask"].SetValue( MaskHelper.MotionBlur( 1 ) );
              }

              DrawOrder = 8;

              WinState = PlayerWinState.None;

              soundPosition = Vector3.Zero;
              soundVelocity = Vector3.Zero;

              float depth = screen.Camera.Position.Z;
              DeathLine = depth * (float)Math.Tan( screen.Camera.Fov / 2f );

              RespawnTime = float.MaxValue;

              shrinkBegin = 0;
              Scale = 1f;
              ScaleSpring = new SpringInterpolater( 1, 200, SpringInterpolater.GetCriticalDamping( 200 ) );
              ScaleSpring.Active = true;
              ScaleSpring.SetSource( Scale );
              ScaleSpring.SetDest( Scale );

              PlayerIndex = playerIndex;
              PlayerNumber = playerNumber;
              BoostBurnRate = 1f;
              BoostRechargeRate = .25f;

              Avatar = avatar;
              BoundingCircle = new PhysCircle( Size / 2f, pos, 10f );
              BoundingCircle.Parent = this;
              BoundingCircle.Elasticity = .4f;
              BoundingCircle.Friction = .5f;
              BoundingCircle.Collided += HandleCollision;
              BoundingCircle.Responded += HandleCollisionResponse;
              screen.PhysicsSpace.AddBody( BoundingCircle );

              walkAnim = CustomAvatarAnimationData.GetAvatarAnimationData( "Walk", Screen.Content );
              runAnim  = CustomAvatarAnimationData.GetAvatarAnimationData( "Run", Screen.Content );

              // pre-load animations for podium screen
              avatar.SetAnimation( AvatarAnimationPreset.Celebrate );
              avatar.SetAnimation( AvatarAnimationPreset.Clap );
              avatar.SetAnimation( AvatarAnimationPreset.FemaleAngry );
              avatar.SetAnimation( AvatarAnimationPreset.MaleCry );

              standAnim = (AvatarAnimationPreset)( (int)AvatarAnimationPreset.Stand0 + random.Next( 8 ) );
              avatar.SetAnimation( standAnim );

              if ( playerIndex >= PlayerIndex.One )
              {
            HUD = new PlayerHUD( this, SignedInGamer.SignedInGamers[playerIndex] );
              }
              else
              {
            HUD = new PlayerHUD( this, null );
            playerAI = new PlayerAI( this );
              }

              vertexDeclaration = new VertexDeclaration( screen.ScreenManager.GraphicsDevice,
                                                 VertexPositionNormalTexture.VertexElements );

              boosterSound = GameCore.Instance.AudioManager.Play2DCue( "booster", 1f );
              boosterSound.Pause();

              glow = new CircularGlow( new Vector3( BoundingCircle.Position, 0 ), Color.OrangeRed, Size );
              glow.Player = this;
              screen.ObjectTable.Add( glow );

              glowSpring = new SpringInterpolater( 1, 500, .75f * SpringInterpolater.GetCriticalDamping( 500 ) );
              glowSpring.Active = true;
              glowSpring.SetSource( 0 );
              glowSpring.SetDest( 0 );

              Tag = new PlayerTag( this, screen.Content.Load<SpriteFont>( "Fonts/playerTagFont" ) );

              SetID( id );
        }
Example #13
0
        public Shelves( GameplayScreen screen )
            : base(screen)
        {
            int nCages = nMaxPlayers * nCagesPerBox;
              cagePieces = new CagePiece[nCages];

              DrawOrder = 4;

              for ( int i = 0; i < nCages; ++i )
            cagePieces[i] = new CagePiece();

              hingeTransforms = new Matrix[4];

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

              cageModel = screen.Content.Load<InstancedModel>( "Models/cage" );
              hingeModel = screen.Content.Load<InstancedModel>( "Models/cageHinge" );

              // determine transforms for each piece
              boundary = screen.ObjectTable.GetObjects<Boundary>()[0];
              if ( boundary == null )
            throw new InvalidOperationException( "boundary must be initialized before shelf" );
              float totalLength = boundary.Right - boundary.Left - size - 2f * offsetFromWall;
              spacing = totalLength / 3f;

              Camera camera = Screen.Camera;

              float tanFovOver2 = (float)Math.Tan( camera.Fov / 2f );
              float depth = camera.Position.Z + size / 2f;
              float height = depth * tanFovOver2;
              topLine = height - size / 2f;

              depth = camera.Position.Z - size / 2f;
              height = depth * tanFovOver2;
              deathLine = Screen.Camera.Position.Y - height;

              // cage bottoms stored in first four indices
              for ( int i = 0; i < nMaxPlayers; ++i )
              {
            Vector3 pos = new Vector3( boundary.Left + offsetFromWall + i * spacing, topLine - size / 2f, 0f );
            cagePieces[i].Translation = Matrix.CreateTranslation( pos );
            cagePieces[i].Rotation = bottomStart;
            cagePieces[i].Transform = scale * bottomStart * cagePieces[i].Translation;
            cagePieces[i].Body = new PhysPolygon( size, .014f * size, new Vector2( pos.X + size / 2f, pos.Y ), 1f );
            cagePieces[i].Body.Friction = 1.75f;
            cagePieces[i].Body.SetPivotPoint( new Vector2( -size / 2, 0f ) );
            cagePieces[i].Body.Flags = BodyFlags.Anchored;
            cagePieces[i].Body.Parent = this;
            Screen.PhysicsSpace.AddBody( cagePieces[i].Body );

            hingeTransforms[i] = Matrix.CreateScale( size ) *
                             Matrix.CreateTranslation( new Vector3( cagePieces[i].Body.Position, 0 ) );
              }

              // all other cage pieces won't change
              for ( int i = nMaxPlayers; i < nCages; ++i )
              {
            int box = ( i - nMaxPlayers ) / 2;
            int side = i % 2;

            float x = boundary.Left + offsetFromWall + box * spacing + side * size;
            Vector3 pos = new Vector3( x, topLine, 0f );
            Matrix translation = Matrix.CreateTranslation( pos );
            Matrix rotation = side == 0 ? rotateL : rotateR;
            cagePieces[i].Translation = translation;
            cagePieces[i].Rotation = rotation;
            cagePieces[i].Transform = scale * rotation * translation;
            cagePieces[i].Body = new PhysPolygon( .014f, size, new Vector2( pos.X, pos.Y ), 1f );
            cagePieces[i].Body.Flags = BodyFlags.Anchored;
            cagePieces[i].Body.Parent = this;
            Screen.PhysicsSpace.AddBody( cagePieces[i].Body );
              }
        }