Example #1
0
    // ------------------------------------------------------------------
    /// Calls the method named methodName on every Component target game object.
    // ------------------------------------------------------------------

    public void Trigger(Component _target, exSpriteAnimationClip.EventInfo _event)
    {
        if (_event.methodName == "")
        {
            return;
        }
        switch (_event.paramType)
        {
        case exSpriteAnimationClip.EventInfo.ParamType.None:
            _target.SendMessage(_event.methodName, _event.msgOptions);
            break;

        case exSpriteAnimationClip.EventInfo.ParamType.String:
            _target.SendMessage(_event.methodName, _event.stringParam, _event.msgOptions);
            break;

        case exSpriteAnimationClip.EventInfo.ParamType.Float:
            _target.SendMessage(_event.methodName, _event.floatParam, _event.msgOptions);
            break;

        case exSpriteAnimationClip.EventInfo.ParamType.Int:
            _target.SendMessage(_event.methodName, _event.intParam, _event.msgOptions);
            break;

        case exSpriteAnimationClip.EventInfo.ParamType.Bool:
            _target.SendMessage(_event.methodName, _event.boolParam, _event.msgOptions);
            break;

        case exSpriteAnimationClip.EventInfo.ParamType.Object:
            _target.SendMessage(_event.methodName, _event.objectParam, _event.msgOptions);
            break;
        }
    }
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    void ConfirmRectSelection_EventInfo( EventInfo _activeObj, EventInfo[] _selectedObjs )
    {
        selectedEventInfos.Clear();
        selectedFrameInfos.Clear();

        // NOTE: use this way to make sure selectedEventInfos is sorted by frame.
        foreach ( EventInfo obj in _selectedObjs ) {
            selectedEventInfos.Add (obj);
        }
        selectedEventInfos.Sort ( delegate ( EventInfo _x, EventInfo _y ) {
                                    if ( _x.frame > _y.frame )
                                        return 1;
                                    else if ( _x.frame == _y.frame )
                                        return 0;
                                    else
                                        return -1;
                                  } );
        oldSelectedEventFrames.Clear();
        foreach ( EventInfo ei in selectedEventInfos ) {
            oldSelectedEventFrames.Add(ei.frame);
        }
    }
Example #3
0
    IEnumerator Start () {
        int loopCount = 1000 * 1000;
        loopCount = 10000 * 10000;
        loopCount = 10000;

        List<exSpriteAnimationClip.EventInfo> eventList = new List<exSpriteAnimationClip.EventInfo>(eventCount);
        Dictionary<int, exSpriteAnimationClip.EventInfo> eventDict = new Dictionary<int, exSpriteAnimationClip.EventInfo>(eventCount);
        for (int i = 0; i < eventCount; i++) {
            var e = new exSpriteAnimationClip.EventInfo();
            e.frame = i;
            eventList.Add(e);
            eventDict.Add(i, e);
        }

        yield return new WaitForSeconds(1);

        CpuProfiler("基准测试...", 
            () => {
                for (int i = 0; i < loopCount; ++i) {
                    for (int j = 0; j < eventCount; j++) {
                    }
                }
            }
        );

        yield return new WaitForSeconds(1);

        CpuProfiler("BinarySearch...", 
            () => {
                for (int i = 0; i < loopCount; ++i) {
                    for (int j = 0; j < eventCount; j++) {
                        exSpriteAnimationClip.EventInfo.SearchComparer.BinarySearch(eventList, j);
                    }
                }
            }
        );

        yield return new WaitForSeconds(1);

        CpuProfiler("for...", 
            () => {
                for (int i = 0; i < loopCount; ++i) {
                    for (int j = 0; j < eventCount; j++) {
                        for (int t = 0; t < eventCount; t++) {
                            if (eventList[t].frame == j) {
                                break;
                            }
                        }
                    }
                }
            }
        );

        yield return new WaitForSeconds(1);

        CpuProfiler("FindIndex...", 
            () => {
                for (int i = 0; i < loopCount; ++i) {
                    for (int j = 0; j < eventCount; j++) {
                        eventList.FindIndex((x) => x.frame == j);
                    }
                }
            }
        );

        yield return new WaitForSeconds(1);

        CpuProfiler("Dict...", 
            () => {
                for (int i = 0; i < loopCount; ++i) {
                    for (int j = 0; j < eventCount; j++) {
                        exSpriteAnimationClip.EventInfo e;
                        eventDict.TryGetValue(j, out e);
                    }
                }
            }
        );
    }
Example #4
0
    IEnumerator Start()
    {
        int loopCount = 1000 * 1000;

        loopCount = 10000 * 10000;
        loopCount = 10000;

        List <exSpriteAnimationClip.EventInfo>            eventList = new List <exSpriteAnimationClip.EventInfo>(eventCount);
        Dictionary <int, exSpriteAnimationClip.EventInfo> eventDict = new Dictionary <int, exSpriteAnimationClip.EventInfo>(eventCount);

        for (int i = 0; i < eventCount; i++)
        {
            var e = new exSpriteAnimationClip.EventInfo();
            e.frame = i;
            eventList.Add(e);
            eventDict.Add(i, e);
        }

        yield return(new WaitForSeconds(1));

        CpuProfiler("基准测试...",
                    () => {
            for (int i = 0; i < loopCount; ++i)
            {
                for (int j = 0; j < eventCount; j++)
                {
                }
            }
        }
                    );

        yield return(new WaitForSeconds(1));

        CpuProfiler("BinarySearch...",
                    () => {
            for (int i = 0; i < loopCount; ++i)
            {
                for (int j = 0; j < eventCount; j++)
                {
                    exSpriteAnimationClip.EventInfo.SearchComparer.BinarySearch(eventList, j);
                }
            }
        }
                    );

        yield return(new WaitForSeconds(1));

        CpuProfiler("for...",
                    () => {
            for (int i = 0; i < loopCount; ++i)
            {
                for (int j = 0; j < eventCount; j++)
                {
                    for (int t = 0; t < eventCount; t++)
                    {
                        if (eventList[t].frame == j)
                        {
                            break;
                        }
                    }
                }
            }
        }
                    );

        yield return(new WaitForSeconds(1));

        CpuProfiler("FindIndex...",
                    () => {
            for (int i = 0; i < loopCount; ++i)
            {
                for (int j = 0; j < eventCount; j++)
                {
                    eventList.FindIndex((x) => x.frame == j);
                }
            }
        }
                    );

        yield return(new WaitForSeconds(1));

        CpuProfiler("Dict...",
                    () => {
            for (int i = 0; i < loopCount; ++i)
            {
                for (int j = 0; j < eventCount; j++)
                {
                    exSpriteAnimationClip.EventInfo e;
                    eventDict.TryGetValue(j, out e);
                }
            }
        }
                    );
    }