Example #1
0
        public void Setup(XML xml)
        {
            this.name = xml.GetAttribute("name");
            _options  = xml.GetAttributeInt("options");
            _autoPlay = xml.GetAttributeBool("autoPlay");
            if (_autoPlay)
            {
                this.autoPlayRepeat = xml.GetAttributeInt("autoPlayRepeat", 1);
                this.autoPlayDelay  = xml.GetAttributeFloat("autoPlayDelay");
            }

            XMLList.Enumerator et = xml.GetEnumerator("item");
            while (et.MoveNext())
            {
                XML            cxml = et.Current;
                TransitionItem item = TransitionItem.createInstance(FieldTypes.ParseTransitionActionType(cxml.GetAttribute("type")));
                _items.Add(item);

                item.time     = (float)cxml.GetAttributeInt("time") / (float)FRAME_RATE;
                item.targetId = cxml.GetAttribute("target", string.Empty);
                item.tween    = cxml.GetAttributeBool("tween");
                item.label    = cxml.GetAttribute("label");
                item.Setup(this);

                if (item.tween)
                {
                    item.duration = (float)cxml.GetAttributeInt("duration") / FRAME_RATE;
                    if (item.time + item.duration > _maxTime)
                    {
                        _maxTime = item.time + item.duration;
                    }

                    string ease = cxml.GetAttribute("ease");
                    if (ease != null)
                    {
                        item.easeType = FieldTypes.ParseEaseType(ease);
                    }

                    item.repeat = cxml.GetAttributeInt("repeat");
                    item.yoyo   = cxml.GetAttributeBool("yoyo");
                    item.label2 = cxml.GetAttribute("label2");

                    string v = cxml.GetAttribute("endValue");
                    if (v != null)
                    {
                        DecodeValue(item, cxml.GetAttribute("startValue", string.Empty), item.startValue);
                        DecodeValue(item, v, item.endValue);
                    }
                    else
                    {
                        item.tween = false;
                        DecodeValue(item, cxml.GetAttribute("startValue", string.Empty), item.value);
                    }
                }
                else
                {
                    if (item.time > _maxTime)
                    {
                        _maxTime = item.time;
                    }
                    DecodeValue(item, cxml.GetAttribute("value", string.Empty), item.value);
                }
            }
        }