Example #1
0
    protected void parseTween(object target)
    {
        bool isRelative   = SafeGetVar <bool>(vars, "__relative__");
        bool isSkipPlugin = SafeGetVar <bool>(vars, "skipPlugin");

        foreach (string p in this.vars.Keys)
        {
            if (!(_reservedVars.ContainsKey(p)))
            {
                NTweenPlugin plugin;
                if (!isSkipPlugin && plugins.ContainsKey(p) && (plugin = (NTweenPlugin)Activator.CreateInstance((Type)plugins[p])).onInit(target, vars[p], isRelative, this))
                {
                    this._firstPT = new NTweenData(plugin,
                                                   "setRatio",
                                                   0f,
                                                   1f,
                                                   plugin.propName,
                                                   true,
                                                   this._firstPT);
                }
                else
                {
                    var s = GetPropValue(target, p);
                    if (null == s)
                    {
                        throw new Exception("Unknown property:" + p + " of " + target);
                    }
                    else
                    {
                        _firstPT = new NTweenData(target, p, s, (isRelative ? vars[p] : Subtraction(vars[p], s)), p, false, _firstPT);
                    }
                }
            }
        }
    }
Example #2
0
 protected void addSubTween(object target, string propName, object start, object change)
 {
     if (change != null)
     {
         _firstPT = new NTweenData(target, propName, start, change, propName, false, _firstPT);
     }
 }
Example #3
0
    protected override void onUpdate(float ratio)
    {
        NTweenData pt = this._firstPT;

        while (pt != null)
        {
            var co = ((Color)(pt.change));
            var r  = co.a * ratio;
            SetPropValue(pt.target, pt.property, (Color)pt.start + new Color(0, 0, 0, r));
            pt = pt._next;
        }
    }
Example #4
0
 public NTweenData(object target, string property, object start, object change, string name, bool isPlugin, NTweenData nextNode = null)
 {
     this.target   = target;
     this.property = property;
     this.start    = start;
     this.change   = change;
     this.name     = name;
     this.isPlugin = isPlugin;
     if (nextNode != null)
     {
         nextNode._prev = this;
         this._next     = nextNode;
     }
 }
Example #5
0
 public void kill(params string[] varListToKill)
 {
     if (varListToKill.Length == 0)
     {
         _container.Remove(this);
     }
     else
     {
         var pt = _firstPT;
         while (pt != null)
         {
             var next = pt._next;
             foreach (var s in varListToKill)
             {
                 if (s == pt.name)
                 {
                     if (pt._prev != null)
                     {
                         pt._prev._next = pt._next;
                     }
                     else if (pt == _firstPT)
                     {
                         _firstPT = pt._next;
                     }
                     if (pt._next != null)
                     {
                         pt._next._prev = pt._prev;
                     }
                     pt._next = pt._prev = null;
                 }
             }
             pt = next;
         }
         if (_firstPT == null)
         {
             _container.Remove(this);
         }
     }
 }
Example #6
0
    private void init()
    {
        if (vars["__fromVars__"] != null)
        {
            var fromVars = (Hashtable)vars["__fromVars__"];
            fromVars["overwrite"] = 0;
            fromVars["renderNow"] = true;
            to(target, 0, fromVars);
        }

        this._firstPT = null;
        parseTween(target);
        if (SafeGetVar <bool>(vars, "__from__"))
        {
            var pt = this._firstPT;
            while (pt != null)
            {
                pt.start  = Addition(pt.start, pt.change);
                pt.change = Negation(pt.change);
                pt        = pt._next;
            }
        }
        _initted = true;
    }
Example #7
0
 protected NTweenPlugin()
 {
     this._firstPT = null;
 }