Example #1
0
 void AnimationEventHandler(string _type, DragonBones.EventObject eventObject)
 {
     if (_type == DragonBones.EventObject.COMPLETE)
     {
         PlayAnim("idle");
     }
 }
 public void Call(string param0, DragonBones.EventObject param1)
 {
     func.BeginPCall();
     func.Push(param0);
     func.PushObject(param1);
     func.PCall();
     func.EndPCall();
 }
Example #3
0
 private void OnMotionComplete(string type, DragonBones.EventObject eventObject)
 {
     if (_afterMotion != null)
     {
         PlayMotion(_afterMotion);
         _afterMotion = null;
     }
     dispatch(new RoleEvent(RoleEvent.MOTION_COMPLETE, this));
 }
 static int DispatchDBEvent(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         DragonBones.DragonBoneEventDispatcher obj = (DragonBones.DragonBoneEventDispatcher)ToLua.CheckObject <DragonBones.DragonBoneEventDispatcher>(L, 1);
         string arg0 = ToLua.CheckString(L, 2);
         DragonBones.EventObject arg1 = (DragonBones.EventObject)ToLua.CheckObject <DragonBones.EventObject>(L, 3);
         obj.DispatchDBEvent(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int DispatchEvent(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         DragonBones.UnityEventDispatcher <DragonBones.EventObject> obj = (DragonBones.UnityEventDispatcher <DragonBones.EventObject>)ToLua.CheckObject(L, 1, typeof(DragonBones.UnityEventDispatcher <DragonBones.EventObject>));
         string arg0 = ToLua.CheckString(L, 2);
         DragonBones.EventObject arg1 = (DragonBones.EventObject)ToLua.CheckObject(L, 3, typeof(DragonBones.EventObject));
         obj.DispatchEvent(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int set_animationState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject    obj  = (DragonBones.EventObject)o;
            DragonBones.AnimationState arg0 = (DragonBones.AnimationState)ToLua.CheckObject <DragonBones.AnimationState>(L, 2);
            obj.animationState = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index animationState on a nil value"));
        }
    }
    static int set_slot(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj  = (DragonBones.EventObject)o;
            DragonBones.Slot        arg0 = (DragonBones.Slot)ToLua.CheckObject <DragonBones.Slot>(L, 2);
            obj.slot = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index slot on a nil value"));
        }
    }
    static int set_data(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj  = (DragonBones.EventObject)o;
            DragonBones.CustomData  arg0 = (DragonBones.CustomData)ToLua.CheckObject <DragonBones.CustomData>(L, 2);
            obj.data = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index data on a nil value"));
        }
    }
    static int set_name(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj = (DragonBones.EventObject)o;
            string arg0 = ToLua.CheckString(L, 2);
            obj.name = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index name on a nil value"));
        }
    }
Example #10
0
    static int get_frame(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject        obj = (DragonBones.EventObject)o;
            DragonBones.AnimationFrameData ret = obj.frame;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index frame on a nil value" : e.Message));
        }
    }
    static int get_animationState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject    obj = (DragonBones.EventObject)o;
            DragonBones.AnimationState ret = obj.animationState;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index animationState on a nil value"));
        }
    }
    static int get_data(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj = (DragonBones.EventObject)o;
            DragonBones.CustomData  ret = obj.data;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index data on a nil value"));
        }
    }
    static int get_name(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj = (DragonBones.EventObject)o;
            string ret = obj.name;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index name on a nil value"));
        }
    }
Example #14
0
    static int set_bone(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj  = (DragonBones.EventObject)o;
            DragonBones.Bone        arg0 = (DragonBones.Bone)ToLua.CheckObject(L, 2, typeof(DragonBones.Bone));
            obj.bone = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index bone on a nil value" : e.Message));
        }
    }
Example #15
0
    static int get_slot(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj = (DragonBones.EventObject)o;
            DragonBones.Slot        ret = obj.slot;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index slot on a nil value" : e.Message));
        }
    }
    static int _CreateDragonBones_EventObject(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                DragonBones.EventObject obj = new DragonBones.EventObject();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: DragonBones.EventObject.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #17
0
        /// <private/>
        protected object _GetSlotDisplay(BuildArmaturePackage dataPackage, DisplayData displayData, DisplayData rawDisplayData, Slot slot)
        {
            var    dataName = dataPackage != null ? dataPackage.dataName : displayData.parent.parent.parent.name;
            object display  = null;

            switch (displayData.type)
            {
            case DisplayType.Image:
            {
                var imageDisplayData = displayData as ImageDisplayData;
                if (imageDisplayData.texture == null)
                {
                    imageDisplayData.texture = this._GetTextureData(dataName, displayData.path);
                }
                else if (dataPackage != null && !string.IsNullOrEmpty(dataPackage.textureAtlasName))
                {
                    imageDisplayData.texture = this._GetTextureData(dataPackage.textureAtlasName, displayData.path);
                }

                if (rawDisplayData != null && rawDisplayData.type == DisplayType.Mesh && this._IsSupportMesh())
                {
                    display = slot.meshDisplay;
                }
                else
                {
                    display = slot.rawDisplay;
                }
            }
            break;

            case DisplayType.Mesh:
            {
                var meshDisplayData = displayData as MeshDisplayData;
                if (meshDisplayData.texture == null)
                {
                    meshDisplayData.texture = this._GetTextureData(dataName, meshDisplayData.path);
                }
                else if (dataPackage != null && !string.IsNullOrEmpty(dataPackage.textureAtlasName))
                {
                    meshDisplayData.texture = this._GetTextureData(dataPackage.textureAtlasName, meshDisplayData.path);
                }

                if (this._IsSupportMesh())
                {
                    display = slot.meshDisplay;
                }
                else
                {
                    display = slot.rawDisplay;
                }
            }
            break;

            case DisplayType.Armature:
            {
                var armatureDisplayData = displayData as ArmatureDisplayData;
                var childArmature       = this._BuildChildArmature(dataPackage, slot, displayData);
                if (childArmature != null)
                {
                    childArmature.inheritAnimation = armatureDisplayData.inheritAnimation;
                    if (!childArmature.inheritAnimation)
                    {
                        var actions = armatureDisplayData.actions.Count > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions;
                        if (actions.Count > 0)
                        {
                            foreach (var action in actions)
                            {
                                var eventObject = BaseObject.BorrowObject <EventObject>();
                                EventObject.ActionDataToInstance(action, eventObject, slot.armature);
                                eventObject.slot = slot;
                                slot.armature._BufferAction(eventObject, false);
                            }
                        }
                        else
                        {
                            childArmature.animation.Play();
                        }
                    }

                    armatureDisplayData.armature = childArmature.armatureData;         //
                }

                display = childArmature;
            }
            break;

            case DisplayType.BoundingBox:
                break;
            }

            return(display);
        }
        public override void Update(float passedTime)
        {
            var prevState     = this.playState;
            var prevPlayTimes = this.currentPlayTimes;
            var prevTime      = this.currentTime;

            if (this._SetCurrentTime(passedTime))
            {
                var eventDispatcher = this._armature.proxy;
                if (prevState < 0)
                {
                    if (this.playState != prevState)
                    {
                        if (this._animationState.displayControl && this._animationState.resetToPose)
                        {
                            // Reset zorder to pose.
                            this._armature._SortZOrder(null, 0);
                        }

                        prevPlayTimes = this.currentPlayTimes;

                        if (eventDispatcher.HasDBEventListener(EventObject.START))
                        {
                            var eventObject = BaseObject.BorrowObject <EventObject>();
                            eventObject.type           = EventObject.START;
                            eventObject.armature       = this._armature;
                            eventObject.animationState = this._animationState;
                            this._armature._dragonBones.BufferEvent(eventObject);
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                var         isReverse         = this._animationState.timeScale < 0.0f;
                EventObject loopCompleteEvent = null;
                EventObject completeEvent     = null;

                if (this.currentPlayTimes != prevPlayTimes)
                {
                    if (eventDispatcher.HasDBEventListener(EventObject.LOOP_COMPLETE))
                    {
                        loopCompleteEvent                = BaseObject.BorrowObject <EventObject>();
                        loopCompleteEvent.type           = EventObject.LOOP_COMPLETE;
                        loopCompleteEvent.armature       = this._armature;
                        loopCompleteEvent.animationState = this._animationState;
                    }

                    if (this.playState > 0)
                    {
                        if (eventDispatcher.HasDBEventListener(EventObject.COMPLETE))
                        {
                            completeEvent                = BaseObject.BorrowObject <EventObject>();
                            completeEvent.type           = EventObject.COMPLETE;
                            completeEvent.armature       = this._armature;
                            completeEvent.animationState = this._animationState;
                        }
                    }
                }

                if (this._frameCount > 1)
                {
                    var timelineData       = this._timelineData as TimelineData;
                    var timelineFrameIndex = (uint)Math.Floor(this.currentTime * this._frameRate); // uint
                    var frameIndex         = (int)this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex];
                    if (this._frameIndex != frameIndex)
                    {
                        // Arrive at frame.
                        var crossedFrameIndex = this._frameIndex;
                        this._frameIndex = frameIndex;
                        if (this._timelineArray != null)
                        {
                            this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + (int)BinaryOffset.TimelineFrameOffset + this._frameIndex];
                            if (isReverse)
                            {
                                if (crossedFrameIndex < 0)
                                {
                                    var prevFrameIndex = (int)Math.Floor(prevTime * this._frameRate);
                                    crossedFrameIndex = (int)this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex];
                                    if (this.currentPlayTimes == prevPlayTimes)
                                    {
                                        // Start.
                                        if (crossedFrameIndex == frameIndex)
                                        { // Uncrossed.
                                            crossedFrameIndex = -1;
                                        }
                                    }
                                }

                                while (crossedFrameIndex >= 0)
                                {
                                    var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + (int)BinaryOffset.TimelineFrameOffset + crossedFrameIndex];
                                    // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem
                                    var framePosition = (float)this._frameArray[frameOffset] / (float)this._frameRate;

                                    if (this._position <= framePosition && framePosition <= this._position + this._duration)
                                    {
                                        // Support interval play.
                                        this._OnCrossFrame(crossedFrameIndex);
                                    }

                                    if (loopCompleteEvent != null && crossedFrameIndex == 0)
                                    {
                                        // Add loop complete event after first frame.
                                        this._armature._dragonBones.BufferEvent(loopCompleteEvent);
                                        loopCompleteEvent = null;
                                    }

                                    if (crossedFrameIndex > 0)
                                    {
                                        crossedFrameIndex--;
                                    }
                                    else
                                    {
                                        crossedFrameIndex = (int)this._frameCount - 1;
                                    }

                                    if (crossedFrameIndex == frameIndex)
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                if (crossedFrameIndex < 0)
                                {
                                    var prevFrameIndex = (int)Math.Floor(prevTime * this._frameRate);
                                    crossedFrameIndex = (int)this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex];
                                    var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + (int)BinaryOffset.TimelineFrameOffset + crossedFrameIndex];
                                    // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem
                                    var framePosition = (float)this._frameArray[frameOffset] / (float)this._frameRate;
                                    if (this.currentPlayTimes == prevPlayTimes)
                                    {
                                        // Start.
                                        if (prevTime <= framePosition)
                                        {
                                            // Crossed.
                                            if (crossedFrameIndex > 0)
                                            {
                                                crossedFrameIndex--;
                                            }
                                            else
                                            {
                                                crossedFrameIndex = (int)this._frameCount - 1;
                                            }
                                        }
                                        else if (crossedFrameIndex == frameIndex)
                                        {
                                            // Uncrossed.
                                            crossedFrameIndex = -1;
                                        }
                                    }
                                }

                                while (crossedFrameIndex >= 0)
                                {
                                    if (crossedFrameIndex < this._frameCount - 1)
                                    {
                                        crossedFrameIndex++;
                                    }
                                    else
                                    {
                                        crossedFrameIndex = 0;
                                    }

                                    var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + (int)BinaryOffset.TimelineFrameOffset + crossedFrameIndex];
                                    // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem
                                    var framePosition = (float)this._frameArray[frameOffset] / (float)this._frameRate;
                                    if (this._position <= framePosition && framePosition <= this._position + this._duration)
                                    {
                                        // Support interval play.
                                        this._OnCrossFrame(crossedFrameIndex);
                                    }

                                    if (loopCompleteEvent != null && crossedFrameIndex == 0)
                                    {
                                        // Add loop complete event before first frame.
                                        this._armature._dragonBones.BufferEvent(loopCompleteEvent);
                                        loopCompleteEvent = null;
                                    }

                                    if (crossedFrameIndex == frameIndex)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                else if (this._frameIndex < 0)
                {
                    this._frameIndex = 0;
                    if (this._timelineData != null)
                    {
                        this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + (int)BinaryOffset.TimelineFrameOffset];
                        // Arrive at frame.
                        var framePosition = (float)this._frameArray[this._frameOffset] / (float)this._frameRate;
                        if (this.currentPlayTimes == prevPlayTimes)
                        {
                            // Start.
                            if (prevTime <= framePosition)
                            {
                                this._OnCrossFrame(this._frameIndex);
                            }
                        }
                        else if (this._position <= framePosition)
                        {
                            // Loop complete.
                            if (!isReverse && loopCompleteEvent != null)
                            {
                                // Add loop complete event before first frame.
                                this._armature._dragonBones.BufferEvent(loopCompleteEvent);
                                loopCompleteEvent = null;
                            }

                            this._OnCrossFrame(this._frameIndex);
                        }
                    }
                }

                if (loopCompleteEvent != null)
                {
                    this._armature._dragonBones.BufferEvent(loopCompleteEvent);
                }

                if (completeEvent != null)
                {
                    this._armature._dragonBones.BufferEvent(completeEvent);
                }
            }
        }
Example #19
0
        /// <private/>
        protected void _UpdateDisplay()
        {
            var prevDisplay       = this._display != null ? this._display : this._rawDisplay;
            var prevChildArmature = this._childArmature;

            // Update display and child armature.
            if (this._displayIndex >= 0 && this._displayIndex < this._displayList.Count)
            {
                this._display = this._displayList[this._displayIndex];
                if (this._display != null && this._display is Armature)
                {
                    this._childArmature = this._display as Armature;
                    this._display       = this._childArmature.display;
                }
                else
                {
                    this._childArmature = null;
                }
            }
            else
            {
                this._display       = null;
                this._childArmature = null;
            }

            // Update display.
            var currentDisplay = this._display != null ? this._display : this._rawDisplay;

            if (currentDisplay != prevDisplay)
            {
                this._OnUpdateDisplay();
                this._ReplaceDisplay(prevDisplay);

                this._transformDirty = true;
                this._visibleDirty   = true;
                this._blendModeDirty = true;
                this._colorDirty     = true;
            }

            // Update frame.
            if (currentDisplay == this._rawDisplay || currentDisplay == this._meshDisplay)
            {
                this._UpdateFrame();
            }

            // Update child armature.
            if (this._childArmature != prevChildArmature)
            {
                if (prevChildArmature != null)
                {
                    // Update child armature parent.
                    prevChildArmature._parent = null;
                    prevChildArmature.clock   = null;
                    if (prevChildArmature.inheritAnimation)
                    {
                        prevChildArmature.animation.Reset();
                    }
                }

                if (this._childArmature != null)
                {
                    // Update child armature parent.
                    this._childArmature._parent = this;
                    this._childArmature.clock   = this._armature.clock;
                    if (this._childArmature.inheritAnimation)
                    {
                        // Set child armature cache frameRate.
                        if (this._childArmature.cacheFrameRate == 0)
                        {
                            var cacheFrameRate = this._armature.cacheFrameRate;
                            if (cacheFrameRate != 0)
                            {
                                this._childArmature.cacheFrameRate = cacheFrameRate;
                            }
                        }

                        // Child armature action.
                        List <ActionData> actions = null;
                        if (this._displayData != null && this._displayData.type == DisplayType.Armature)
                        {
                            actions = (this._displayData as ArmatureDisplayData).actions;
                        }
                        else if (this._displayIndex >= 0 && this._rawDisplayDatas != null)
                        {
                            var rawDisplayData = this._displayIndex < this._rawDisplayDatas.Count ? this._rawDisplayDatas[this._displayIndex] : null;

                            if (rawDisplayData == null)
                            {
                                rawDisplayData = this._GetDefaultRawDisplayData(this._displayIndex);
                            }

                            if (rawDisplayData != null && rawDisplayData.type == DisplayType.Armature)
                            {
                                actions = (rawDisplayData as ArmatureDisplayData).actions;
                            }
                        }

                        if (actions != null && actions.Count > 0)
                        {
                            foreach (var action in actions)
                            {
                                var eventObject = BaseObject.BorrowObject <EventObject>();
                                EventObject.ActionDataToInstance(action, eventObject, this._armature);
                                eventObject.slot = this;
                                this._armature._BufferAction(eventObject, false);
                            }
                        }
                        else
                        {
                            this._childArmature.animation.Play();
                        }
                    }
                }
            }
        }
Example #20
0
 /**
  * @private
  */
 internal void _bufferEvent(EventObject value, string type)
 {
     value.type     = type;
     value.armature = this;
     _events.Add(value);
 }