コード例 #1
0
ファイル: UIMConfig1.cs プロジェクト: ridsl22/AURA
 public UIMConfigMode this[SpeedMode mode]
 {
     get
     {
         return(zones_[(int)mode]);
     }
 }
コード例 #2
0
ファイル: L122M2X4.cs プロジェクト: jajanuj/GitTest
        /// <summary>
        /// 連續移動 (需選擇使用軸參的手動速度或是自動速度)
        /// </summary>
        /// <param name="dir">移動方向</param>
        /// <param name="inAuto">手動或自動速度</param>
        /// <returns></returns>
        public bool ContinuousMove(RotationDirection dir, SpeedMode inAuto = SpeedMode.Auto)
        {
            I16 rc = -1;

            if (axisPara.IsActive && axisPara.Enabled)
            {
                if (isAllowMove(dir))
                {
                    sbyte bDir = 1;
                    if (dir == RotationDirection.CW)
                    {
                        bDir = 1;
                    }
                    else
                    {
                        bDir = -1;
                    }
                    if (inAuto == SpeedMode.Auto)
                    {
                        CCMNet.CS_mnet_m204_tv_move(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, MmToPulse(checkOverMaxSpeed(axisPara.StrVelA)) * bDir, MmToPulse(checkOverMaxSpeed(axisPara.DevVelA)) * bDir, axisPara.AccVelA);
                    }
                    else
                    {
                        CCMNet.CS_mnet_m204_tv_move(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, MmToPulse(checkOverMaxSpeed(axisPara.StrVelM)) * bDir, MmToPulse(checkOverMaxSpeed(axisPara.DevVelM)) * bDir, axisPara.AccVelM);
                    }
                }
            }
            return(rc == 0 ? true : false);
        }
コード例 #3
0
        /// <summary>Constructor with specific values</summary>
        /// <param name="minValue"></param>
        /// <param name="maxValue"></param>
        /// <param name="wrap"></param>
        /// <param name="rangeLocked"></param>
        /// <param name="maxSpeed"></param>
        /// <param name="accelTime"></param>
        /// <param name="decelTime"></param>
        /// <param name="name"></param>
        /// <param name="invert"></param>
        public AxisState(
            float minValue, float maxValue, bool wrap, bool rangeLocked,
            float maxSpeed, float accelTime, float decelTime,
            string name, bool invert)
        {
            m_MinValue       = minValue;
            m_MaxValue       = maxValue;
            m_Wrap           = wrap;
            ValueRangeLocked = rangeLocked;

            HasRecentering = false;
            m_Recentering  = new Recentering(false, 1, 2);

            m_SpeedMode      = SpeedMode.MaxSpeed;
            m_MaxSpeed       = maxSpeed;
            m_AccelTime      = accelTime;
            m_DecelTime      = decelTime;
            Value            = (minValue + maxValue) / 2;
            m_InputAxisName  = name;
            m_InputAxisValue = 0;
            m_InvertInput    = invert;

            m_CurrentSpeed      = 0f;
            m_InputAxisProvider = null;
            m_InputAxisIndex    = 0;
            m_LastUpdateTime    = 0;
            m_LastUpdateFrame   = 0;
        }
コード例 #4
0
        public Gameboy(
            GameboyOptions options,
            Cartridge rom,
            IDisplay display,
            IController controller,
            ISoundOutput soundOutput,
            SerialEndpoint serialEndpoint)
        {
            _display  = display;
            _gbc      = rom.Gbc;
            SpeedMode = new SpeedMode();

            var interruptManager = new InterruptManager(_gbc);

            _timer = new Timer(interruptManager, SpeedMode);
            Mmu    = new Mmu();

            var oamRam = new Ram(0xfe00, 0x00a0);

            _dma        = new Dma(Mmu, oamRam, SpeedMode);
            _gpu        = new Gpu(display, interruptManager, _dma, oamRam, _gbc);
            _hdma       = new Hdma(Mmu);
            _sound      = new Sound(soundOutput, _gbc);
            _serialPort = new SerialPort(interruptManager, serialEndpoint, SpeedMode);

            Mmu.AddAddressSpace(rom);
            Mmu.AddAddressSpace(_gpu);
            Mmu.AddAddressSpace(new Joypad(interruptManager, controller));
            Mmu.AddAddressSpace(interruptManager);
            Mmu.AddAddressSpace(_serialPort);
            Mmu.AddAddressSpace(_timer);
            Mmu.AddAddressSpace(_dma);
            Mmu.AddAddressSpace(_sound);

            Mmu.AddAddressSpace(new Ram(0xc000, 0x1000));
            if (_gbc)
            {
                Mmu.AddAddressSpace(SpeedMode);
                Mmu.AddAddressSpace(_hdma);
                Mmu.AddAddressSpace(new GbcRam());
                Mmu.AddAddressSpace(new UndocumentedGbcRegisters());
            }
            else
            {
                Mmu.AddAddressSpace(new Ram(0xd000, 0x1000));
            }

            Mmu.AddAddressSpace(new Ram(0xff80, 0x7f));
            Mmu.AddAddressSpace(new ShadowAddressSpace(Mmu, 0xe000, 0xc000, 0x1e00));

            Cpu = new Cpu(Mmu, interruptManager, _gpu, display, SpeedMode);

            interruptManager.DisableInterrupts(false);

            if (!options.UseBootstrap)
            {
                InitiliseRegisters();
            }
        }
コード例 #5
0
        public void Main(Application excelApp)
        {
            double[] xValues;
            double[] yValues;


            // 获取原始数据
            Worksheet sht = excelApp.ActiveSheet;

            //
            Range valueRange = RangeValueConverter.GetRange(sht, 1, 1, 117, 2);
            var   value      = valueRange.Value;

            double[] vDate = ArrayConstructor.GetColumn <double>(RangeValueConverter.GetRangeValue <double>(value, false, 0), 0);

            double[,] vValue = RangeValueConverter.GetRangeValue <double>(value, false, 1);
            // 其他计算参数
            int type     = (int)sht.Cells[1, 4].Value;
            int newCount = (int)sht.Cells[2, 4].Value;

            // var sp = new SpeedMode(XdateNum.Select(r => (double)r).ToArray(), Y);
            var sp = new SpeedMode(vDate, ArrayConstructor.GetColumn(vValue, 0));

            SpeedMode.ShrinkResult res;
            switch (type)
            {
            case 1:
            {
                res = sp.ShrinkByIdAverage(newCount);
                if (res == SpeedMode.ShrinkResult.Succeed)
                {
                    // 绘制数据
                    RangeValueConverter.FillRange(sht, 1, 5, sp.GetX(), colPrior: true);
                    RangeValueConverter.FillRange(sht, 1, 6, sp.GetY(), colPrior: true);
                }
                break;
            }

            case 2:
            {
                res = sp.ShrinkByXAxis(newCount);
                if (res == SpeedMode.ShrinkResult.Succeed)
                {
                    // 绘制数据

                    RangeValueConverter.FillRange(sht, 1, 7, sp.GetX(), colPrior: true);
                    RangeValueConverter.FillRange(sht, 1, 8, sp.GetY(), colPrior: true);
                }
                else
                {
                    MessageBox.Show(sp.ErrorMessage);
                }
                break;
            }
            }
        }
コード例 #6
0
        public SizeCalculator(int sizeChange, SpeedMode speedMode, int iterations)
        {
            this.sizeChange     = sizeChange;
            this.speedMode      = speedMode;
            this.iterations     = iterations > 0 ? iterations : 1;
            this.iterationsLeft = iterations;

            current = 0;
            CalcFirst();
        }
コード例 #7
0
        private async Task GoAtSpeedForASecond(SpeedMode speed, CancellationToken cancellationToken)
        {
            var nrOperationsToDo = (int)speed;
            var operationDuration = 1000 / nrOperationsToDo;

            for (var i = 0; i < nrOperationsToDo; i++)
            {
                await Task.Delay(operationDuration, cancellationToken);
                this.perfCounter.Increment(); // increment the perfcounter each time an operation completes.
            }
        }
コード例 #8
0
        static void Main(string[] args)
        {
            args = new string[] { "bg", "PlainText", @"E:\AnalysInfo\Bulgarian\articles", @"E:\AnalysInfo\BulgarianResultPlain.txt" };

            /*
             * Arg0 - short IETF language code
             * Arg1 - InputMode - Xml or plain text parsing
             * Arg2 - data source path
             * Arg3 - path for result
             * Arg4 - (optional)SpeedMode - Normal or Fast
             */

            try
            {
                if (args.Length < 4)
                {
                    throw new Exception("Wrong arguments");
                }

                string    language_code = args[0];
                InputMode input_mode    = (InputMode)Enum.Parse(typeof(InputMode), args[1]);
                string    from_path     = args[2];
                string    to_path       = args[3];
                SpeedMode speed_mode    = SpeedMode.Normal;
                if (args.Length > 4)
                {
                    speed_mode = (SpeedMode)Enum.Parse(typeof(SpeedMode), args[4]);
                }

                List <char> chars = new List <char>();
                switch (language_code)
                {
                case "en":
                case "fr":
                case "de":
                    chars = LatinCharacters.Concat(StandartPunctuationsCharacters).ToList();
                    break;

                case "ru":
                case "bg":
                    chars = CyrillicCharacters.Concat(StandartPunctuationsCharacters).ToList();
                    break;
                }


                LanguageAnalizer analizer = new LanguageAnalizer(chars, from_path, to_path, InputMode.PlainText, SpeedMode.Normal);
                analizer.Analize();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception - {}", ex.Message);
            }
        }
コード例 #9
0
        private async Task GoAtSpeedForASecond(SpeedMode speed, CancellationToken cancellationToken)
        {
            var nrOperationsToDo  = (int)speed;
            var operationDuration = 1000 / nrOperationsToDo;

            for (var i = 0; i < nrOperationsToDo; i++)
            {
                await Task.Delay(operationDuration, cancellationToken);

                this.perfCounter.Increment(); // increment the perfcounter each time an operation completes.
            }
        }
コード例 #10
0
 public void GetArtical(string url,SpeedMode speedmode)
 {
     if (NetworkInterface.GetIsNetworkAvailable())
     {
         this.speedmode = speedmode;
         httpget.GetHtml(url);
         httpget.htmlcallbackforstring = GetArticalDataCallback;
     }
     else
     {
         throw (new Exception("no network!"));
     }
 }
コード例 #11
0
        public LanguageAnalizer(List <char> char_list, string from_file_path, string to_file_path, InputMode input_mode = InputMode.XML, SpeedMode speed_mode = SpeedMode.Normal, int max_ngram_len = 3)
        {
            NGramsDict     = new Dictionary <string, int>();
            FullTextLength = 0;

            FromFilePath   = from_file_path;
            ToFilePath     = to_file_path;
            InputMode      = input_mode;
            SpeedMode      = speed_mode;
            CharList       = char_list;
            MaxNGramLength = max_ngram_len;

            SubresultCount = 5000;
        }
コード例 #12
0
 /// <summary>
 /// 絕對移動 (需選擇使用軸參的手動速度或是自動速度)
 /// </summary>
 /// <param name="dest">目標位置 (millimeter).</param>
 /// <param name="inAuto">手動或自動速度</param>
 public void Move(double dest, SpeedMode inAuto)
 {
     if (axisPara.IsActive && axisPara.Enabled)
     {
         if (inAuto == SpeedMode.Manual)
         {
             CCMNet.CS_mnet_m1_set_tmove_speed(RingNoOfMNet, axisPara.SlaveIP, MmToPulse(axisPara.StrVelM), MmToPulse(axisPara.DevVelM), axisPara.AccVelM, axisPara.DecVelM);
         }
         if (inAuto == SpeedMode.Auto)
         {
             CCMNet.CS_mnet_m1_set_tmove_speed(RingNoOfMNet, axisPara.SlaveIP, MmToPulse(axisPara.StrVelA), MmToPulse(axisPara.DevVelA), axisPara.AccVelA, axisPara.DecVelA);
         }
         nPos = MmToPulse(dest);
         CCMNet.CS_mnet_m1_start_a_move(RingNoOfMNet, axisPara.SlaveIP, nPos);
     }
 }
コード例 #13
0
ファイル: L132M1X1.cs プロジェクト: jajanuj/GitTest
 /// <summary>
 /// 絕對移動 (需選擇使用軸參的手動速度或是自動速度)
 /// </summary>
 /// <param name="dest">目標位置 (millimeter).</param>
 /// <param name="inAuto">手動或自動速度</param>
 public void Move(double dest, SpeedMode inAuto)
 {
     if (axisPara.IsActive && axisPara.Enabled)
     {
         if (inAuto == SpeedMode.Manual)
         {
             CMNET_L132.CS_mnet_m1_set_tmove_speed((U16)axisPara.CardSwitchNo, (U16)axisPara.RingNoOfCard, axisPara.SlaveIP, MmToPulse(axisPara.StrVelM), MmToPulse(axisPara.DevVelM), axisPara.AccVelM, axisPara.DecVelM);
         }
         if (inAuto == SpeedMode.Auto)
         {
             CMNET_L132.CS_mnet_m1_set_tmove_speed((U16)axisPara.CardSwitchNo, (U16)axisPara.RingNoOfCard, axisPara.SlaveIP, MmToPulse(axisPara.StrVelA), MmToPulse(axisPara.DevVelA), axisPara.AccVelA, axisPara.DecVelA);
         }
         nPos = MmToPulse(dest);
         CMNET_L132.CS_mnet_m1_start_a_move((U16)axisPara.CardSwitchNo, (U16)axisPara.RingNoOfCard, axisPara.SlaveIP, nPos);
     }
 }
コード例 #14
0
ファイル: L122M2X4.cs プロジェクト: jajanuj/GitTest
        /// <summary>
        /// 絕對移動 (需選擇使用軸參的手動速度或是自動速度)
        /// </summary>
        /// <param name="dest">目標位置 (millimeter).</param>
        /// <param name="inAuto">手動或自動速度</param>
        public bool AbsolueMove(double dest, SpeedMode inAuto = SpeedMode.Auto)
        {
            I16 rc = -1;

            if (axisPara.IsActive && axisPara.Enabled)
            {
                nPos = MmToPulse(dest);
                if (inAuto == SpeedMode.Manual)
                {
                    rc = CCMNet.CS_mnet_m204_start_ta_move(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, nPos, MmToPulse(axisPara.StrVelM), MmToPulse(axisPara.DevVelM), axisPara.AccVelM, axisPara.DecVelM);
                }
                if (inAuto == SpeedMode.Auto)
                {
                    rc = CCMNet.CS_mnet_m204_start_ta_move(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, nPos, MmToPulse(axisPara.StrVelA), MmToPulse(axisPara.DevVelA), axisPara.AccVelA, axisPara.DecVelA);
                }
            }
            return(rc == 0 ? true : false);
        }
コード例 #15
0
 /// <summary>
 /// 以只考虑数据点个数的方式进行缩减
 /// </summary>
 /// <param name="srcX">数据源中的X数据</param>
 /// <param name="srcY">数据源中的Y数据</param>
 /// <param name="newCount">缩减后的新数据点个数</param>
 /// <param name="srcD">要将缩减后的数据放置在哪里,此属性中只包含一个单元格,表示整个缩减后的曲线的左上角单元格</param>
 public static void ShrinkByPointCount(Range srcX, Range srcY, int newCount, Range srcD)
 {
     double[] x = GetColumnData(srcX);
     double[] y = GetColumnData(srcY);
     if (x.Length > 2 && x.Length == y.Length)
     {
         //
         var sp = new SpeedMode(x, y);
         SpeedMode.ShrinkResult res = sp.ShrinkByIdAverage(newCount);
         if (res == SpeedMode.ShrinkResult.Succeed)
         {
             Worksheet sht = srcD.Worksheet;
             // 绘制数据
             RangeValueConverter.FillRange(sht, srcD.Row, srcD.Column, sp.GetX(), colPrior: true);
             RangeValueConverter.FillRange(sht, srcD.Row, srcD.Column + 1, sp.GetY(), colPrior: true);
         }
     }
     else
     {
         throw new ArgumentException(@"X与Y数据点的个数必须相同而且至少为2。");
     }
 }
コード例 #16
0
        public static double SpeedUnitToMSec(this double speedUnit, SpeedMode mode, SpeedUnits units, Vessel vessel)
        {
            if (mode == SpeedMode.Mach)
            {
                return(speedUnit * vessel.speedOfSound);
            }
            else
            {
                double speed = speedUnit / speedUnitTransform(units, vessel.speedOfSound);
                switch (mode)
                {
                case SpeedMode.True:
                    return(speed);

                case SpeedMode.Indicated:
                    return(speed * Math.Sqrt(vessel.atmDensity / 1.225) * calcStagnationPres(vessel));

                case SpeedMode.Equivalent:
                    return(speed / Math.Sqrt(vessel.atmDensity / 1.225));
                }
                return(0);
            }
        }
コード例 #17
0
ファイル: Dma.cs プロジェクト: fknzxlegend1/CoreBoy-Avalonia
 public Dma(IAddressSpace addressSpace, IAddressSpace oam, SpeedMode speedMode)
 {
     _addressSpace = new DmaAddressSpace(addressSpace);
     _speedMode    = speedMode;
     _oam          = oam;
 }
コード例 #18
0
 public SerialPort(InterruptManager interruptManager, SerialEndpoint serialEndpoint, SpeedMode speedMode)
 {
     _interruptManager = interruptManager;
     _serialEndpoint   = serialEndpoint;
     _speedMode        = speedMode;
 }
コード例 #19
0
 /// <summary>
 /// 相對移動 (需選擇使用軸參的手動速度或是自動速度)
 /// </summary>
 /// <param name="dest">目標位置 (millimeter).</param>
 /// <param name="inAuto">手動或自動速度</param>
 public void Offset(double dest, SpeedMode inAuto)
 {
     Move(getPos() + dest, inAuto);
 }
コード例 #20
0
 internal static AnimationControler.AnimePacket AnimeRectPropPacket(string queueName, string propName, Rectangle rect, int time, SpeedMode speedMode, bool queue, int queueLevel, object qOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     RectThreadParam sizeParam = new RectThreadParam() { CompleteIfCancel = CompleteIfCancel };
     sizeParam.rect = rect;
     sizeParam.time = time;
     sizeParam.PropertyName = propName;
     sizeParam.speedMode = speedMode;
     sizeParam.QueueLevel = queueLevel;
     sizeParam.finalCallback = finalCallback;
     sizeParam.queueName = queueName;
     return new AnimationControler.AnimePacket() { isQueue = queue && queueLevel >= 0, queueOwner = qOwner, method = SetRectProperty, threadParam = sizeParam };
 }
コード例 #21
0
 /// <summary>
 /// Sets the speed and therefore accuracy of the conversion
 /// </summary>
 /// <param name="mode"><see cref="SpeedMode"/></param>
 public void SetSpeedMode(SpeedMode mode)
 {
     NativeCalls.SetSpeedMode(_context, mode);
 }
コード例 #22
0
 internal static AnimationControler.AnimePacket AnimeMultiRectPropPacket(string queueName, string propName, object[] objects, Rectangle[] rects, int time, SpeedMode speedMode, bool queue, int queueLevel, object qOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     RectArrayThreadParam multiRectParam = new RectArrayThreadParam() { CompleteIfCancel = CompleteIfCancel };
     multiRectParam.rects = rects;
     multiRectParam.objects = objects;
     multiRectParam.time = time;
     multiRectParam.PropertyName = propName;
     multiRectParam.speedMode = speedMode;
     multiRectParam.QueueLevel = queueLevel;
     multiRectParam.finalCallback = finalCallback;
     multiRectParam.queueName = queueName;
     return new AnimationControler.AnimePacket() { isQueue = queue && queueLevel >= 0, queueOwner = qOwner, method = SetMultiRectProperty, threadParam = multiRectParam };
 }
コード例 #23
0
 public static object AnimeMultiRectProp(object ctrl, string queueName, string propName, object[] objects, Rectangle[] rects, int time, SpeedMode speedMode, bool queue, int queueLevel, object queueOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     return AnimationControler.ProcessPacket(ctrl, AnimeMultiRectPropPacket(queueName, propName, objects, rects, time, speedMode, queue, queueLevel, queueOwner, finalCallback, CompleteIfCancel));
 }
コード例 #24
0
ファイル: Utility.cs プロジェクト: Kramax/KramaxAutoPilot
 public static double SpeedUnitToMSec(this double speedUnit, SpeedMode mode, SpeedUnits units, Vessel vessel)
 {
     if (mode == SpeedMode.Mach)
         return speedUnit * vessel.speedOfSound;
     else
     {
         double speed = speedUnit / speedUnitTransform(units, vessel.speedOfSound);
         switch (mode)
         {
             case SpeedMode.True:
                 return speed;
             case SpeedMode.Indicated:
                 return speed * Math.Sqrt(vessel.atmDensity / 1.225) * calcStagnationPres(vessel);
             case SpeedMode.Equivalent:
                 return speed / Math.Sqrt(vessel.atmDensity / 1.225);
         }
         return 0;
     }
 }
コード例 #25
0
 public static object AnimeColorProp(object ctrl, string queueName, string propName, Color color, int time, SpeedMode speedMode, bool queue, int queueLevel, object queueOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     return AnimationControler.ProcessPacket(ctrl, AnimeColorPropPacket(queueName, propName, color, time, speedMode, queue, queueLevel, queueOwner, finalCallback, CompleteIfCancel));
 }
コード例 #26
0
 internal static AnimationControler.AnimePacket AnimeColorPropPacket(string queueName, string propName, Color color, int time, SpeedMode speedMode, bool queue, int queueLevel, object qOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     ColorThreadParam colorParam = new ColorThreadParam() { CompleteIfCancel = CompleteIfCancel };
     colorParam.color = color;
     colorParam.time = time;
     colorParam.PropertyName = propName;
     colorParam.speedMode = speedMode;
     colorParam.QueueLevel = queueLevel;
     colorParam.finalCallback = finalCallback;
     colorParam.queueName = queueName;
     return new AnimationControler.AnimePacket() { isQueue = queue && queueLevel >= 0, queueOwner = qOwner, method = SetColorProperty, threadParam = colorParam };
 }
コード例 #27
0
 public Timer(InterruptManager interruptManager, SpeedMode speedMode)
 {
     _speedMode        = speedMode;
     _interruptManager = interruptManager;
 }
コード例 #28
0
 internal static IntPtr SetSpeedMode(IntPtr ctx, SpeedMode speedMode) => SetSpeedMode(ctx, (int)speedMode);
コード例 #29
0
    private void LateUpdate()
    {
        if (!_active)
        {
            return;
        }

        // スピードダウン
        if (Input.GetButtonDown(InputPredefined.JOYSTICK_LEFT_PRESS) || Input.GetKeyDown(KeyCode.F))
        {
            switch (_speedMode)
            {
            case SpeedMode.Default:
                _speedMode = SpeedMode.Slow;
                break;

            case SpeedMode.Turbo:
                _speedMode = SpeedMode.Default;
                break;

            default:
                break;
            }
        }

        // スピードアップ
        if (Input.GetButtonDown(InputPredefined.JOYSTICK_RIGHT_PRESS) || Input.GetKeyDown(KeyCode.G))
        {
            switch (_speedMode)
            {
            case SpeedMode.Default:
                _speedMode = SpeedMode.Turbo;
                break;

            case SpeedMode.Slow:
                _speedMode = SpeedMode.Default;
                break;

            default:
                break;
            }
        }

        _mousePosDelta = Input.mousePosition - _prevMousePos;
        _prevMousePos  = Input.mousePosition;
        _nextPosition  = transform.position;

        // 速度の設定
        var movingSpeed   = _movingSensitivity;
        var hoveringSpeed = _hoveringSensitivity;

        if (Input.GetKey(KeyCode.LeftShift))
        {
            _speedMode = SpeedMode.Turbo;
        }
        else
        {
            _speedMode = SpeedMode.Default;
        }

        switch (_speedMode)
        {
        case SpeedMode.Slow:
            movingSpeed   = _movingSensitivity * 0.5f;
            hoveringSpeed = _hoveringSensitivity * 0.5f;
            break;

        case SpeedMode.Default:
            movingSpeed   = _movingSensitivity * 1.0f;
            hoveringSpeed = _hoveringSensitivity * 1.0f;
            break;

        case SpeedMode.Turbo:
            movingSpeed   = _movingSensitivity * 2.0f;
            hoveringSpeed = _hoveringSensitivity * 2.0f;
            break;

        default:
            break;
        }
        movingSpeed *= transform.lossyScale.x;

        var smoothness = _smoothMode == SmoothMode.Smooth ? _smoothness : _noSmoothness;

        var deltaTime = Time.deltaTime;

        var rightDir   = transform.right;
        var upDir      = _axisMode == AxisMode.Global ? Vector3.up : transform.up;
        var forwardDir = _axisMode == AxisMode.Global ? Vector3.ProjectOnPlane(transform.forward, Vector3.up) : transform.forward;

        var leftJoystick = new Vector2(Input.GetAxis(InputPredefined.HORIZONTAL_LEFT),
                                       Input.GetAxis(InputPredefined.VERTICAL_LEFT));
        var rightJoystick = new Vector2(Input.GetAxis(InputPredefined.HORIZONTAL_RIGHT),
                                        Input.GetAxis(InputPredefined.VERTICAL_RIGHT));

        var trigger = 0f;

        if (Input.GetAxis(InputPredefined.TRIGGER_LEFT) > 0f)
        {
            trigger = -_hoveringSensitivity * (Input.GetAxis(InputPredefined.TRIGGER_LEFT) + 1) / 2.0f;
        }
        else if (Input.GetAxis(InputPredefined.TRIGGER_RIGHT) > 0f)
        {
            trigger = _hoveringSensitivity * (Input.GetAxis(InputPredefined.TRIGGER_RIGHT) + 1) / 2.0f;
        }

        if (Input.GetMouseButton(1) || Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(0) || leftJoystick.sqrMagnitude > 0f || rightJoystick.sqrMagnitude > 0f || trigger != 0f)
        {
            // キーボード移動
            if (Input.GetKey(KeyCode.W))
            {
                _nextPosition = _nextPosition + forwardDir * movingSpeed;
            }

            if (Input.GetKey(KeyCode.A))
            {
                _nextPosition = _nextPosition - rightDir * movingSpeed;
            }

            if (Input.GetKey(KeyCode.S))
            {
                _nextPosition = _nextPosition - forwardDir * movingSpeed;
            }

            if (Input.GetKey(KeyCode.D))
            {
                _nextPosition = _nextPosition + rightDir * movingSpeed;
            }

            if (Input.GetKey(KeyCode.Q))
            {
                _nextPosition = _nextPosition - upDir * hoveringSpeed;
            }

            if (Input.GetKey(KeyCode.E))
            {
                _nextPosition = _nextPosition + upDir * hoveringSpeed;
            }

            // コントローラー移動
            _nextPosition += rightDir * leftJoystick.x * movingSpeed + forwardDir * leftJoystick.y * movingSpeed + upDir * trigger * movingSpeed;

            // マウス回転
            _elapsedAngles.y += Input.GetAxis(InputPredefined.MOUSE_X) * _rotationSensitivity;
            _elapsedAngles.x += -Input.GetAxis(InputPredefined.MOUSE_Y) * _rotationSensitivity;

            // コントローラー回転
            _elapsedAngles.y += rightJoystick.x * _rotationSensitivity;
            _elapsedAngles.x += -rightJoystick.y * _rotationSensitivity;

            transform.localRotation = SmoothDamp.Pow(transform.localRotation,
                                                     Quaternion.Euler(
                                                         new Vector3(_elapsedAngles.x, _elapsedAngles.y, 0f)), smoothness, deltaTime);
        }
        else if (Input.GetMouseButton(2))
        {
            var mouseDelta = _mousePosDelta;
            _nextPosition -= rightDir * mouseDelta.x * movingSpeed * 0.1f;
            _nextPosition -= upDir * mouseDelta.y * movingSpeed * 0.1f;
            //Debug.Log("mouseDelta : " + mouseDelta);
        }

        if (Input.mousePosition.x < Screen.width && Input.mousePosition.x > 0 && Input.mousePosition.y < Screen.height && Input.mousePosition.y > 0)
        {
            // マウスホイール前後移動
            _nextPosition += forwardDir * Input.GetAxis(InputPredefined.MOUSE_SCROLLWHEEL) * movingSpeed * _mouseWheelSensitivity;
        }

        transform.position = SmoothDamp.Pow(transform.position, _nextPosition, smoothness, deltaTime);

        // ズーム
        if (Input.GetKey(KeyCode.C) || Input.GetButton(InputPredefined.BUMPER_RIGHT_PRESS))
        {
            _cam.fieldOfView = SmoothDamp.Pow(_cam.fieldOfView, _defaultFov * 0.5f, 0.01f, deltaTime);
        }
        else if (Input.GetKey(KeyCode.Z) || Input.GetButton(InputPredefined.BUMPER_LEFT_PRESS))
        {
            _cam.fieldOfView = SmoothDamp.Pow(_cam.fieldOfView, _defaultFov * 1.5f, 0.01f, deltaTime);
        }
        else
        {
            _cam.fieldOfView = SmoothDamp.Pow(_cam.fieldOfView, _defaultFov, 0.01f, deltaTime);
        }
    }
コード例 #30
0
 public string ModeFormat(SpeedMode pos) => ModeToNames[pos];
コード例 #31
0
ファイル: L122M2X4.cs プロジェクト: jajanuj/GitTest
 /// <summary>
 /// 相對移動 (需選擇使用軸參的手動速度或是自動速度)
 /// </summary>
 /// <param name="dest">目標位置 (millimeter).</param>
 /// <param name="inAuto">手動或自動速度</param>
 public bool RelativeMove(double dest, SpeedMode inAuto = SpeedMode.Auto)
 {
     return(AbsolueMove(getPos() + dest, inAuto));
 }