コード例 #1
0
 public void Init(int _num)
 {
     punchInitPos   = curTrans.position;
     punchHeightPos = punchInitPos + new Vector3(0f, punchHeight, 0f);
     targetTime     = 0f;
     label.text     = _num.ToString();
     curNumState    = NumState.punching_up;
 }
コード例 #2
0
 public CoordinateParserState(ref ReadOnlySpan <char> chars)
 {
     CurrNumState  = NumState.Separator;
     NewNumState   = NumState.Separator;
     CharsPosition = 0;
     Position      = 0;
     HasMore       = chars.Length > 0;
     if (char.IsLetter(chars[0]))
     {
         ++CharsPosition;
     }
 }
コード例 #3
0
        void Update()
        {
            switch (curNumState)
            {
            case NumState.showUp:
                float delta = Time.deltaTime * showUpSpeed * dir;
                curTrans.position += new Vector3(0f, delta, 0f);

                targetTime += Time.deltaTime;
                if (targetTime >= showUpTimeLength)
                {
                    moveUpTimeLength = 0f;
                    curNumState      = NumState.moveSlow;
                }
                break;

            case NumState.moveSlow:
                delta              = Time.deltaTime * moveUpTimeSpeed * dir;
                curTrans.position += new Vector3(0f, delta, 0f);

                targetTime += Time.deltaTime;
                // if(moveUpTimeLength>=moveUpTimeLength)
                if (targetTime >= moveUpTimeLength)
                {
                    targetTime  = 1f;
                    curNumState = NumState.fadeOut;
                }
                break;

            case NumState.fadeOut:

                targetTime -= Time.deltaTime * fadeOutSpeed;

                delta              = Time.deltaTime * moveUpTimeSpeed * dir;
                curTrans.position += new Vector3(0f, delta, 0f);

                //mulLabel.color = new Color(mulLabelColor.r, mulLabelColor.g, mulLabelColor.b, targetTime);
                //valueLabel.color = new Color(valueLabelColor.r, valueLabelColor.g, valueLabelColor.b, targetTime);

                // mulSprite.color = new Color(mulSpriteColor.r, mulSpriteColor.g, mulSpriteColor.b, targetTime);
                // valueSprite.color = new Color(valueSpriteColor.r, valueSpriteColor.g, valueSpriteColor.b, targetTime);
                if (targetTime <= 0f)
                {
                    Factory.Recycle(this.transform);
                    curNumState = NumState.none;
                }
                break;

            default:
                break;
            }
        }
コード例 #4
0
        void Update()
        {
            switch (curNumState)
            {
            case NumState.punching_up:
                targetTime       += Time.deltaTime * punchSpeed;
                curTrans.position = Vector3.Lerp(punchInitPos, punchHeightPos, targetTime);
                if (targetTime >= 1f)
                {
                    targetTime  = 0f;
                    curNumState = NumState.punching_down;
                }
                break;

            case NumState.punching_down:
                targetTime       += Time.deltaTime * punchSpeed;
                curTrans.position = Vector3.Lerp(punchHeightPos, punchInitPos, targetTime);
                if (targetTime >= 1f)
                {
                    targetTime  = 0f;
                    curNumState = NumState.wait;
                }
                break;

            case NumState.wait:
                targetTime += Time.deltaTime;
                if (targetTime >= punchDoneWaitTimeLength)
                {
                    targetTime  = 0f;
                    curNumState = NumState.fadeOut;
                }
                break;

            case NumState.fadeOut:
                targetTime += Time.deltaTime * fadeOutSpeed;
                if (targetTime >= 1f)
                {
                    curNumState = NumState.none;

                    Factory.Recycle(this.transform);
                }
                break;

            default:
                break;
            }
        }
コード例 #5
0
ファイル: CoordinateParser.cs プロジェクト: zzc1231/SVG
        public bool TryGetBool(out bool result)
        {
            while (i < _coords.Length && _parseWorked)
            {
                switch (_currState)
                {
                case NumState.separator:
                    if (IsCoordSeparator(_coords[i]))
                    {
                        _newState = NumState.separator;
                    }
                    else if (_coords[i] == '0')
                    {
                        result    = false;
                        _newState = NumState.separator;
                        _pos      = i + 1;
                        return(MarkState(true));
                    }
                    else if (_coords[i] == '1')
                    {
                        result    = true;
                        _newState = NumState.separator;
                        _pos      = i + 1;
                        return(MarkState(true));
                    }
                    else
                    {
                        result = false;
                        return(MarkState(false));
                    }
                    break;

                default:
                    result = false;
                    return(MarkState(false));
                }
                i++;
            }
            result = false;
            return(MarkState(false));
        }
コード例 #6
0
ファイル: CoordinateParser.cs プロジェクト: dteunkenstt/SVG
 public bool TryGetBool(out bool result)
 {
     while (i < _coords.Length && _parseWorked)
     {
         switch (_currState)
         {
             case NumState.separator:
                 if (IsCoordSeparator(_coords[i]))
                 {
                     _newState = NumState.separator;
                 }
                 else if (_coords[i] == '0')
                 {
                     result = false;
                     _newState = NumState.separator;
                     _pos = i + 1;
                     return MarkState(true);
                 }
                 else if (_coords[i] == '1')
                 {
                     result = true;
                     _newState = NumState.separator;
                     _pos = i + 1;
                     return MarkState(true);
                 }
                 else
                 {
                     result = false;
                     return MarkState(false);
                 }
                 break;
             default:
                 result = false;
                 return MarkState(false);
         }
         i++;
     }
     result = false;
     return MarkState(false);
 }
コード例 #7
0
        public void Init(int _mul, int _value, bool _upsideDown)
        {
            mulLabel.text   = _mul.ToString();
            valueLabel.text = _value.ToString();

            if (_upsideDown)
            {
                // 如果玩家炮台需要旋转,则调整泡泡运动方向
                if (CanonCtrl.Instance.turn_screen == true && CanonCtrl.Instance.turn_screen_on_of)
                {
                    dir = 1;
                }
                else
                {
                    dir = -1;
                }
            }
            else
            {
                // 如果玩家炮台需要旋转,则调整泡泡运动方向
                if (CanonCtrl.Instance.turn_screen == true && CanonCtrl.Instance.turn_screen_on_of)
                {
                    dir = -1;
                }
                else
                {
                    dir = 1;
                }
            }

            targetTime  = 0f;
            curNumState = NumState.showUp;

            // init color.
            //mulLabel.color = mulLabelColor;
            //valueLabel.color = valueLabelColor;

            //mulSprite.color = mulSpriteColor;
            //	valueSprite.color = valueSpriteColor;
        }
コード例 #8
0
ファイル: CoordinateParser.cs プロジェクト: dteunkenstt/SVG
        public bool TryGetFloat(out float result)
        {
            while (i < _coords.Length && _parseWorked)
            {
                switch (_currState)
                {
                    case NumState.separator:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.integer;
                        }
                        else if (IsCoordSeparator(_coords[i]))
                        {
                            _newState = NumState.separator;
                        }
                        else
                        {
                            switch (_coords[i])
                            {
                                case '.':
                                    _newState = NumState.decPlace;
                                    break;
                                case '+':
                                case '-':
                                    _newState = NumState.prefix;
                                    break;
                                default:
                                    _newState = NumState.invalid;
                                    break;
                            }
                        }
                        break;
                    case NumState.prefix:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.integer;
                        }
                        else if (_coords[i] == '.')
                        {
                            _newState = NumState.decPlace;
                        }
                        else
                        {
                            _newState = NumState.invalid;
                        }
                        break;
                    case NumState.integer:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.integer;
                        }
                        else if (IsCoordSeparator(_coords[i]))
                        {
                            _newState = NumState.separator;
                        }
                        else
                        {
                            switch (_coords[i])
                            {
                                case '.':
                                    _newState = NumState.decPlace;
                                    break;
                                case 'E':
                                case 'e':
                                    _newState = NumState.exponent;
                                    break;
                                case '+':
                                case '-':
                                    _newState = NumState.prefix;
                                    break;
                                default:
                                    _newState = NumState.invalid;
                                    break;
                            }
                        }
                        break;
                    case NumState.decPlace:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.fraction;
                        }
                        else if (IsCoordSeparator(_coords[i]))
                        {
                            _newState = NumState.separator;
                        }
                        else
                        {
                            switch (_coords[i])
                            {
                                case 'E':
                                case 'e':
                                    _newState = NumState.exponent;
                                    break;
                                case '+':
                                case '-':
                                    _newState = NumState.prefix;
                                    break;
                                default:
                                    _newState = NumState.invalid;
                                    break;
                            }
                        }
                        break;
                    case NumState.fraction:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.fraction;
                        }
                        else if (IsCoordSeparator(_coords[i]))
                        {
                            _newState = NumState.separator;
                        }
                        else
                        {
                            switch (_coords[i])
                            {
                                case '.':
                                    _newState = NumState.decPlace;
                                    break;
                                case 'E':
                                case 'e':
                                    _newState = NumState.exponent;
                                    break;
                                case '+':
                                case '-':
                                    _newState = NumState.prefix;
                                    break;
                                default:
                                    _newState = NumState.invalid;
                                    break;
                            }
                        }
                        break;
                    case NumState.exponent:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.expValue;
                        }
                        else if (IsCoordSeparator(_coords[i]))
                        {
                            _newState = NumState.invalid;
                        }
                        else
                        {
                            switch (_coords[i])
                            {
                                case '+':
                                case '-':
                                    _newState = NumState.expPrefix;
                                    break;
                                default:
                                    _newState = NumState.invalid;
                                    break;
                            }
                        }
                        break;
                    case NumState.expPrefix:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.expValue;
                        }
                        else
                        {
                            _newState = NumState.invalid;
                        }
                        break;
                    case NumState.expValue:
                        if (char.IsNumber(_coords[i]))
                        {
                            _newState = NumState.expValue;
                        }
                        else if (IsCoordSeparator(_coords[i]))
                        {
                            _newState = NumState.separator;
                        }
                        else
                        {
                            switch (_coords[i])
                            {
                                case '.':
                                    _newState = NumState.decPlace;
                                    break;
                                case '+':
                                case '-':
                                    _newState = NumState.prefix;
                                    break;
                                default:
                                    _newState = NumState.invalid;
                                    break;
                            }
                        }
                        break;
                }

                if (_newState < _currState)
                {
                    result = float.Parse(_coords.Substring(_pos, i - _pos), NumberStyles.Float, CultureInfo.InvariantCulture);
                    _pos = i;
                    _currState = _newState;
                    return MarkState(true);
                }
                else if (_newState != _currState && _currState == NumState.separator)
                {
                    _pos = i;
                }

                if (_newState == NumState.invalid)
                {
                    result = float.MinValue;
                    return MarkState(false);
                }
                _currState = _newState;
                i++;
            }

            if (_currState == NumState.separator || !_parseWorked || _pos >= _coords.Length)
            {
                result = float.MinValue;
                return MarkState(false);
            }
            else
            {
                result = float.Parse(_coords.Substring(_pos, _coords.Length - _pos), NumberStyles.Float, CultureInfo.InvariantCulture);
                _pos = _coords.Length;
                return MarkState(true);
            }
        }
コード例 #9
0
ファイル: CoordinateParser.cs プロジェクト: zzc1231/SVG
        public bool TryGetFloat(out float result)
        {
            while (i < _coords.Length && _parseWorked)
            {
                switch (_currState)
                {
                case NumState.separator:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.integer;
                    }
                    else if (IsCoordSeparator(_coords[i]))
                    {
                        _newState = NumState.separator;
                    }
                    else
                    {
                        switch (_coords[i])
                        {
                        case '.':
                            _newState = NumState.decPlace;
                            break;

                        case '+':
                        case '-':
                            _newState = NumState.prefix;
                            break;

                        default:
                            _newState = NumState.invalid;
                            break;
                        }
                    }
                    break;

                case NumState.prefix:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.integer;
                    }
                    else if (_coords[i] == '.')
                    {
                        _newState = NumState.decPlace;
                    }
                    else
                    {
                        _newState = NumState.invalid;
                    }
                    break;

                case NumState.integer:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.integer;
                    }
                    else if (IsCoordSeparator(_coords[i]))
                    {
                        _newState = NumState.separator;
                    }
                    else
                    {
                        switch (_coords[i])
                        {
                        case '.':
                            _newState = NumState.decPlace;
                            break;

                        case 'E':
                        case 'e':
                            _newState = NumState.exponent;
                            break;

                        case '+':
                        case '-':
                            _newState = NumState.prefix;
                            break;

                        default:
                            _newState = NumState.invalid;
                            break;
                        }
                    }
                    break;

                case NumState.decPlace:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.fraction;
                    }
                    else if (IsCoordSeparator(_coords[i]))
                    {
                        _newState = NumState.separator;
                    }
                    else
                    {
                        switch (_coords[i])
                        {
                        case 'E':
                        case 'e':
                            _newState = NumState.exponent;
                            break;

                        case '+':
                        case '-':
                            _newState = NumState.prefix;
                            break;

                        default:
                            _newState = NumState.invalid;
                            break;
                        }
                    }
                    break;

                case NumState.fraction:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.fraction;
                    }
                    else if (IsCoordSeparator(_coords[i]))
                    {
                        _newState = NumState.separator;
                    }
                    else
                    {
                        switch (_coords[i])
                        {
                        case '.':
                            _newState = NumState.decPlace;
                            break;

                        case 'E':
                        case 'e':
                            _newState = NumState.exponent;
                            break;

                        case '+':
                        case '-':
                            _newState = NumState.prefix;
                            break;

                        default:
                            _newState = NumState.invalid;
                            break;
                        }
                    }
                    break;

                case NumState.exponent:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.expValue;
                    }
                    else if (IsCoordSeparator(_coords[i]))
                    {
                        _newState = NumState.invalid;
                    }
                    else
                    {
                        switch (_coords[i])
                        {
                        case '+':
                        case '-':
                            _newState = NumState.expPrefix;
                            break;

                        default:
                            _newState = NumState.invalid;
                            break;
                        }
                    }
                    break;

                case NumState.expPrefix:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.expValue;
                    }
                    else
                    {
                        _newState = NumState.invalid;
                    }
                    break;

                case NumState.expValue:
                    if (char.IsNumber(_coords[i]))
                    {
                        _newState = NumState.expValue;
                    }
                    else if (IsCoordSeparator(_coords[i]))
                    {
                        _newState = NumState.separator;
                    }
                    else
                    {
                        switch (_coords[i])
                        {
                        case '.':
                            _newState = NumState.decPlace;
                            break;

                        case '+':
                        case '-':
                            _newState = NumState.prefix;
                            break;

                        default:
                            _newState = NumState.invalid;
                            break;
                        }
                    }
                    break;
                }

                if (_newState < _currState)
                {
                    result     = float.Parse(_coords.Substring(_pos, i - _pos), NumberStyles.Float, CultureInfo.InvariantCulture);
                    _pos       = i;
                    _currState = _newState;
                    return(MarkState(true));
                }
                else if (_newState != _currState && _currState == NumState.separator)
                {
                    _pos = i;
                }

                if (_newState == NumState.invalid)
                {
                    result = float.MinValue;
                    return(MarkState(false));
                }
                _currState = _newState;
                i++;
            }

            if (_currState == NumState.separator || !_parseWorked || _pos >= _coords.Length)
            {
                result = float.MinValue;
                return(MarkState(false));
            }
            else
            {
                result = float.Parse(_coords.Substring(_pos, _coords.Length - _pos), NumberStyles.Float, CultureInfo.InvariantCulture);
                _pos   = _coords.Length;
                return(MarkState(true));
            }
        }
コード例 #10
0
        private bool CheckData()
        {
            string voyageNo = txtVoyageNo.Text.Trim();

            if (voyageNo == "")
            {
                MessageBox.Show("总运单号不能为空");
                txtVoyageNo.Focus();
                return(false);
            }

            if (!rbI.Checked && !rbE.Checked)
            {
                MessageBox.Show("请选择进出口选项");
                return(false);
            }

            if (!rbA.Checked && !rbL.Checked)
            {
                MessageBox.Show("请选择空陆运选项");
                return(false);
            }

            bool isPerPass = CheckActionPer(voyageNo);

            //  CheckButtonEnable(hasValue);
            if (!isPerPass)
            {
                return(false);
            }

            if (!CheckVoyageLength())
            {
                txtVoyageNo.Focus();
                return(false);
            }



            string val     = "";
            int    itemp   = 0;
            double idouble = 0;

            foreach (DataGridViewRow item in this.superGrid1.Rows)
            {
                NumState state = CheckItemNumState(item);
                if (state == NumState.TicketLagerThenPACK)
                {
                    MessageBox.Show("票数必须小于等于件数");
                    item.Cells["Ticket"].Style.BackColor = Color.Red;
                    item.Cells["Piece"].Style.BackColor  = Color.Red;
                    return(false);
                }
                else
                {
                    item.Cells["Ticket"].Style.BackColor = Color.White;
                    item.Cells["Piece"].Style.BackColor  = Color.White;
                }

                if (state == NumState.ValueError)
                {
                    MessageBox.Show("数值输入错误,请检查!");
                    return(false);
                }

                if (state == NumState.HasOneZero)
                {
                    MessageBox.Show("票数,件数,重量有某一项为0,禁止保存!");
                    return(false);
                }

                for (int i = 2; i < 4; i++)
                {
                    val = item.Cells[i].Value.ToString().Trim();
                    if (!string.IsNullOrEmpty(val))
                    {
                        if (!int.TryParse(val, out itemp) || itemp < 0)
                        {
                            MessageBox.Show("输入项有非法字符");
                            return(false);
                        }
                    }
                }

                for (int i = 4; i < 6; i++)
                {
                    val = item.Cells[i].Value.ToString().Trim();
                    if (!string.IsNullOrEmpty(val))
                    {
                        if (!double.TryParse(val, out idouble) || idouble < 0)
                        {
                            MessageBox.Show("输入项有非法字符");
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }