コード例 #1
0
 void Update()
 {
     if (state != SpState.SPAWNING)
     {
         state = SpState.SPAWNING;
         SpawnCircleEnemyPool();
         state = SpState.WAITING;
     }
 }
コード例 #2
0
        /// <summary>
        /// Parses a <see cref="NetServ.Net.Json.JsonArray"/> and all contained types
        /// from the underlying stream.
        /// </summary>
        /// <returns>The parsed JsonArray.</returns>
        public virtual JsonArray ParseArray()
        {
            AssertNext(TokenType.BeginArray);
            AssertDepth(++this.Depth);

            TokenType type;
            SpState   state = SpState.Initial;
            JsonArray arr   = new JsonArray();

            // Move into the array.
            for (Read(); ;)
            {
                switch (type = NextToken())
                {
                case TokenType.EndArray:
                    if (state == SpState.ReqValue)
                    {
                        goto error;
                    }
                    Read();
                    --this.Depth;
                    return(arr);

                case TokenType.ValueSeperator:
                    if (state != SpState.SepValid)
                    {
                        goto error;
                    }
                    Read();
                    // Empty elements are illegal.
                    state = SpState.ReqValue;
                    break;

                case TokenType.EndObject:
                case TokenType.EOF:
                case TokenType.NameSeperator:
                    goto error;

                default:
                    arr.Add(ParseNext(type));
                    state = SpState.SepValid;
                    break;
                }
            }
error:
            throw new FormatException("The input contains a malformed Json-Array.");
        }
コード例 #3
0
        /// <summary>
        /// Parses a <see cref="NetServ.Net.Json.JsonObject"/> and all contained types
        /// from the underlying stream.
        /// </summary>
        /// <returns>The parsed JsonObject.</returns>
        public virtual JsonObject ParseObject()
        {
            AssertNext(TokenType.BeginObject);
            AssertDepth(++this.Depth);

            string     key;
            TokenType  type;
            SpState    state = SpState.Initial;
            JsonObject obj   = new JsonObject();

            // Move into the object.
            for (Read(); ;)
            {
                switch (NextToken())
                {
                case TokenType.String:
                    key = ParseStringImpl();
                    if (NextToken() != TokenType.NameSeperator)
                    {
                        goto error;
                    }
                    Read();
                    break;

                case TokenType.ValueSeperator:
                    if (state != SpState.SepValid)
                    {
                        goto error;
                    }
                    Read();
                    // Empty members are illegal.
                    state = SpState.ReqValue;
                    continue;

                case TokenType.EndObject:
                    if (state == SpState.ReqValue)
                    {
                        goto error;
                    }
                    Read();
                    --this.Depth;
                    return(obj);

                default:
                    goto error;
                }
                switch (type = NextToken())
                {
                case TokenType.EndArray:
                case TokenType.EndObject:
                case TokenType.NameSeperator:
                case TokenType.EOF:
                case TokenType.ValueSeperator:
                    goto error;

                default:
                    obj.Add(key, ParseNext(type));
                    state = SpState.SepValid;
                    break;
                }
            }
error:
            throw new FormatException("The input contains a malformed Json-Object.");
        }