示例#1
0
    public void SetValue(double newVal)
    {
        if (double.IsNaN(newVal) || double.IsInfinity(newVal))
        {
            return;
        }

        if (!m_isInit)
        {
            LastRawValue = RawValue = newVal;
            m_isInit     = true;
            Debug.Log("Key: " + key + "获得的最初值为" + newVal);
            return;
        }
        else
        {
            LastRawValue = RawValue;
            RawValue     = newVal;
        }

        if (raw)
        {
            TargetValue = RawValue;
        }
        else
        {
            if (isDegree)
            {
                var delta = (RawValue - LastRawValue);
                TargetValue = TGUtility.PreventValueSkipping(TargetValue, LastRawValue, RawValue, reverse);
            }
            else
            {
                int   sign = (reverse) ? -1 : 1;
                float dist = ( float )(RawValue - LastRawValue);
                TargetValue += dist * sign;
            }
        }

        if (damp > 0)
        {
            value = Mathf.Lerp(( float )value, ( float )TargetValue, damp);
        }
        else
        {
            value = TargetValue;
        }
    }
    public KeyResolveValue(KeyPortValueData _data, bool _degree, bool _raw, bool _reverse)
    {
        key      = _data.key;
        isDegree = _degree;

        raw = _raw;

        StartMin = TGUtility.GetValueFromINI(_data.min);
        StartMax = TGUtility.GetValueFromINI(_data.max);

        equation = _data.equation;

        value = m_default = (_data.origin == -1) ?
                            0 : Min + (Max - Min) * _data.origin;

        Ratio = 1;
    }
示例#3
0
    private void TouchInputUpdate(LMTouchCtrl touch)
    {
        if (touch == null)
        {
            return;
        }

        if (touch.IsTouched)
        {
            m_playerCtrl.MoveByTouch(touch.CurrentPosition);
        }


        if (touch.IsTouched)
        {
            TGUtility.DrawHeatmap2D(touch.ScreenPosition);
        }
    }
示例#4
0
    public void ForceWrite()
    {
        string path = m_controller.RootPath + saveFileName;

        INIParser ini = new INIParser();

        ini.Open(path);

        ini.WriteValue("ret", "名称", m_controller.GameNameCn);
        ini.WriteValue("ret", "种类", "2");
        ini.WriteValue("ret", "开始时间", TGUtility.ParseDateTimeToString(m_controller.startTime));
        ini.WriteValue("ret", "结束时间", TGUtility.ParseDateTimeToString(m_controller.endTime));
        WriteExtraData(ini);
        ini.Close();


        Debug.Log("Finished Write");
    }
示例#5
0
    public KeyResolveValue(KeyPortValueData _data, bool _degree, bool _raw, bool _reverse, float _damp)
    {
        key      = _data.key;
        isDegree = _degree;

        raw  = _raw;
        damp = _damp;

        StartMin = TGUtility.GetValueFromINI(_data.min);
        StartMax = TGUtility.GetValueFromINI(_data.max);

        equation = _data.equation;

        TargetValue = m_default = (_data.origin == -1) ?
                                  0 : Min + (Max - Min) * _data.origin;

        Debug.Log("Key: " + key + "初始值为" + TargetValue);

        Ratio = 1;
    }
示例#6
0
    private void TouchInputUpdate()
    {
        var touch = TGInputSetting.Touch;

        if (touch == null)
        {
            return;
        }

        if (touch.IsTouched)
        {
            m_playerCtrl.MoveByTouch(touch.CurrentPosition);
        }


        if (touch.IsTouched)
        {
            TGUtility.DrawHeatmap2D(touch.ScreenPosition);
        }
    }
    public void SetValue(double newVal)
    {
        if (_delayFrame > 0)
        {
            _delayFrame--;
            return;
        }

        if (double.IsNaN(newVal))
        {
            newVal = 0f;
        }

        if (!m_isInit)
        {
            LastRawValue = RawValue = newVal;
            m_isInit     = true;
        }
        else
        {
            LastRawValue = RawValue;
            RawValue     = newVal;
        }

        if (raw)
        {
            value = (float)RawValue;
            return;
        }

        if (isDegree)
        {
            value = TGUtility.PreventValueSkipping(value, LastRawValue, RawValue, reverse);
        }
        else
        {
            int   sign = (reverse) ? -1 : 1;
            float dist = (float)(RawValue - LastRawValue);
            value += dist * sign;
        }
    }
    public override IEnumerator SetupRoutine()
    {
        touchCtrl = GetComponent <LMTouchCtrl>();

        keyInputConfig = TGUtility.ParseConfigFile(configFileName);

        DeviceName = m_controller.gameConfig.GetValue("训练器材", string.Empty);

        KeyportData = keyInputConfig.GetKeyportData(DeviceName);

        if (KeyportData == null)
        {
            m_controller.ErrorQuit("训练器材 " + DeviceName + "不存在!");
            yield break;
        }

        touchCtrl.enabled = KeyportData.type == "touch";

        if (!touchCtrl.enabled)
        {
            // FIXME: Temperory
            if (KeyportData.type == "m7b" && m_gameConfig.evalData.isFullAxis)
            {
                KeyportData.type += "2D";
            }

            portInput = GetProperInput();

            if (!portInput.OnStart(KeyportData))
            {
                m_controller.DebugText(portInput.ErrorTxt);
                touchCtrl.enabled = true;
            }
        }

        m_controller.SetHeatmapEnable(KeyportData.heatmap);
        Debug.Log("Input Setup Success");

        yield return(1);
    }
示例#9
0
 public void Write(string code, bool isHex = true)
 {
     byte[] bytes = (isHex) ? TGUtility.HexToByteArray(code) : Encoding.ASCII.GetBytes(code);
     Debug.Log("Write Port: " + code + ", Converted into: " + BitConverter.ToString(bytes));
     Write(bytes);
 }
 public void Write(string hex)
 {
     byte[] bytes = TGUtility.StringToByteArray(hex);
     Debug.Log("Write Port: " + hex + ", Converted into: " + BitConverter.ToString(bytes));
     Write(bytes);
 }