Exemplo n.º 1
0
        public object UnstageValue(StageItem item, Type targetType)
        {
            Type elementType;

            StageItem[] array = ((StageList)item).Items().ToArray <StageItem>();
            if (targetType.IsArray)
            {
                elementType = targetType.GetElementType();
                Array arrays = Array.CreateInstance(elementType, (int)array.Length);
                for (int i = 0; i < (int)array.Length; i++)
                {
                    object obj = SerializationMaster.Unstage(array[i], elementType);
                    arrays.SetValue(obj, i);
                }
                return(arrays);
            }
            elementType = (!targetType.IsGenericType ? typeof(object) : targetType.GetGenericArguments()[0]);
            IList lists = Activator.CreateInstance(targetType, new object[] { (int)array.Length }) as IList;

            for (int j = 0; j < (int)array.Length; j++)
            {
                object obj1 = SerializationMaster.Unstage(array[j], elementType);
                lists.Add(obj1);
            }
            return(lists);
        }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        Regex monsterItem = new Regex("m (-?[0-9]+) (-?[0-9]+) ([0-9]+)");
        Regex bossItem    = new Regex("b ([0-9]+)");

        string [] lines = StageInformation.text.Split('\n');
        foreach (string line in lines)
        {
            StageItem item = new StageItem();
            switch (line [0])
            {
            case 'm':
            {
                var match = monsterItem.Match(line);
                item.IsBoss    = false;
                item.Position  = int.Parse(match.Groups [1].Value) / 480.0f * 4 - 2;
                item.Angle     = float.Parse(match.Groups [2].Value);
                item.RaiseTime = int.Parse(match.Groups [3].Value) / 1000.0f;
            }
            break;

            case 'b':
            {
                var match = bossItem.Match(line);
                item.IsBoss    = true;
                item.Position  = 0;
                item.Angle     = 0;
                item.RaiseTime = int.Parse(match.Groups [1].Value) / 1000.0f;
            }
            break;
            }
            stageItems.Enqueue(item);
        }
    }
 public void WriteLabel(StageItem l)
 {
     _b.Append('"');
     StringHandler.EscapeString(l.name, _b);
     _b.Append('"');
     _b.Append(':');
 }
Exemplo n.º 4
0
 public void WriteLabel(StageItem l)
 {
     this._b.Append('\"');
     StringHandler.EscapeString(l.name, this._b);
     this._b.Append('\"');
     this._b.Append(':');
 }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        elapsedTime += Time.deltaTime;

        do
        {
            if (stageItems.Count == 0)
            {
                break;
            }
            if (stageItems.Peek().RaiseTime <= elapsedTime)
            {
                StageItem  currentItem = stageItems.Dequeue();
                GameObject mob         = Instantiate(currentItem.IsBoss ? EmittionBoss : EmittionEnemy);
                mob.transform.position = new Vector3(currentItem.Position, currentItem.IsBoss ? 5.6f : 4.4f, 0);
                if (!currentItem.IsBoss)
                {
                    mob.GetComponent <EnemyController> ().Angle = currentItem.Angle;
                }
                else
                {
                    bossName = mob.name;
                    Debug.Log(bossName);
                }
            }
            else
            {
                break;
            }
        } while (true);

        if (stageItems.Count == 0 && GameObject.Find(bossName) == null)
        {
            //Debug.Log ( "NextStage" );
            if (!createdNextStage)
            {
                createdNextStage = true;

                if (NextStage != null)
                {
                    var nextStage = Instantiate(NextStage);
                    --nextStage.transform.GetChild(0).GetComponent <SpriteRenderer> ().sortingOrder;
                    nextStageName = nextStage.name;
                }
            }

            var backgroundRenderer = gameObject.transform.GetChild(0).GetComponent <SpriteRenderer> ();
            backgroundRenderer.color = new Color(1, 1, 1, backgroundRenderer.color.a - (0.3f * Time.deltaTime));
            if (backgroundRenderer.color.a <= 0)
            {
                var nextStage = GameObject.Find(nextStageName);
                if (nextStage != null)
                {
                    ++nextStage.transform.GetChild(0).GetComponent <SpriteRenderer> ().sortingOrder;
                }
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 6
0
        /// <summary>
        /// Unstages the value.
        /// </summary>
        /// <param name="item">The stage item to unstage.</param>
        /// <param name="targetType">Type of the value.</param>
        /// <returns>
        /// The unstaged value.
        /// </returns>
        public object UnstageValue(StageItem item, Type targetType)
        {
            var el = (StageElement)item;

            return(new Vector2(
                       el.AttributeValue <float>("x"),
                       el.AttributeValue <float>("y")));
        }
Exemplo n.º 7
0
        private void RecordRepairedAIs()
        {
            var repaired = new List <StageElement>();

            for (int i = 0; i < _typeResolution.Length; i++)
            {
                var tre = _typeResolution[i].elements;
                for (int j = 0; j < tre.Length; j++)
                {
                    StageItem el = tre[j];
                    while (el.parent != null)
                    {
                        el = el.parent;
                    }

                    var root = el as StageElement;
                    repaired.AddUnique(root);
                }
            }

            for (int i = 0; i < _membersResolution.Length; i++)
            {
                var mre = _membersResolution[i].unresolvedMembers;
                for (int j = 0; j < mre.Count; j++)
                {
                    var items = mre[j].items;

                    for (int k = 0; k < items.Length; k++)
                    {
                        StageItem el = items[k];
                        while (el.parent != null)
                        {
                            el = el.parent;
                        }

                        var root = el as StageElement;
                        repaired.AddUnique(root);
                    }
                }
            }

            for (int i = 0; i < _mismatchedMembers.Length; i++)
            {
                var el = _mismatchedMembers[i].item;
                while (el.parent != null)
                {
                    el = el.parent;
                }

                var root = el as StageElement;
                repaired.AddUnique(root);
            }

            var ids = repaired.Select(el => el.ValueOrDefault("_id", string.Empty));

            //Since the serialization uses a compact (N) format for guids but the AIStorage component does not, we have to do this rather lame conversion.
            _repairedAIIds = ids.Where(id => !string.IsNullOrEmpty(id)).Select(id => new Guid(id).ToString()).ToArray();
        }
Exemplo n.º 8
0
    public override void OnOpen(params object[] args)
    {
        var stageList = StageConfigManager.Instance.stageList;

        foreach (var stage in stageList)
        {
            var item = new StageItem(tmp, stage);
            list.Add(item);
        }
    }
Exemplo n.º 9
0
        /// <summary>
        /// Unstages the value.
        /// </summary>
        /// <param name="item">The stage item to unstage.</param>
        /// <param name="targetType">Type of the value.</param>
        /// <returns>
        /// The unstaged value.
        /// </returns>
        public object UnstageValue(StageItem item, Type targetType)
        {
            var el = (StageElement)item;

            return(new Rect(
                       el.AttributeValue <float>("left"),
                       el.AttributeValue <float>("top"),
                       el.AttributeValue <float>("width"),
                       el.AttributeValue <float>("height")));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Unstages the value.
        /// </summary>
        /// <param name="item">The stage item to unstage.</param>
        /// <param name="targetType">Type of the value.</param>
        /// <returns>
        /// The unstaged value.
        /// </returns>
        public object UnstageValue(StageItem item, Type targetType)
        {
            var el = (StageElement)item;

            return(new Color(
                       el.AttributeValue <float>("r"),
                       el.AttributeValue <float>("g"),
                       el.AttributeValue <float>("b"),
                       el.AttributeValue <float>("a")));
        }
        public string Serialize(StageItem item, bool pretty)
        {
            StageElement stageElement = item as StageElement;

            if (stageElement == null)
            {
                throw new ArgumentException("Only StageElements can serve as the root of a serialized graph.");
            }
            return((new StagedToJson(pretty)).Serialize(stageElement));
        }
 public object UnstageValue(StageItem item, Type targetType)
 {
     return(new AnimationCurve((
                                   from key in ((StageElement)item).Elements()
                                   select new Keyframe()
     {
         time = key.AttributeValue <float>("time"),
         @value = key.AttributeValue <float>("value"),
         inTangent = key.AttributeValue <float>("inTangent"),
         outTangent = key.AttributeValue <float>("outTangent"),
         tangentMode = key.AttributeValue <int>("tangentMode")
     }).ToArray <Keyframe>()));
 }
Exemplo n.º 13
0
        public StageItem StageValue(string name, object value)
        {
            IList     lists     = value as IList;
            int       count     = lists.Count;
            StageList stageList = new StageList(name);

            for (int i = 0; i < count; i++)
            {
                StageItem stageItem = SerializationMaster.Stage("Item", lists[i]);
                stageList.Add(stageItem);
            }
            return(stageList);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Serializes the specified staged object (or object graph).
        /// </summary>
        /// <param name="item">The staged representation of the object to serialize.</param>
        /// <param name="pretty">Whether to serialize the data in a pretty (reader friendly) format.</param>
        /// <returns>
        /// The serialized representation of the object.
        /// </returns>
        /// <exception cref="System.ArgumentException">Only StageElements can serve as the root of a serialized graph.</exception>
        public string Serialize(StageItem item, bool pretty)
        {
            var root = item as StageElement;

            if (root == null)
            {
                throw new ArgumentException("Only StageElements can serve as the root of a serialized graph.");
            }

            var s = new StagedToJson(pretty);

            return(s.Serialize(root));
        }
Exemplo n.º 15
0
            static bool Prefix(Stage __instance, ref List <StageItem> ___orderList)
            {
                PropertyInfo property = typeof(Stage).GetProperty("CurDay", BindingFlags.Instance);

                property.SetValue(__instance, Module <TimeManager> .Self.Days, null);

                MethodInfo dynMethod = __instance.GetType().GetMethod("ClearDataButMaxAccept", BindingFlags.NonPublic | BindingFlags.Instance);

                dynMethod.Invoke(__instance, new object[] { });

                List <StageItemData> list = StageItemData.List;

                for (int i = 0; i < list.Count; i++)
                {
                    StageItem stageItem = new StageItem();
                    stageItem.Convert(list[i]);
                    ___orderList.Add(stageItem);
                }

                List <TypePriceData> list2 = TypePriceData.List;
                int            num2        = 0;
                List <IdCount> list3       = new List <IdCount>();

                for (int j = 0; j < list2.Count; j++)
                {
                    TypePriceData typePriceData = list2[j];
                    if (typePriceData.NumLimit != null && typePriceData.NumLimit.Length > 0 && typePriceData.NumLimit[0] > 0)
                    {
                        ___orderList[num2].SetPriceType(typePriceData.Type);
                        list3.Add(typePriceData.Type, 1);
                        num2++;
                    }
                    if (num2 >= list.Count)
                    {
                        break;
                    }
                }
                num2  = 0;
                list2 = GameUtils.RandomSortList <TypePriceData>(list2);
                foreach (StageItem stageItem2 in ___orderList)
                {
                    if (stageItem2.PriceType == 0)
                    {
                        TypePriceData typePriceData2 = list2[num2 % list2.Count];
                        stageItem2.SetPriceType(typePriceData2.Type);
                        num2++;
                    }
                }

                return(false);
            }
Exemplo n.º 16
0
        private string GetParentTypeName(StageItem item)
        {
            var parent = item.parent;

            if (parent is StageElement)
            {
                var parentTypeName = ((StageElement)parent).AttributeValueOrDefault <string>("type");
                return(parentTypeName != null ? parentTypeName : string.Empty);
            }

            var listType = ResolveExpectedBaseType(item, false);

            return(listType != null?listType.ProperName(false) : "List");
        }
Exemplo n.º 17
0
        /// <summary>
        /// Unstages the value.
        /// </summary>
        /// <param name="item">The stage item to unstage.</param>
        /// <param name="targetType">Type of the value.</param>
        /// <returns>
        /// The unstaged value.
        /// </returns>
        public object UnstageValue(StageItem item, Type targetType)
        {
            var el = (StageElement)item;

            return(new Bounds(
                       new Vector3(
                           SerializationMaster.FromString <float>(el.Attribute("center.x").value),
                           SerializationMaster.FromString <float>(el.Attribute("center.y").value),
                           SerializationMaster.FromString <float>(el.Attribute("center.z").value)),
                       new Vector3(
                           SerializationMaster.FromString <float>(el.Attribute("size.x").value),
                           SerializationMaster.FromString <float>(el.Attribute("size.y").value),
                           SerializationMaster.FromString <float>(el.Attribute("size.z").value))));
        }
        /// <summary>
        /// Unstages the value.
        /// </summary>
        /// <param name="item">The stage item to unstage.</param>
        /// <param name="targetType">Type of the value.</param>
        /// <returns>
        /// The unstaged value.
        /// </returns>
        public object UnstageValue(StageItem item, Type targetType)
        {
            var element = (StageElement)item;
            var keys    = (from key in element.Elements()
                           select new Keyframe
            {
                time = key.AttributeValue <float>("time"),
                value = key.AttributeValue <float>("value"),
                inTangent = key.AttributeValue <float>("inTangent"),
                outTangent = key.AttributeValue <float>("outTangent"),
                tangentMode = key.AttributeValue <int>("tangentMode")
            }).ToArray();

            return(new AnimationCurve(keys));
        }
        public object UnstageValue(StageItem item, Type targetType)
        {
            StageElement[] array            = ((StageList)item).Elements().ToArray <StageElement>();
            Type[]         genericArguments = targetType.GetGenericArguments();
            Type           type             = genericArguments[0];
            Type           type1            = genericArguments[1];
            IDictionary    dictionaries     = Activator.CreateInstance(targetType, new object[] { (int)array.Length }) as IDictionary;

            for (int i = 0; i < (int)array.Length; i++)
            {
                StageElement stageElement = array[i];
                object       obj          = SerializationMaster.Unstage(stageElement.Item("key"), type);
                object       obj1         = SerializationMaster.Unstage(stageElement.Item("value"), type1);
                dictionaries.Add(obj, obj1);
            }
            return(dictionaries);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Unstages the value.
        /// </summary>
        /// <param name="item">The stage item to unstage.</param>
        /// <param name="targetType">Type of the value.</param>
        /// <returns>
        /// The unstaged value.
        /// </returns>
        public object UnstageValue(StageItem item, Type targetType)
        {
            var el = (StageList)item;

            var items = el.Items().ToArray();

            Type itemType;

            if (targetType.IsArray)
            {
                itemType = targetType.GetElementType();

                var arr = Array.CreateInstance(itemType, items.Length);
                for (int i = 0; i < items.Length; i++)
                {
                    var itemValue = SerializationMaster.Unstage(items[i], itemType);
                    arr.SetValue(itemValue, i);
                }

                return(arr);
            }

            //A list
            if (targetType.IsGenericType)
            {
                itemType = targetType.GetGenericArguments()[0];
            }
            else
            {
                itemType = typeof(object);
            }

            var list = Activator.CreateInstance(targetType, items.Length) as IList;

            for (int i = 0; i < items.Length; i++)
            {
                var itemValue = SerializationMaster.Unstage(items[i], itemType);
                list.Add(itemValue);
            }

            return(list);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Unstages the value.
        /// </summary>
        /// <param name="item">The stage item to unstage.</param>
        /// <param name="targetType">Type of the value.</param>
        /// <returns>
        /// The unstaged value.
        /// </returns>
        public object UnstageValue(StageItem item, Type targetType)
        {
            var el = (StageList)item;

            var elements = el.Elements().ToArray();

            var  typeArgs  = targetType.GetGenericArguments();
            Type keyType   = typeArgs[0];
            Type valueType = typeArgs[1];

            var dic = Activator.CreateInstance(targetType, elements.Length) as IDictionary;

            for (int i = 0; i < elements.Length; i++)
            {
                var element = elements[i];
                var key     = SerializationMaster.Unstage(element.Item("key"), keyType);
                var value   = SerializationMaster.Unstage(element.Item("value"), valueType);
                dic.Add(key, value);
            }

            return(dic);
        }
Exemplo n.º 22
0
        private Type ResolveExpectedBaseType(StageItem el, bool elementType)
        {
            var parent = el.parent;

            if (parent == null)
            {
                return(null);
            }

            var parentElement = parent as StageElement;

            if (parentElement != null)
            {
                var parentTypeName = parentElement.AttributeValueOrDefault <string>("type");
                if (parentTypeName == null)
                {
                    /* For custom types that have no type attribute, the entire type will be validated at once, so we ignore individual members. */
                    return(null);
                }

                Type parentType;
                if (!_identifiedTypes.TryGetValue(parentTypeName, out parentType))
                {
                    return(null);
                }

                var prop = parentType.GetProperty(el.name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if (prop != null)
                {
                    return(prop.PropertyType);
                }

                var field = parentType.GetField(el.name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if (field != null)
                {
                    return(field.FieldType);
                }

                return(null);
            }

            var parentList = parent as StageList;

            if (parentList == null)
            {
                return(null);
            }

            var listType = ResolveExpectedBaseType(parentList, elementType);

            if (!elementType)
            {
                return(listType);
            }

            while (typeof(IList).IsAssignableFrom(listType))
            {
                if (listType.IsArray)
                {
                    listType = listType.GetElementType();
                }
                else if (listType.IsGenericType)
                {
                    listType = listType.GetGenericArguments()[0];
                }
                else
                {
                    listType = null;
                }
            }

            return(listType);
        }
Exemplo n.º 23
0
        public object UnstageValue(StageItem item, Type targetType)
        {
            StageElement stageElement = (StageElement)item;

            return(new Vector4(stageElement.AttributeValue <float>("x"), stageElement.AttributeValue <float>("y"), stageElement.AttributeValue <float>("z"), stageElement.AttributeValue <float>("w")));
        }