コード例 #1
0
ファイル: Program.cs プロジェクト: theLOLflashlight/CyberCube
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (CubeGame game = new CubeGame())
     {
         game.Run();
     }
 }
コード例 #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();
        }
コード例 #3
0
ファイル: Solid.cs プロジェクト: theLOLflashlight/CyberCube
 public Solid( CubeGame game, World world, Body body )
 {
     Game = game;
     mWorld = world;
     Body = body;
     Initialize();
 }
コード例 #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;
        }
コード例 #5
0
ファイル: Camera.cs プロジェクト: theLOLflashlight/CyberCube
        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
        }
コード例 #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 );
 }
コード例 #7
0
ファイル: Actor.cs プロジェクト: theLOLflashlight/CyberCube
        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 );
        }
コード例 #8
0
        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();
        }
コード例 #9
0
ファイル: Solid.cs プロジェクト: theLOLflashlight/CyberCube
 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();
 }
コード例 #10
0
        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;
        }
コード例 #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;
        }
コード例 #12
0
        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 );
        }
コード例 #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();
        }
コード例 #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 );
        }
コード例 #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);
        }
コード例 #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 );
            }*/
        }
コード例 #17
0
ファイル: EndDoor.cs プロジェクト: theLOLflashlight/CyberCube
        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;
        }
コード例 #18
0
ファイル: Box.cs プロジェクト: theLOLflashlight/CyberCube
        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;
        }
コード例 #19
0
 /// <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 >();
 }
コード例 #20
0
 public ControlsScreen(CubeGame game)
     : base(game)
 {
 }
コード例 #21
0
 public SimpleDrawableCubeGameComponent( CubeGame game )
     : base(game)
 {
 }
コード例 #22
0
 public DrawableCubeScreenGameComponent( CubeGame game, CubeScreen screen )
     : base(game)
 {
     Screen = screen;
 }
コード例 #23
0
 public CubeGameComponent( CubeGame game )
     : base(game)
 {
 }
コード例 #24
0
ファイル: EndDoor.cs プロジェクト: theLOLflashlight/CyberCube
 public EndDoor( CubeGame game, World world, Body body )
     : base(game, world, body)
 {
 }
コード例 #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 ))
 {
 }
コード例 #26
0
 public HazardBox( CubeGame game, World world, Body body, float width, float height )
     : base(game, world, body)
 {
     mWidth = width;
     mHeight = height;
 }
コード例 #27
0
 public HandBrush( CubeGame game )
 {
     Game = game;
 }
コード例 #28
0
 public Solid MakeSolid( CubeGame game, World world, Body body )
 {
     return new Quarterpipe( game, world, body, Radius );
 }
コード例 #29
0
 public Solid MakeSolid( CubeGame game, World world, Body body )
 {
     return new HazardBox( game, world, body, Width, Height );
 }
コード例 #30
0
ファイル: EndDoor.cs プロジェクト: theLOLflashlight/CyberCube
 public Solid MakeSolid( CubeGame game, World world, Body body )
 {
     return new EndDoor( game, world, body );
 }