Beispiel #1
0
        /// <summary>
        /// 解释 SET 子句。
        /// </summary>
        /// <param name="DbParameters">用于缓存在解释过程中可能会产生的参数。</param>
        /// <returns></returns>
        public override string Parsing(ref List <IDbDataParameter> DbParameters)
        {
            SetBlock      sb      = (SetBlock)this.Description;
            StringBuilder cBuffer = new StringBuilder(" SET");

            sb.Expressions[0].DescriptionParserAdapter = sb.DescriptionParserAdapter;
            string itemBuffer = sb.Expressions[0].GetParser().Parsing(ref DbParameters);

            if (itemBuffer[0] == (char)0x20)
            {
                cBuffer.Append(itemBuffer);
            }
            else
            {
                cBuffer.AppendFormat(" {0}", itemBuffer);
            }
            if (sb.Expressions.Count > 1)
            {
                for (int i = 1; i < sb.Expressions.Count; ++i)
                {
                    sb.Expressions[i].DescriptionParserAdapter = sb.DescriptionParserAdapter;
                    itemBuffer = sb.Expressions[i].GetParser().Parsing(ref DbParameters);
                    if (itemBuffer[0] == (char)0x20)
                    {
                        cBuffer.AppendFormat(",{0}", itemBuffer);
                    }
                    else
                    {
                        cBuffer.AppendFormat(", {0}", itemBuffer);
                    }
                }
            }
            return(cBuffer.ToString());
        }
Beispiel #2
0
        public void PlaceBlock(Vector3S location, byte type)
        {
            var place = new SetBlock {
                Block = type,
                Mode  = 1,
                X     = location.X,
                Y     = location.Y,
                Z     = location.Z
            };

            World.UpdateBlock(location.X, location.Y, location.Z, type);
            _client.SendPacket(place);
        }
Beispiel #3
0
        private IAlgorithmBlock CreateBlockData(BlockData data)
        {
            IAlgorithmBlock result = null;

            switch (data.type)
            {
            case BlockType.Begin:
            {
                BeginBlock block = new BeginBlock();
                block.Data = data;
                result     = block;
            }
            break;

            case BlockType.Action:
            {
                ActionBlock block = new ActionBlock();
                block.Data = data;
                block.Name = data.name;
                result     = block;
            }
            break;

            case BlockType.If:
            {
                IfBlock block = new IfBlock();
                block.Data = data;
                result     = block;
            }
            break;

            case BlockType.While:
            {
                WhileBlock block = new WhileBlock();
                block.Data = data;
                result     = block;
            }
            break;

            case BlockType.Set:
            {
                SetBlock block = new SetBlock();
                block.Data = data;
                result     = block;
            }
            break;
            }

            return(result);
        }
        private void ExecuteBlock(IAlgorithmBlock block)
        {
            if (block == null)
            {
                Debug.Log("IsDone");
                IsDone = true;
                return;
            }

            if (block.Type == BlockType.Action)
            {
                if (_procedures.ContainsKey(block.Data.name))
                {
                    _procedures[block.Data.name].Invoke();
                }

                return;
            }
            else if (block.Type == BlockType.Set)
            {
                SetBlock setBlock = block as SetBlock;

                if (setBlock != null)
                {
                    if (setBlock.Variable.Type == AlgorithmizmModels.Math.ValueType.Bool)
                    {
                        BoolVariable boolVariable = setBlock.Variable as BoolVariable;
                        boolVariable.IsTrue = ((IBoolean)setBlock.Value).IsTrue;
                    }
                    else if (setBlock.Variable.Type == AlgorithmizmModels.Math.ValueType.Number)
                    {
                        FloatVariable boolVariable = setBlock.Variable as FloatVariable;
                        boolVariable.Value = ((INumber)setBlock.Value).Value;
                    }
                }
            }
        }