Пример #1
0
    /// <summary>
    /// 回池
    /// </summary>
    protected override void toRelease(DataPool pool)
    {
        base.toRelease(pool);

        this.nowPos = null;
        this.data   = null;
    }
Пример #2
0
        void RunTests_Click(object sender, RoutedEventArgs e)
        {
            // Disable Controls.
            SelectedDrive_cmb.IsEnabled        = false;
            ResultsDisplay_dg.IsHitTestVisible = false;
            ResultsDisplay_dg.Opacity          = 0.80;

            // Hide Run Tests Button
            RunTests_btn.Visibility = System.Windows.Visibility.Collapsed;

            // Show Stop Tests Button
            StopTests_btn.Visibility = System.Windows.Visibility.Visible;

            // Unhide the progress bar.
            RunningTestProgress_pb.Visibility = System.Windows.Visibility.Visible;

            //Get the selected drive to run the test(s) on.
            DriveData tempDriveData = (DriveData)SelectedDrive_cmb.SelectedItem;

            // Clean up after the IOmeter test.
            io_meter.DeleteIOmeterTestFile(tempDriveData.DriveLetter);

            // Setup mechanism to keep gui responsive.
            SetupWorkloadBackroundWorker();

            // Start running the tests in the background.
            workload_background_thread.RunWorkerAsync(tempDriveData);

            // Display running test message.
            Welcome_lbl.Text = "Running selected workloads. Please press STOP TESTS if you wish to cancel the workloads.";
        }
Пример #3
0
        private void StopIOmeterTests()
        {
            // Reenable Controls
            SelectedDrive_cmb.IsEnabled        = true;
            ResultsDisplay_dg.IsHitTestVisible = true;
            ResultsDisplay_dg.Opacity          = 1;
            ResultsDisplay_dg.UnselectAll();

            // Unhide Run Tests Button
            RunTests_btn.Visibility = System.Windows.Visibility.Visible;

            // Hide Stop Tests Button
            StopTests_btn.Visibility = System.Windows.Visibility.Collapsed;

            // Hide the progress bar.
            RunningTestProgress_pb.Visibility = System.Windows.Visibility.Collapsed;

            // Reset instruction message.
            Welcome_lbl.Text = "Please select a drive to test and which workloads to run. After slecting a drive and workloads click RUN TESTS to begin testing.";

            // Get the selected drive to run the test(s) on.
            DriveData tempDriveData = (DriveData)SelectedDrive_cmb.SelectedItem;

            // Clean up after the IOmeter test.
            io_meter.DeleteIOmeterTestFile(tempDriveData.DriveLetter);

            HideToastMessage();
        }
Пример #4
0
    /** 客户端发起驾驶 */
    public void onServerDrive(PosDirData nowPos, DriveData data)
    {
        if (_drive == null || !_drive.needDrive)
        {
            return;
        }

        _unit.pos.setByPosDir(nowPos);

        if (getBaseMoveState() != UnitBaseMoveState.Drive)
        {
            clearBaseMove();

            _d.baseMoveState = UnitBaseMoveState.Drive;
            _d.moveType      = UnitMoveType.Drive;
        }

        _d.driveData = data;

        if (data.forward == 0 && data.turn == 0)
        {
            clearBaseMove();
            reIdle();
        }
    }
    public void LoadData()
    {
        string fileName = FileSelectionHelper.SelectFile(new ExtensionFilter("Data Files", "csv"));

        if (fileName == null)
        {
            return;
        }

        DriveData driveData = ParseFileToJson(fileName);

        using (StreamWriter writer = new StreamWriter("output.json"))
        {
            writer.Write(JsonConvert.SerializeObject(driveData));
        }

        if (driveData == null)
        {
            Debug.Log("Cannot read the file.");
            return;
        }

        EventBus.Instance.OnFileLoad.Invoke(fileName);
        EventBus.Instance.OnDataLoad.Invoke(driveData);
    }
Пример #6
0
    protected override void copyData()
    {
        base.copyData();
        PosDirData nowPosTemp = nowPos;

        if (nowPosTemp != null)
        {
            this.nowPos = (PosDirData)BytesControl.createData(PosDirData.dataID);
            this.nowPos.copy(nowPosTemp);
        }
        else
        {
            this.nowPos = null;
        }

        DriveData dataTemp = data;

        if (dataTemp != null)
        {
            this.data = (DriveData)dataTemp.clone();
        }
        else
        {
            this.data = null;
            nullObjError("data");
        }
    }
Пример #7
0
        public string GetListOfDrives()
        {
            var driveData         = DriveInfo.GetDrives();
            List <DriveData> data = new List <DriveData>();

            foreach (var d in driveData)
            {
                try
                {
                    var dd = new DriveData()
                    {
                        DriveLetter = d.Name.Replace(@":\\", ""),
                        DriveName   = d.VolumeLabel,
                        DriveType   = d.DriveType.ToString(),
                        FreeSpace   = d.AvailableFreeSpace,
                        UsedSpace   = d.TotalSize - d.AvailableFreeSpace
                    };
                    data.Add(dd);
                }
                catch { }
            }

            return(js.Serialize(new Response()
            {
                Data = data, id = 0, RequestType = RequestEnum.ListOfDrives
            }));
        }
        public void CreateDriveData(int probeDataId, DriveData data)
        {
            data.ProbeDataId = probeDataId;
            data.CreatedOn   = DateTime.UtcNow;

            _Context.DriveData.Add(data);
            _Context.SaveChanges();
        }
Пример #9
0
    /// <summary>
    /// 创建实例
    /// </summary>
    public static CUnitDriveRequest create(int instanceID, PosDirData nowPos, DriveData data)
    {
        CUnitDriveRequest re = (CUnitDriveRequest)BytesControl.createRequest(dataID);

        re.instanceID = instanceID;
        re.nowPos     = nowPos;
        re.data       = data;
        return(re);
    }
Пример #10
0
	/// <summary>
	/// 复制(潜拷贝)
	/// </summary>
	protected override void toShadowCopy(BaseData data)
	{
		if(!(data is DriveData))
			return;
		
		DriveData mData=(DriveData)data;
		
		this.forward=mData.forward;
		this.turn=mData.turn;
		this.currentSpeed=mData.currentSpeed;
	}
Пример #11
0
        void Workload_Background_Thread_DoWork(object sender, DoWorkEventArgs e)
        {
            DriveData tempDriveData = null;

            if (e.Argument != null)
            {
                tempDriveData = (DriveData)e.Argument;
            }

            for (int count = 0; count < ResultsToDisplay.Count; count++)
            {
                // Allow the running test(s) to be canceled.
                if (workload_background_thread.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                // Get the selected workload to run.
                Result tempResult = ResultsToDisplay[count];

                // Skip workloads user doesn't want to run.
                if (!tempResult.RunWorkLoad)
                {
                    continue;
                }

                // Display a snackbar progress message.
                if (!workload_background_thread.CancellationPending)
                {
                    workload_background_thread.ReportProgress(0, String.Format("Running workload {0}.", tempResult.WorkloadName));
                }

                // Execute IOmeter test.
                io_meter.RunIOmeterTest(tempDriveData.DriveLetter, tempResult.WorkloadName);

                // Update the results display.
                workload_background_thread.ReportProgress(0);

                int number_of_tests = ezIOmeter_utility.NumberOfTestsToRun(ResultsToDisplay);
                if ((count + 1) != number_of_tests && number_of_tests > 1 && !workload_background_thread.CancellationPending)
                {
                    // Wait (x)sec before running the next workload.
                    String temp_delay_sec     = io_meter.UserConfigSettings.GetAppSetting("sleep_between_tests_sec");
                    int    delay_test_for_sec = Convert.ToInt32(temp_delay_sec);
                    while (delay_test_for_sec != 0 && !workload_background_thread.CancellationPending)
                    {
                        workload_background_thread.ReportProgress(0, String.Format("Waiting {0} second(s) before running next workload.", delay_test_for_sec.ToString()));
                        System.Threading.Thread.Sleep(1000); // Sleep for one second
                        delay_test_for_sec--;
                    }
                }
            }
        }
    private void OnDataLoad(DriveData driveData)
    {
        this.driveData = driveData;

        if (!HasData())
        {
            return;
        }

        LoadFrame(driveData.PointCloudFrames.Frames[0], 0);
    }
    private DriveData ParseFileToJson(string fileName)
    {
        DriveData driveData = new DriveData();

        driveData.PositionFrames   = ParsePositionFrames(fileName);
        driveData.PointCloudFrames = ParsePointCloudFrames(fileName);
        //driveData.PointCloudFrames = new FrameCollection<PointCloudFrame>();

        driveData.SpeedFrames = new FrameCollection <SingleValueFrame>()
        {
            Frames = new SingleValueFrame[]
            {
                new SingleValueFrame()
                {
                    Value = 0
                },
                new SingleValueFrame()
                {
                    Value = 1
                },
            },
        };
        driveData.AccelerationFrames = new FrameCollection <SingleValueFrame>()
        {
            Frames = new SingleValueFrame[]
            {
                new SingleValueFrame()
                {
                    Value = 0
                },
                new SingleValueFrame()
                {
                    Value = 1
                },
            },
        };
        driveData.PerceptionFrames = new FrameCollection <SingleValueFrame>()
        {
            Frames = new SingleValueFrame[]
            {
                new SingleValueFrame()
                {
                    Value = 0
                },
                new SingleValueFrame()
                {
                    Value = 1
                },
            },
        };

        return(driveData);
    }
Пример #14
0
    /// <summary>
    /// 回池
    /// </summary>
    protected override void toRelease(DataPool pool)
    {
        base.toRelease(pool);

        if (this.nowPos != null)
        {
            this.nowPos.release(pool);
            this.nowPos = null;
        }
        this.data.release(pool);
        this.data = null;
    }
Пример #15
0
 /// <summary>
 /// 回池
 /// </summary>
 protected override void toRelease(DataPool pool)
 {
     this.baseMoveState       = 0;
     this.moveType            = 0;
     this.baseMovePos         = null;
     this.moveList            = null;
     this.specialMoveID       = 0;
     this.specialMoveArgs     = null;
     this.specialMoveLastTime = 0;
     this.vehicleInstanceID   = 0;
     this.driveData           = null;
     this.realMoveDir         = null;
     this.realMoveSpeedRatio  = 0;
 }
Пример #16
0
	/// <summary>
	/// 是否数据一致
	/// </summary>
	protected override bool toDataEquals(BaseData data)
	{
		DriveData mData=(DriveData)data;
		if(this.forward!=mData.forward)
			return false;
		
		if(this.turn!=mData.turn)
			return false;
		
		if(this.currentSpeed!=mData.currentSpeed)
			return false;
		
		return true;
	}
Пример #17
0
    /// <summary>
    /// 读取字节流(简版)
    /// </summary>
    protected override void toReadBytesSimple(BytesReadStream stream)
    {
        base.toReadBytesSimple(stream);

        if (stream.readBoolean())
        {
            this.nowPos = (PosDirData)stream.createData(PosDirData.dataID);
            this.nowPos.readBytesSimple(stream);
        }
        else
        {
            this.nowPos = null;
        }

        this.data = (DriveData)stream.readDataSimpleNotNull();
    }
        public ListOfFilesPanelView()
        {
            InitializeComponent();

            try
            {
                DriveInfo[] drives = DriveInfo.GetDrives();
                foreach (DriveInfo d in drives)
                {
                    DriveData disc = new DriveData(d.VolumeLabel, d.Name);
                    DrivesList.Add(disc);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            driveCharSelect.ItemsSource = DrivesList;
        }
Пример #19
0
        public void PopulateDrivesToSelect(BindingList <DriveData> drives_to_display, ComboBox selected_drive_cmb)
        {
            DriveInfo[] allDrives = DriveInfo.GetDrives();

            foreach (DriveInfo tempDriveInfo in allDrives)
            {
                // Only add drives to the list that are ready to be used.
                if (tempDriveInfo.IsReady)
                {
                    DriveData tempDriveData = new DriveData();
                    tempDriveData.DriveLetter    = tempDriveInfo.Name.Replace('\\', ' ').Trim();
                    tempDriveData.DriveLabel     = tempDriveInfo.VolumeLabel;
                    tempDriveData.DriveFreeSpace = (tempDriveInfo.TotalFreeSpace / 1048576).ToString(); // Convert byte to Megabyte

                    drives_to_display.Add(tempDriveData);
                }
            }

            selected_drive_cmb.ItemsSource = drives_to_display;
        }
    public void LoadData()
    {
        string fileName = FileSelectionHelper.SelectFile(new ExtensionFilter("Data Files", "json"));

        if (fileName == null)
        {
            return;
        }

        DriveData driveData = ReadJsonFile(fileName);

        if (driveData == null)
        {
            Debug.Log("Cannot read the file.");
            return;
        }

        EventBus.Instance.OnFileLoad.Invoke(fileName);
        EventBus.Instance.OnDataLoad.Invoke(driveData);
    }
Пример #21
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        base.toReadBytesFull(stream);

        stream.startReadObj();

        if (stream.readBoolean())
        {
            this.nowPos = (PosDirData)stream.createData(PosDirData.dataID);
            this.nowPos.readBytesFull(stream);
        }
        else
        {
            this.nowPos = null;
        }

        BaseData dataT = stream.readDataFullNotNull();

        if (dataT != null)
        {
            if (dataT is DriveData)
            {
                this.data = (DriveData)dataT;
            }
            else
            {
                this.data = new DriveData();
                if (!(dataT.GetType().IsAssignableFrom(typeof(DriveData))))
                {
                    stream.throwTypeReadError(typeof(DriveData), dataT.GetType());
                }
                this.data.shadowCopy(dataT);
            }
        }
        else
        {
            this.data = null;
        }

        stream.endReadObj();
    }
Пример #22
0
    private void OnDataLoaded(DriveData driveData)
    {
        if (driveData.PositionFrames == null)
        {
            return;
        }

        _frames = driveData.PositionFrames;

        Vector3[] positions = new Vector3[driveData.PositionFrames.Frames.Length];

        for (int i = 0; i < positions.Length; i++)
        {
            positions[i] = driveData.PositionFrames.Frames[i].Point.ToVector();
        }

        splineBuilder = new SplineBuilder(positions);
        EventBus.Instance.OnSplineBuilderInitialized.Invoke(splineBuilder);
        EventBus.Instance.OnWaypointsUpdate.Invoke(splineBuilder.GetSplinePoints(splineStep));
        EventBus.Instance.OnCurrentWaypointChange.Invoke(positions[0]);
    }
Пример #23
0
    /// <summary>
    /// 复制(潜拷贝)
    /// </summary>
    protected override void toShadowCopy(BaseData data)
    {
        if (!(data is UnitMoveData))
        {
            return;
        }

        UnitMoveData mData = (UnitMoveData)data;

        this.baseMoveState       = mData.baseMoveState;
        this.moveType            = mData.moveType;
        this.baseMovePos         = mData.baseMovePos;
        this.moveList            = mData.moveList;
        this.specialMoveID       = mData.specialMoveID;
        this.specialMoveArgs     = mData.specialMoveArgs;
        this.specialMoveLastTime = mData.specialMoveLastTime;
        this.vehicleInstanceID   = mData.vehicleInstanceID;
        this.driveData           = mData.driveData;
        this.realMoveDir         = mData.realMoveDir;
        this.realMoveSpeedRatio  = mData.realMoveSpeedRatio;
    }
Пример #24
0
        private static void GetHardDriveData()
        {
            try
            {
                DriveInfo[] allDrives = DriveInfo.GetDrives();

                foreach (DriveInfo d in allDrives)
                {
                    Console.WriteLine("Drive {0}", d.Name);
                    Console.WriteLine("  Drive type: {0}", d.DriveType);
                    if (d.IsReady == true)
                    {
                        Console.WriteLine("  Volume label: {0}", d.VolumeLabel);
                        Console.WriteLine("  File system: {0}", d.DriveFormat);
                        Console.WriteLine("  Available space to current user:{0, 15} bytes", d.AvailableFreeSpace);

                        Console.WriteLine("  Total available space:          {0, 15} bytes", d.TotalFreeSpace);

                        Console.WriteLine("  Total size of drive:            {0, 15} bytes ", d.TotalSize);


                        var data = new DriveData()
                        {
                            Name           = d.Name,
                            DriveType      = d.DriveType.ToString(),
                            VolumeLabel    = d.VolumeLabel,
                            DriveFormat    = d.DriveFormat,
                            AvailableSpace = d.AvailableFreeSpace,
                            TotalSpace     = d.TotalFreeSpace,
                        };

                        _AssetDataService.CreateDriveData(_MachineData.Id, data);
                    }
                }
            }
            catch (Exception e)
            {
                _AssetDataService.CreateError(_MachineData.Id, "GetHardDriveData", e);
            }
        }
Пример #25
0
 private void OnDataLoaded(DriveData driveData)
 {
     _duration = driveData.GetDuration();
     EventBus.Instance.OnTimelineChangeEvent.Invoke(_duration);
 }
Пример #26
0
        private void ShowDriveData(DriveInfo drive)
        {
            DriveData driveData = new DriveData(drive);

            txtSize.Text  = driveData.LongSize;
            txtLabel.Text = driveData.VolumeLabel;



            try
            {
                pbSize.Maximum = driveData.MaximumSize;

                pbSize.Value = driveData.MaximumSize -
                               driveData.AvailableFreeSpace;
            }
            catch (Exception)
            {
            }

            imgDriveType.Source = driveData.DriveIcon;


            //if (drive.IsReady)
            //{
            //    string totalShort = SizeFileInString.GetSizeInStr(drive.TotalSize);
            //    string totalLong = drive.TotalSize.ToString();

            //    string availableShort = SizeFileInString.GetSizeInStr(drive.AvailableFreeSpace);
            //    string availableLong = drive.AvailableFreeSpace.ToString();

            //    txtSize.Text = string.Format("(Free: {0} from {1} ({2} from {3}))", availableShort, totalShort, availableLong, totalLong);

            //    txtLabel.Text = drive.VolumeLabel;

            //    pbSize.Maximum = drive.TotalSize;

            //    try
            //    {
            //        pbSize.Value = drive.TotalSize - drive.AvailableFreeSpace;
            //    }
            //    catch (Exception)
            //    {

            //    }

            //}
            //else
            //{

            //}

            //switch (drive.DriveType)
            //{
            //    case DriveType.CDRom:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_cdrom.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Fixed:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_fixed.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Network:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_network.ico", UriKind.Relative));
            //        break;
            //    case DriveType.NoRootDirectory:
            //        break;
            //    case DriveType.Ram:
            //        break;
            //    case DriveType.Removable:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_removable.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Unknown:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_unknown.ico", UriKind.Relative));
            //        break;
            //    default:
            //        break;
            //}
        }
Пример #27
0
        private void GerarDados(Dictionary<string, string> listaDirArquivo)
        {
            try
            {
                if (File.Exists(txtIndentificador.Text + ".xml"))
                {
                    DialogResult dResult = MessageBox.Show("O catálogo '"
                        + txtIndentificador.Text
                        + "' já existe! Deseja substituir?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dResult != DialogResult.Yes)
                    {
                        return;
                    }
                }

                DriveData driveData = new DriveData();
                driveData.Identificador = txtIndentificador.Text;
                driveData.Data = dtpData.Value.ToShortDateString();
                driveData.TipoArquivos = cbTipoArquivos.Text;
                driveData.File = new List<ChaveValorSer<string, string>>();
                progressBar1.Value = 0;
                progressBar1.Maximum = listaDirArquivo.Count;

                foreach (KeyValuePair<string, string> dirArquivo in listaDirArquivo)
                {
                    if (cancelar)
                    {
                        cancelar = false;
                        return;
                    }
                    else
                    {
                        progressBar1.Value += 1;
                        ChaveValorSer<string, string> info = new ChaveValorSer<string, string>();
                        info.Size = dirArquivo.Value;
                        info.File = dirArquivo.Key;
                        driveData.File.Add(info);
                    }
                    Application.DoEvents();
                }

                XmlSerializer writer = new XmlSerializer(driveData.GetType());
                StreamWriter file = new StreamWriter(driveData.Identificador + ".xml", false);
                writer.Serialize(file, driveData);
                file.Close();
                file.Dispose();
                MessageBox.Show("Arquivo de catálogo gerado com sucesso.",
                    "Catálogo gerado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception)
            {
                MessageBox.Show("Erro ao gerar arquivo de catálogo.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                progressBar1.Value = 0;
            }
        }
 private void OnDataLoaded(DriveData driveData)
 {
     _slider.interactable = true;
 }
Пример #29
0
    protected void driveMoveFrame(float delay)
    {
        DriveLogic drive = _drive;

        _tempPos.clear();

        DriveData dData = _d.driveData;

        float speedAbs = Math.Abs(drive.driveCurrentMoveSpeedM);

        if (speedAbs == 0 && dData.forward == 0)
        {
            if (dData.turn == 0 || !drive.canDriveTurnAtPivot)
            {
                return;
            }
        }

        //本次移动距离
        float dis;

        //不启用加速度
        if (drive.driveAccelerateSpeedM == 0)
        {
            dis = _useMoveSpeedM * delay * dData.forward;
        }
        else
        {
            //滑行
            if (dData.forward == 0)
            {
                //需要的减速时间
                float nTime = speedAbs / drive.driveGroundFrictionM;
                float useA  = drive.driveCurrentMoveSpeedM > 0 ? -drive.driveGroundFrictionM : drive.driveGroundFrictionM;

                if (delay <= nTime)
                {
                    float d = useA * delay;
                    dis = drive.driveCurrentMoveSpeedM * delay + d * delay / 2;
                    drive.driveCurrentMoveSpeedM += d;
                }
                //减到0
                else
                {
                    dis = drive.driveCurrentMoveSpeedM * nTime / 2;              //vt/2
                    drive.driveCurrentMoveSpeedM = 0;
                }
            }
            else
            {
                float useA       = drive.driveAccelerateSpeedM * dData.forward;
                bool  sameSymbol = MathUtils.sameSymbol(useA, drive.driveCurrentMoveSpeedM);

                //符号相同,并且已经是最高速度
                if (sameSymbol && speedAbs >= _useMoveSpeedM)
                {
                    dis = drive.driveCurrentMoveSpeedM * delay;
                }
                else
                {
                    //需要加速的时间
                    float nTime = (_useMoveSpeedM - (sameSymbol ? speedAbs : -speedAbs)) / drive.driveAccelerateSpeedM;

                    //匀加速
                    if (delay <= nTime)
                    {
                        float d = useA * delay;
                        dis = drive.driveCurrentMoveSpeedM * delay + d * delay / 2;
                        drive.driveCurrentMoveSpeedM += d;
                    }
                    //到max
                    else
                    {
                        dis = drive.driveCurrentMoveSpeedM * nTime + useA * nTime * nTime / 2;

                        //到达最大速度
                        drive.driveCurrentMoveSpeedM = useA > 0 ? _useMoveSpeedM : -_useMoveSpeedM;
                        //剩余时间用新速度
                        dis += (drive.driveCurrentMoveSpeedM * (delay - nTime));
                    }
                }
            }
        }

        bool hasPos = false;
        bool hasDir = false;

        if (dData.turn == 0)
        {
            if (dis != 0)
            {
                _scenePosLogic.calculateVectorByDir(_tempPos, _dir, dis);
                _scenePosLogic.addPos(_tempPos, _pos);
                hasPos = true;
            }
            else
            {
                return;
            }
        }
        else
        {
            if (dis != 0)
            {
                float angle;
                float radius;

                if (drive.canDriveTurnAtPivot)
                {
                    angle  = drive.driveDirectionSpeed * delay;
                    radius = dis / angle;
                }
                else
                {
                    radius = drive.driveTurnRadius;
                    angle  = dis / radius;
                }

                //正方向
                float forward = (float)(radius * Math.Sin(angle));
                //两侧
                float side = (float)(radius * (1 - Math.Cos(angle)));

                _tempPos.x = forward;
                _tempPos.z = dData.turn * side;
                _tempPos.y = 0;

                //朝向向量
                _scenePosLogic.rotatePosByDir2D(_tempPos, _dir);
                _scenePosLogic.addPos(_tempPos, _pos);

                //朝向修改
                _dir.direction = MathUtils.directionCut(_dir.direction - (angle * dData.turn));
                hasDir         = true;
                hasPos         = true;
            }
            else
            {
                if (drive.canDriveTurnAtPivot)
                {
                    float angle = drive.driveDirectionSpeed * delay;
                    _dir.direction = MathUtils.directionCut(_dir.direction - (angle * dData.turn));
                    hasDir         = true;
                }
                else
                {
                    return;
                }
            }
        }

        BaseGameUtils.makeTerrainPos(_tempPos);

        if (hasDir)
        {
            _unit.pos.onSetDir();
        }

        if (hasPos)
        {
            if (_scenePosLogic.isPosEnabled(_moveType, _tempPos))
            {
                _pos.copyPos(_tempPos);
                _unit.pos.onSetPos();
            }
            else
            {
                // Ctrl.print("撞墙",_tempPos.toDataString());
            }
        }


        if (drive.driveAccelerateSpeedM != 0 && drive.driveCurrentMoveSpeedM == 0f && dData.forward == 0 && _currentMoveIsInitiative)
        {
            if (!drive.canDriveTurnAtPivot || dData.turn == 0)
            {
                stopMove();
            }
        }
    }
Пример #30
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        stream.startReadObj();

        this.baseMoveState = stream.readInt();

        this.moveType = stream.readInt();

        if (stream.readBoolean())
        {
            this.baseMovePos = (PosData)stream.createData(PosData.dataID);
            this.baseMovePos.readBytesFull(stream);
        }
        else
        {
            this.baseMovePos = null;
        }

        if (stream.readBoolean())
        {
            int moveListLen = stream.readLen();
            if (this.moveList != null)
            {
                this.moveList.clear();
                this.moveList.ensureCapacity(moveListLen);
            }
            else
            {
                this.moveList = new SList <PosData>();
            }

            SList <PosData> moveListT = this.moveList;
            for (int moveListI = moveListLen - 1; moveListI >= 0; --moveListI)
            {
                PosData moveListV;
                if (stream.readBoolean())
                {
                    moveListV = (PosData)stream.createData(PosData.dataID);
                    moveListV.readBytesFull(stream);
                }
                else
                {
                    moveListV = null;
                }

                moveListT.add(moveListV);
            }
        }
        else
        {
            this.moveList = null;
        }

        this.specialMoveID = stream.readInt();

        if (stream.readBoolean())
        {
            int specialMoveArgsLen = stream.readLen();
            if (this.specialMoveArgs == null || this.specialMoveArgs.Length != specialMoveArgsLen)
            {
                this.specialMoveArgs = new int[specialMoveArgsLen];
            }
            int[] specialMoveArgsT = this.specialMoveArgs;
            for (int specialMoveArgsI = 0; specialMoveArgsI < specialMoveArgsLen; ++specialMoveArgsI)
            {
                int specialMoveArgsV;
                specialMoveArgsV = stream.readInt();

                specialMoveArgsT[specialMoveArgsI] = specialMoveArgsV;
            }
        }
        else
        {
            this.specialMoveArgs = null;
        }

        this.specialMoveLastTime = stream.readInt();

        this.vehicleInstanceID = stream.readInt();

        if (stream.readBoolean())
        {
            BaseData driveDataT = stream.readDataFullNotNull();
            if (driveDataT != null)
            {
                if (driveDataT is DriveData)
                {
                    this.driveData = (DriveData)driveDataT;
                }
                else
                {
                    this.driveData = new DriveData();
                    if (!(driveDataT.GetType().IsAssignableFrom(typeof(DriveData))))
                    {
                        stream.throwTypeReadError(typeof(DriveData), driveDataT.GetType());
                    }
                    this.driveData.shadowCopy(driveDataT);
                }
            }
            else
            {
                this.driveData = null;
            }
        }
        else
        {
            this.driveData = null;
        }

        if (stream.readBoolean())
        {
            this.realMoveDir = (DirData)stream.createData(DirData.dataID);
            this.realMoveDir.readBytesFull(stream);
        }
        else
        {
            this.realMoveDir = null;
        }

        this.realMoveSpeedRatio = stream.readInt();

        stream.endReadObj();
    }
Пример #31
0
        /// <summary>
        /// Заполняем элементы управления данными
        /// </summary>
        private void ShowDriveData()
        {
            DriveData driveData = new DriveData(drive);

            txtSize.Text = driveData.LongSize;

            try
            {
                pbSize.Maximum = driveData.MaximumSize;
                pbSize.Value   = driveData.MaximumSize -
                                 driveData.AvailableFreeSpace;
            }
            catch (Exception)
            {
                //pbSize.MaxWidth = 300;
            }

            imgDriveType.Source = driveData.DriveIcon;

            //txtInfo.Text = string.Format("name:{0} type:{1}",
            //    drive.Name[0].ToString(), drive.DriveType);
            txtDriveLabel.Text = driveData.VolumeLabel;
            txtDriveName.Text  = driveData.Drive.Name[0].ToString();
            txtDriveType.Text  = driveData.Drive.DriveType.ToString();

            if (!driveData.Drive.IsReady)
            {
                //txtSize.Text = Properties.Resources.TheDriveIsNotReady;
                txtSize.Text = LanguagesManager.GetCurrLanguage().DDDriveIsNotReady;
            }

            //if (drive.IsReady)
            //{
            //    string totalShort = SizeFileInString.GetSizeInStr(drive.TotalSize);
            //    string totalLong = drive.TotalSize.ToString();

            //    string availableShort = SizeFileInString.GetSizeInStr(drive.AvailableFreeSpace);
            //    string availableLong = drive.AvailableFreeSpace.ToString();

            //    txtSize.Text = string.Format("Free: {0} from {1} ({2} from {3})", availableShort, totalShort, availableLong, totalLong);

            //    pbSize.Maximum = drive.TotalSize;

            //    try
            //    {
            //        pbSize.Value = drive.TotalSize - drive.AvailableFreeSpace;
            //    }
            //    catch (Exception)
            //    {

            //    }

            //    txtInfo.Text = string.Format("name:{0} label:{1} type:{2}",
            //        drive.Name[0].ToString(), drive.VolumeLabel, drive.DriveType);

            //}
            //else
            //{
            //    txtInfo.Text = string.Format("name:{0} type:{1}",
            //        drive.Name[0].ToString(), drive.DriveType);
            //    txtSize.Text = "The drive is not read";
            //}

            //switch (drive.DriveType)
            //{
            //    case DriveType.CDRom:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_cdrom.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Fixed:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_fixed.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Network:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_network.ico", UriKind.Relative));
            //        break;
            //    case DriveType.NoRootDirectory:
            //        break;
            //    case DriveType.Ram:
            //        break;
            //    case DriveType.Removable:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_removable.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Unknown:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_unknown.ico", UriKind.Relative));
            //        break;
            //    default:
            //        break;
            //}
        }