예제 #1
0
            public void AddSolid( Solid solid )
            {
                if ( solid == null )
                    return;

                mSolids.Add( solid );
            }
예제 #2
0
        public void Cancel()
        {
            mFace = null;
            Started = false;

            if ( Game.Input.CheckFocus( mSelectedSolid ) )
                Game.Input.Focus = null;

            mSelectedSolid = null;
            mStartPos = Vector2.Zero;
        }
예제 #3
0
            protected void MoveSolid( Solid solid, CompassDirection dir )
            {
                Face nextFace = AdjacentFace( dir );
                var backDir = nextFace.BackwardsDirectionFrom( this );

                mSolids.Remove( solid );
                solid.World = nextFace.World;
                nextFace.mSolids.Add( solid );

                Body body = solid.Body;

                float pastRotation = body.Rotation;

                body.Rotation += nextFace.Rotation;
                body.AdHocGravity = Vector2.UnitY.Rotate( -body.Rotation ).Rounded();
                body.Awake = true;

                body.Position = body.Position.Rotate( pastRotation - body.Rotation );
                body.LinearVelocity = body.LinearVelocity.Rotate( pastRotation - body.Rotation );
            }
예제 #4
0
            private IEnumerable<CompassDirection> ClampSolid( Solid solid )
            {
                Vector2 pos = solid.Body.Position.ToPixels();

                if ( pos.X > WIDTH )
                {
                    solid.Body.Position = new Vector2( WIDTH, pos.Y ).ToUnits();

                    var dir = VectorToDirection( Vector3.UnitX );
                    if ( dir != null )
                        yield return dir.Value;
                }
                else if ( pos.X < 0 )
                {
                    solid.Body.Position = new Vector2( 0, pos.Y ).ToUnits();

                    var dir = VectorToDirection( -Vector3.UnitX );
                    if ( dir != null )
                        yield return dir.Value;
                }

                if ( pos.Y > HEIGHT )
                {
                    solid.Body.Position = new Vector2( pos.X, HEIGHT ).ToUnits();

                    var dir = VectorToDirection( Vector3.UnitY );
                    if ( dir != null )
                        yield return dir.Value;
                }
                else if ( pos.Y < 0 )
                {
                    solid.Body.Position = new Vector2( pos.X, 0 ).ToUnits();

                    var dir = VectorToDirection( -Vector3.UnitY );
                    if ( dir != null )
                        yield return dir.Value;
                }
            }
예제 #5
0
 public void RemoveSolid( Solid solid )
 {
     mSolids.Remove( solid );
     World.RemoveBody( solid.Body );
 }
예제 #6
0
        public void Start( EditableCube.Face face, Vector2 mousePos, GameTime gameTime )
        {
            Solid selectedSolid = face.FindSolidAt( mousePos.ToUnits() );

            if ( selectedSolid != mSelectedSolid )
                Cancel();

            if ( selectedSolid != null )
            {
                mFace = face;
                Started = true;
                mStartPos = mousePos;
                mSelectedSolid = selectedSolid;
                mOriginalPos = mSelectedSolid.Position;
                Game.Input.Focus = mSelectedSolid;
            }
        }