Example #1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (CubeGame game = new CubeGame())
     {
         game.Run();
     }
 }
Example #2
0
        public Quarterpipe( CubeGame game,
                            World world,
                            float radius,
                            Vector2 position,
                            Type type,
                            BodyType bodyType = BodyType.Static,
                            float density = 1,
                            Category categories = Constants.Categories.DEFAULT )
            : base(game, world, position.ToUnits(), AngleFromType( type ), new QuarterpipeMaker( radius ))
        {
            mRadius = radius;

            FixtureFactory.AttachChainShape(
                MakeArc( 100, radius.ToUnits(), 0 ),
                Body,
                new Concave() );

            var fixtureList = FixtureFactory.AttachCompoundPolygon(
                Triangulate.ConvexPartition(
                    MakeArc( 10, radius.ToUnits(), 0 ),
                    TriangulationAlgorithm.Earclip ),
                density,
                Body );

            foreach ( var f in fixtureList )
                f.CollidesWith = Category.None;

            Body.BodyType = bodyType;
            Body.CollisionCategories = categories;

            Initialize();
        }
Example #3
0
 public Solid( CubeGame game, World world, Body body )
 {
     Game = game;
     mWorld = world;
     Body = body;
     Initialize();
 }
Example #4
0
        public HazardBox( CubeGame game,
                          World world,
                          RectangleF rec,
                          BodyType bodyType = BodyType.Static,
                          float density = 1,
                          Category categories = Constants.Categories.DEFAULT,
                          Category killCategories = Constants.Categories.ACTORS )
            : base(game, world, rec.Center.ToUnits(), 0, new HazardBoxMaker( rec.Width, rec.Height ))
        {
            mWidth = rec.Width;
            mHeight = rec.Height;

            Fixture box = FixtureFactory.AttachRectangle(
                    mWidth.ToUnits(),
                    mHeight.ToUnits(),
                    density,
                    Vector2.Zero,
                    Body,
                    new Flat() );

            Fixture killBox = box.CloneOnto( Body );
            killBox.IsSensor = true;
            killBox.UserData = new Hazard( "killbox" );

            Body.BodyType = bodyType;
            Body.CollisionCategories = categories;

            killBox.CollidesWith = killCategories;
            box.CollidesWith ^= killCategories;
        }
Example #5
0
        public Camera( CubeGame game )
            : base(game)
        {
            #region Init Projection
            mFov = new AnimatedVariable<float>( Utils.Tween );
            mAspectRatio = new AnimatedVariable<float>( Utils.Tween );
            mNearPlaneDist = new AnimatedVariable<float>( Utils.Tween );
            mFarPlaneDist = new AnimatedVariable<float>( Utils.Tween );

            mFov.ValueChanged += OnProjectionValueChanged;
            mAspectRatio.ValueChanged += OnProjectionValueChanged;
            mNearPlaneDist.ValueChanged += OnProjectionValueChanged;
            mFarPlaneDist.ValueChanged += OnProjectionValueChanged;
            #endregion

            #region Init View
            mPosition = new AnimatedVariable<Vector3>( (v0, v1, d)
                => Vector3.Distance( v0, v1 ) > d / 10 ? v0.Slerp( v1, d ) : v1 );

            mTarget = new AnimatedVariable<Vector3>( (v0, v1, d)
                => Vector3.Distance( v0, v1 ) > d ? v0.Slerp( v1, d ) : v1 );

            mUpVector = new AnimatedVariable<Vector3>( Vector3.Up, (v0, v1, d)
                => Vector3.Distance( v0, v1 ) > d ? v0.Slerp( v1, d * 10 ) : v1 );

            mPosition.ValueChanged += OnViewValueChanged;
            mTarget.ValueChanged += OnViewValueChanged;
            mUpVector.ValueChanged += OnViewValueChanged;

            mPosition.ValueChanged += FixNaN;
            mTarget.ValueChanged += FixNaN;
            mUpVector.ValueChanged += FixNaN;
            #endregion
        }
Example #6
0
 /// <summary>
 /// Creates a new EditScreen.
 /// </summary>
 /// <param name="game">Game the EditScreen should be associated with.</param>
 /// <param name="editCube">EditableCube the screen should display.</param>
 public EditScreen( CubeGame game, EditableCube editCube )
     : base(game, editCube)
 {
     ScreenProperties = new EditScreenProperties( this );
     LeftBrush = new BoxBrush( game );
     RightBrush = new HandBrush( game );
     MiddleBrush = new StartPositionBrush( game );
 }
Example #7
0
        public Actor( CubeGame game, CubeScreen screen, Cube cube, Vector3 worldPos, Direction upDir )
            : this(game, screen)
        {
            Cube = cube;
            mCubePosition = worldPos;
            UpDir = upDir;

            CubeFace = Cube.GetFaceFromPosition( mCubePosition );
        }
        public OneWayPlatform( CubeGame game, World world, Body body, Line2 line )
            : base(game, world, body)
        {
            mLine = line - line.Center;

            mPlatform = Body.FindFixture( new SolidDescriptor( "platform" ) );
            mExclusionRec = Body.FindFixture( new SolidDescriptor( "exclusion" ) );

            Initialize();
        }
Example #9
0
 protected Solid( CubeGame game,
                  World world,
                  Vector2 position = default( Vector2 ),
                  float rotation = 0,
                  ISolidMaker solidMaker = null )
 {
     Game = game;
     mWorld = world;
     Body = BodyFactory.CreateBody( World, position, rotation, solidMaker );
     Initialize();
 }
        public EditableCube( CubeGame game, EditScreen screen = null )
            : base(game, screen)
        {
            mFrontFace.BackgroundColor = Color.Red;
            mBackFace.BackgroundColor = Color.Orange;
            mTopFace.BackgroundColor = Color.Blue;
            mBottomFace.BackgroundColor = Color.Green;
            mLeftFace.BackgroundColor = Color.Purple;
            mRightFace.BackgroundColor = Color.Yellow;

            CameraDistance = 5;
        }
Example #11
0
        public MenuScreen( CubeGame game )
            : base(game)
        {
            verString = "v1.0";

            currentHighlight = Highlight.NewGame;

            cSelected = new Color(0, 240, 255, 255);
            isFading = true;
            cNewGame = Color.White;
            cLoadGame = Color.White;
            //cLevelEdit = Color.White;
            cControls = Color.White;
            cExit = Color.White;

            resetTime = 0.5f;
        }
        public EndLevelScreen(CubeGame game, string levelName, PlayScreen level)
            : base(game)
        {
            pLevelName = levelName;
            pSaveData = SaveData.Load(pLevelName);

            mLevel = level;
            mTextBox = new TextBox(game, game);

            mTextBox.Visible = false;
            bSendingScore = false;
            bSentScore = false;

            // TODO: Replace Tester with user's name
            // pSaveData.AddScore( pScore, "The World's #1" );
            // pSaveData.Save( pLevelName );
        }
Example #13
0
        public Quarterpipe( CubeGame game, World world, Body body, float radius )
            : base(game, world, body)
        {
            mRadius = radius;

            Fixture curve = Body.FindFixture( new Concave() );
            var tmpCat = curve.CollisionCategories;
            Body.DestroyFixture( curve );

            curve = FixtureFactory.AttachChainShape(
                MakeArc( 10 * (int) Math.Sqrt( radius ), radius.ToUnits(), 0 ),
                Body,
                new Concave() );

            curve.CollisionCategories = tmpCat;
            Initialize();
        }
Example #14
0
        /// <summary>
        /// Creates a new CubeScreen.
        /// </summary>
        /// <param name="game">Game the CubeScreen should be associated with.</param>
        /// <param name="cube">Cube the screen should display.</param>
        public CubeScreen( CubeGame game, Cube cube )
            : base(game)
        {
            Cube = cube;
            Cube.Screen = this;
            Hud = new GameHud( this );
            Camera = new Camera( Game );

            Cube.UpdateOrder = 2;

            Hud.UpdateOrder = 2;
            Hud.DrawOrder = 2;

            Camera.UpdateOrder = 2;

            Components.Add( Hud );
            Components.Add( Cube );
            Components.Add( Camera );
        }
Example #15
0
        public PauseScreen( CubeGame game )
            : base(game)
        {
            currentHighlight = Highlight.ResumeGame;

            cSelected = new Color(0, 240, 255, 255);
            isFading = true;

            cResumeGame = Color.White;
            //cSaveGame = Color.White;
            cControls = Color.White;
            cQuit = Color.White;

            bg = new Rectangle(game.GraphicsDevice.Viewport.Width / 4,
                               game.GraphicsDevice.Viewport.Height / 4,
                               game.GraphicsDevice.Viewport.Width / 2,
                               game.GraphicsDevice.Viewport.Height / 2);

            bStart = new Vector2(game.GraphicsDevice.Viewport.Width / 2 - sResumeGame.Width / 2, 150);
        }
Example #16
0
        /// <summary>
        /// Creates a new PlayScreen.
        /// </summary>
        /// <param name="game">Game the PlayScreen should be associated with.</param>
        /// <param name="playCube">PlayableCube the screen should display.</param>
        public PlayScreen( CubeGame game, PlayableCube playCube )
            : base(game, playCube)
        {
            MediaPlayer.Volume = mVolume;
            //MediaPlayer.Play(mSong);
            MediaPlayer.IsRepeating = true;

            /*Random rand = new Random();

            for ( int i = 0 ; i < 10 ; ++i )
            {
                PlayableCube cube = new PlayableCube( Game, this );
                cube.Position = new Vector3(
                    (float) (rand.NextDouble() - 0.5) * 10,
                    (float) (rand.NextDouble() - 0.5) * 10,
                    (float) (rand.NextDouble() - 0.5) * 10 );

                cube.Enabled = false;
                Components.Add( cube );
            }*/
        }
Example #17
0
        public EndDoor( CubeGame game,
                        World world,
                        Vector2 pos,
                        string nextLevel = null,
                        BodyType bodyType = BodyType.Static,
                        float density = 1,
                        Category categories = Category.Cat1 )
            : base(game, world, pos.ToUnits(), 0, new EndDoorMaker())
        {
            var door = FixtureFactory.AttachRectangle(
                    WIDTH.ToUnits(),
                    HEIGHT.ToUnits(),
                    density,
                    Vector2.Zero,
                    Body,
                    new Door( nextLevel ) );

            door.IsSensor = true;

            Body.BodyType = bodyType;
            Body.CollisionCategories = categories;
        }
Example #18
0
        public Box(CubeGame game,
                    World world,
                    RectangleF rec,
                    BodyType bodyType = BodyType.Static,
                    float density = 1,
                    Category categories = Constants.Categories.DEFAULT)
            : base(game, world, rec.Center.ToUnits(), 0, new BoxMaker(rec.Width, rec.Height))
        {
            mWidth = rec.Width;
            mHeight = rec.Height;

            destRect = new Rectangle((int)rec.Left, (int)rec.Bottom, (int)rec.Width, (int)rec.Height);

            FixtureFactory.AttachRectangle(
                    mWidth.ToUnits(),
                    mHeight.ToUnits(),
                    density,
                    Vector2.Zero,
                    Body,
                    new Flat());

            Body.BodyType = bodyType;
            Body.CollisionCategories = categories;
        }
 /// <summary>
 /// Creates a new ScreenManager.
 /// </summary>
 /// <param name="game">Game the ScreenManager should be associated with.</param>
 public ScreenManager( CubeGame game )
     : base(game)
 {
     mScreens = new Stack< GameScreen >();
     mPendingScreens = new List< GameScreen >();
 }
 public ControlsScreen(CubeGame game)
     : base(game)
 {
 }
 public SimpleDrawableCubeGameComponent( CubeGame game )
     : base(game)
 {
 }
 public DrawableCubeScreenGameComponent( CubeGame game, CubeScreen screen )
     : base(game)
 {
     Screen = screen;
 }
 public CubeGameComponent( CubeGame game )
     : base(game)
 {
 }
Example #24
0
 public EndDoor( CubeGame game, World world, Body body )
     : base(game, world, body)
 {
 }
Example #25
0
 /// <summary>
 /// Creates a new EditScreen.
 /// </summary>
 /// <param name="game">Game the EditScreen should be associated with.</param>
 public EditScreen( CubeGame game )
     : this(game, new EditableCube( game ))
 {
 }
Example #26
0
 public HazardBox( CubeGame game, World world, Body body, float width, float height )
     : base(game, world, body)
 {
     mWidth = width;
     mHeight = height;
 }
Example #27
0
 public HandBrush( CubeGame game )
 {
     Game = game;
 }
Example #28
0
 public Solid MakeSolid( CubeGame game, World world, Body body )
 {
     return new Quarterpipe( game, world, body, Radius );
 }
Example #29
0
 public Solid MakeSolid( CubeGame game, World world, Body body )
 {
     return new HazardBox( game, world, body, Width, Height );
 }
Example #30
0
 public Solid MakeSolid( CubeGame game, World world, Body body )
 {
     return new EndDoor( game, world, body );
 }