コード例 #1
0
ファイル: RoBoGame.cs プロジェクト: suzuke/3DPhysics
        // Flexible create methods for the game
        private RoverObject GetRover(Vector3 pos)
        {
            // Colby says: Assets.Rover exists only as an experiment to decide between using Enums with casting or public static int variables with manual (possibly automated with reflection) initialization
            RoverObject rover = assetManager.GetNewInstance(AssetTypes.Rover) as RoverObject;

            rover.MoveTo(pos, Matrix.Identity);
            return(rover);
        }
コード例 #2
0
ファイル: RoBoGame.cs プロジェクト: suzuke/3DPhysics
        private Gobject SpawnRover(int ownerid, int objectid)
        {
            Gobject newobject = GetRover(new Vector3(90, 20, 20));

            newobject.ID = objectid;
            physicsManager.AddNewObject(newobject);
            Debug.WriteLine("Selecting: owner" + ownerid + " mine" + MyClientID);
            if (ownerid == MyClientID) // Only select the new car if its OUR new car
            {
                myRover = (RoverObject)newobject;
                SelectGameObject(myRover);
            }
            return(newobject);
        }
コード例 #3
0
ファイル: RoBoGame.cs プロジェクト: suzuke/3DPhysics
        /// <summary>
        /// CLIENT SIDE
        /// client should do something oriented to the specific game here, like player bullets or cars.
        /// The server has granted the object request and this is where the client handle the response the server has sent back
        /// This is called from the Network code, thus in the Network threads
        /// </summary>
        /// <param name="objectid"></param>
        /// <param name="asset"></param>
        public override void ProcessObjectAdded(int ownerid, int objectid, int asset)
        {
            Debug.WriteLine("Process Object Added: owner:" + ownerid + " id:" + objectid + " asset:" + asset);
            Gobject newobject = assetManager.GetNewInstance((AssetTypes)asset);

            newobject.ID = objectid;
            physicsManager.AddNewObject(newobject);
            if (ownerid == MyClientID) // Only select the new car if its OUR new car
            {
                if (newobject is RoverObject)
                {
                    myRover = (RoverObject)newobject;
                    SelectGameObject(myRover);
                }
            }
        }
コード例 #4
0
ファイル: RoBoGame.cs プロジェクト: suzuke/3DPhysics
        bool CollisionSkin_callbackFn(CollisionSkin skin0, CollisionSkin skin1)
        {
            RoverObject rover = null;
            Gobject     obj   = null;

            if (skin0.Owner.ExternalData is RoverObject)
            {
                rover = skin0.Owner.ExternalData as RoverObject;
            }
            if (skin1.Owner == null)
            {
                return(true);
            }
            if (skin1.Owner.ExternalData is Gobject)
            {
                obj = skin1.Owner.ExternalData as Gobject;
            }

            if (rover == null || obj == null)
            {
                return(true);
            }

            if (objectsToDelete.Contains(obj.ID)) // if the object is going to be deleted soon,
            {
                return(false);                    // don't bother doing any collision with it
            }
            int type = obj.type;

            if ((AssetTypes)type == AssetTypes.Laser1Pickup)
            {
                rover.SetLaser(true);
                DeleteObject(obj.ID);
                return(false);
            }
            if ((AssetTypes)type == AssetTypes.Radar1Pickup)
            {
                rover.SetRadar(true);
                DeleteObject(obj.ID);
                return(false);
            }
            return(true);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: UKTechTests/Rover
        static void Main(string[] args)
        {
            Console.WriteLine("Enter top right corner of plateu");
            var line = Console.ReadLine();

            if (line != null)
            {
                string[] topRightCoOrdinate = line.Split(' ');
                var      plateau            = new Plateau(StringToInt(topRightCoOrdinate[0]), StringToInt(topRightCoOrdinate[1]));

                while (true)
                {
                    Console.WriteLine("Enter current position of rover");
                    var readLine = Console.ReadLine();

                    if (readLine != null)
                    {
                        var position         = readLine.Split(' ');
                        var currentPosition  = new CoOrdinates(StringToInt(position[0]), StringToInt(position[1]));
                        var currentDirection = Direction.N.StringToEnum(position[2]);

                        var rover = new RoverObject(currentPosition, currentDirection, plateau);

                        Console.WriteLine("Enter command string");
                        var command = Console.ReadLine();

                        rover.Run(command);
                    }
                    else
                    {
                        Console.WriteLine("Invalid position");
                    }

                    Console.WriteLine("Do you want to exit: (Y/N)");
                    line = Console.ReadLine();
                    if (line == "Y")
                    {
                        break;
                    }
                }
            }
            Console.ReadKey();
        }
コード例 #6
0
        public RoverObject QueryRoverObject(DateTime queryDate)
        {
            string      jsonResponse;
            RoverObject rover = null;

            try
            {
                url          = string.Format(url, queryDate.ToString("yyyy-MM-dd"));
                jsonResponse = Util.GetCallAPI(url);
                if (!string.IsNullOrEmpty(jsonResponse))
                {
                    rover = JsonConvert.DeserializeObject <RoverObject>(jsonResponse);
                }
            }
            catch (Exception)
            {
            }

            return(rover);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: Thejraj/Rover
        static void Main(string[] args)
        {
            Console.WriteLine("Enter top right corner of plateu");
            var line = Console.ReadLine();
            if (line != null)
            {
                string[] topRightCoOrdinate = line.Split(' ');
                var plateau = new Plateau(StringToInt(topRightCoOrdinate[0]), StringToInt(topRightCoOrdinate[1]));

                while (true)
                {
                    Console.WriteLine("Enter current position of rover");
                    var readLine = Console.ReadLine();

                    if (readLine != null)
                    {
                        var position = readLine.Split(' ');
                        var currentPosition = new CoOrdinates(StringToInt(position[0]), StringToInt(position[1]));
                        var currentDirection = Direction.N.StringToEnum(position[2]);

                        var rover = new RoverObject(currentPosition, currentDirection, plateau);

                        Console.WriteLine("Enter command string");
                        var command = Console.ReadLine();

                        rover.Run(command);
                    }
                    else
                    {
                        Console.WriteLine("Invalid position");
                    }

                    Console.WriteLine("Do you want to exit: (Y/N)");
                    line = Console.ReadLine();
                    if (line == "Y")
                        break;
                }
            }
            Console.ReadKey();
        }
コード例 #8
0
ファイル: RoBoGame.cs プロジェクト: suzuke/3DPhysics
        // Standard and Static callback create methods for the asset manager
        private Gobject CreateRover()
        {
            RoverObject r = null;

            try
            {
                Vector3 pos               = Vector3.Zero;
                float   maxSteerAngle     = 30.0f;
                float   steerRate         = 5.0f;
                float   wheelSideFriction = 4.7f;
                float   wheelFwdFriction  = 5.0f;
                float   wheelTravel       = 0.2f;
                float   wheelRadius       = 0.4f;
                float   wheelZOffset      = 0.05f;
                float   wheelRestingFrac  = 0.45f;
                float   wheeldampingFrac  = 0.3f;
                int     wheelNumRays      = 1;
                float   driveTorque       = 200.0f;

                r = new RoverObject(0, pos, roverModel, wheelModel, roverRadar, cubeModel, RotArm, roverCam, Pole, maxSteerAngle, steerRate,
                                    wheelSideFriction, wheelFwdFriction, wheelTravel, wheelRadius, wheelZOffset, wheelRestingFrac, wheeldampingFrac, wheelNumRays,
                                    driveTorque, /*physicsManager.PhysicsSystem.Gravity.Length());*/ 10f);
                // TODO FIX - Jeffrey changed gravity to magic constant because planets have their own gravity ... thus PhysicsSystem.Gravity = 0;
                r.Rover.EnableCar();
                r.Rover.Chassis.Body.AllowFreezing = false;

                if (isServer)
                {
                    r.AddCollisionCallback(CollisionSkin_callbackFn);
                }
            }
            catch (Exception E)
            {
                System.Diagnostics.Debug.WriteLine(E.StackTrace);
            }
            return(r);
        }
コード例 #9
0
ファイル: RightTurnCommand.cs プロジェクト: UKTechTests/Rover
 public void Execute(RoverObject rover)
 {
     rover.RightTurn();
 }
コード例 #10
0
ファイル: LeftTurnCommand.cs プロジェクト: Thejraj/Rover
 public void Execute(RoverObject rover)
 {
     rover.LeftTurn();
 }
コード例 #11
0
ファイル: LeftTurnCommand.cs プロジェクト: UKTechTests/Rover
 public void Execute(RoverObject rover)
 {
     rover.LeftTurn();
 }
コード例 #12
0
ファイル: MoveCommad.cs プロジェクト: UKTechTests/Rover
 public void Execute(RoverObject rover)
 {
     rover.MoveOneStep();
 }
コード例 #13
0
ファイル: MoveCommad.cs プロジェクト: Thejraj/Rover
 public void Execute(RoverObject rover)
 {
     rover.MoveOneStep();
 }