Ejemplo n.º 1
0
        public OuterVehicle(OuterVehicleData OVehicle)
        {
            VehicleTypeOut = (uint)OVehicle.m_Type;
            Id = (uint)OVehicle.m_ID;
            switch (OVehicle.m_Type)
            {
                case 0:
                    _vehicleType = VehicleTypes.CAR;
                    break;
                case 1:
                    _vehicleType = VehicleTypes.BUS;
                    break;
                case 2:
                    _vehicleType = VehicleTypes.CAR;
                    break;
                case 3:
                    _vehicleType = VehicleTypes.TRAM;
                    break;
                default:
                    break;
            }
            _length = OVehicle.m_length * 10.0;
            this._state = new IVehicle.State(0.0);
               // this.state.positionAbs = new Vector2();
            this.state.positionAbs.X = OVehicle.m_X * 10.0;
            this.state.positionAbs.Y = OVehicle.m_Y * 10.0;
            this.state.orientation.X = Math.Cos(OVehicle.m_orientation) * 10.0;
            this.state.orientation.Y = Math.Sin(OVehicle.m_orientation) * 10.0;

            this._physics.Acceleration = OVehicle.m_Acceleration ;
            this._physics.Velocity = OVehicle.m_Velocity ;
        }
Ejemplo n.º 2
0
        public void SpawnDrivedOutVehicle(int num, OuterVehicleData[] oVhicle)
        {
            for (int i = 0; i < num; i++)
            {
                OuterVehicle ov = new OuterVehicle(oVhicle[i]);

                if (oVhicle[i].m_PV_flag == 1)
                {
                    PV.Add(ov);
                }
                VehicleDrivedOut.Add(ov);
                foreach (NodeConnection nc in nodeSteuerung.connections)
                {
                    nc.VehicleDrivedOut.Add(ov);
                }
            }
        }
Ejemplo n.º 3
0
        public unsafe void ReceiveDataFromRDCServer()
        {
            IntPtr RecvPtr = Marshal.AllocHGlobal(25616);
            m_UpdateVehicle[0] = new OuterVehicleData[256];
            m_UpdateVehicle[1] = new OuterVehicleData[256];

            if (!NamedPipeNative.WaitNamedPipe(RecvPipeName, NamedPipeNative.NMPWAIT_WAIT_FOREVER))
            {
                Console.WriteLine("Can not open Pipe\n");
                return;
            }

            IntPtr fileHandle = NamedPipeNative.CreateFile(RecvPipeName, NamedPipeNative.GENERIC_READ | NamedPipeNative.GENERIC_WRITE, 0, null, NamedPipeNative.OPEN_EXISTING, 0, 0);

            byte[] numReadWritten = new byte[4];

            while (m_OnRun)
            {
                bool ReadSuccessFlag;
                ReadSuccessFlag = NamedPipeNative.ReadFile(fileHandle, RecvPtr, 25606, numReadWritten, 0);
                m_RecvData = (RecvData)Marshal.PtrToStructure(RecvPtr, typeof(RecvData));
                if (ReadSuccessFlag)
                {
                    RespondCommand();
                }
            }
            Marshal.FreeHGlobal(RecvPtr);
            NamedPipeNative.CloseHandle(fileHandle);
        }
Ejemplo n.º 4
0
        public void RemoveDrivedOutVehicle(int num, OuterVehicleData[] oVhicle)
        {
            for (int j = 0; j < VehicleDrivedOut.Count; j++)
            {
                IVehicle v = VehicleDrivedOut[j];
                for (int i = 0; i < num; i++)
                {
                    if (v.Id == oVhicle[i].m_ID)
                    {
                        RM_Flag[j] = 0;
                        break;
                    }
                    RM_Flag[j]++;

                    if (RM_Flag[j]>100)
                    {

                        if (PV.Contains(v))
                        {
                            if (TSSingnalCulled[PV.IndexOf(v)] != null)
                            {
                                TSSingnalCulled[PV.IndexOf(v)].Clear();
                            }
                            if (TSVehicleCulled[PV.IndexOf(v)] != null)
                            {
                                TSVehicleCulled[PV.IndexOf(v)].Clear();
                            }
                            PV.Remove(v);
                        }
                        foreach (NodeConnection nc in nodeSteuerung.connections)
                        {
                            nc.VehicleDrivedOut.Remove(v);
                        }
                        VehicleDrivedOut.Remove(v);
                    }

                }

            }
        }
Ejemplo n.º 5
0
        public void DriveOuterVehicle(int num, OuterVehicleData[] oVhicle)
        {
            foreach (IVehicle v in VehicleDrivedOut)
            {
                for (int i = 0; i < num; i++)
                {
                    if (v.Id == VehicleDrivedOut[i].Id)
                    {
                        v.state.positionAbs.X = oVhicle[i].m_X*10.0;
                        v.state.positionAbs.Y = oVhicle[i].m_Y * 10.0;
                        v.state.orientation.X = Math.Cos(oVhicle[i].m_orientation) * 10.0;
                        v.state.orientation.Y = Math.Sin(oVhicle[i].m_orientation) * 10.0;

                        v._physics.Acceleration = oVhicle[i].m_Acceleration ;
                        v._physics.Velocity = oVhicle[i].m_Velocity ;

                    }
                }
            }
        }