Esempio n. 1
0
    // -- Static functions --
    public static DC DelayedCall(float delay, Action callback, bool useFrames = false)
    {
        DC dc = new DC(delay, useFrames);

        dc.onComplete = callback;
        TSScheduler.Register(dc);
        return(dc);
    }
Esempio n. 2
0
    public static DC DelayedCall(float delay, Action <object> callback, object pars, bool useFrames = false)
    {
        DC dc = new DC(delay, useFrames);

        dc.onCompleteArg    = callback;
        dc.onCompleteParams = pars;
        TSScheduler.Register(dc);
        return(dc);
    }
Esempio n. 3
0
    // -- Internal functions --
    private void Init(Dictionary <string, object> args)
    {
        InitVariables();

        foreach (KeyValuePair <string, object> kvp in args)
        {
            string key   = kvp.Key;
            object value = kvp.Value;

            if (!TSKeywordParser.Parse(this, kvp))
            {
                ParseKeyValue(key, value);
            }
        }

        PropertyInfo[] pis = target.GetType().GetProperties();
        foreach (PropertyInfo pi in pis)
        {
            int ind = propertyNames.IndexOf(pi.Name);
            if (ind != -1 && propertyPlugins[ind] == null)
            {
                object val = pi.GetValue(target, null);
                if (val is float)
                {
                    propertyStartValues[ind] = (float)val;
                }
                propertyInfos[ind] = pi;
            }
        }

        int len = propertyNames.Count;

        for (int i = 0; i < len; i++)
        {
            if (propertyInfos[i] == null && propertyPlugins[i] == null)
            {
                throw new Exception("Tweensharp(): Property " + propertyNames[i] + " not found on object " + target + ".");
            }
        }

        TSScheduler.Register(this);
    }
Esempio n. 4
0
 public void Restart()
 {
     startTime = Time.realtimeSinceStartup;
     TSScheduler.Register(this, true);
 }
Esempio n. 5
0
    public TweenSharp(object target, float duration, Dictionary <string, object> args)
    {
        float f = 0;

        this.target   = target;
        this.duration = duration;

        startTime = Time.realtimeSinceStartup;

        propertyNames        = new List <string>();
        propertyStartValues  = new List <float>();
        propertyTargetValues = new List <float>();
        propertyPlugins      = new List <TSPlugin>();
        propertyInfos        = new List <PropertyInfo>();

        foreach (KeyValuePair <string, object> kvp in args)
        {
            string key = kvp.Key;

            if (!TSKeywordParser.Parse(this, kvp))
            {
                propertyNames.Add(key);
                propertyInfos.Add(null);

                TSPlugin plugin = PluginManager.GetPlugin(key);
                if (plugin != null)
                {
                    plugin.Target = target;
                }
                propertyPlugins.Add(plugin);

                if (kvp.Value is float)
                {
                    if (plugin != null)
                    {
                        propertyStartValues.Add(plugin.Value);
                    }
                    else
                    {
                        propertyStartValues.Add(0f);
                    }
                    propertyTargetValues.Add((float)kvp.Value);
                }
                else
                {
                    propertyStartValues.Add(0f);
                    propertyTargetValues.Add(0f);
                    throw new Exception("Tweensharp: Value is not of type float.");
                }
            }
        }

        PropertyInfo[] pis = target.GetType().GetProperties();
        foreach (PropertyInfo pi in pis)
        {
            int ind = propertyNames.IndexOf(pi.Name);
            if (ind != -1 && propertyPlugins[ind] == null)
            {
                object val = pi.GetValue(target, null);
                if (val is float)
                {
                    propertyStartValues[ind] = (float)val;
                }
                propertyInfos[ind] = pi;
            }
        }

        int len = propertyNames.Count;

        for (int i = 0; i < len; i++)
        {
            if (propertyInfos[i] == null && propertyPlugins[i] == null)
            {
                throw new Exception("Tweensharp(): Property " + propertyNames[i] + " not found on object " + target + ".");
            }
        }


        TSScheduler.Register(this);
    }