/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace DragonBones
{
///
/// - The properties of the object carry basic information about an event,
/// which are passed as parameter or parameter's parameter to event listeners when an event occurs.
///
/// DragonBones 4.5
/// en_US
///
/// - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。
///
/// DragonBones 4.5
/// zh_CN
public class EventObject : BaseObject
{
///
/// - Animation start play.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画开始播放。
///
/// DragonBones 4.5
/// zh_CN
public const string START = "start";
///
/// - Animation loop play complete once.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画循环播放完成一次。
///
/// DragonBones 4.5
/// zh_CN
public const string LOOP_COMPLETE = "loopComplete";
///
/// - Animation play complete.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画播放完成。
///
/// DragonBones 4.5
/// zh_CN
public const string COMPLETE = "complete";
///
/// - Animation fade in start.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画淡入开始。
///
/// DragonBones 4.5
/// zh_CN
public const string FADE_IN = "fadeIn";
///
/// - Animation fade in complete.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画淡入完成。
///
/// DragonBones 4.5
/// zh_CN
public const string FADE_IN_COMPLETE = "fadeInComplete";
///
/// - Animation fade out start.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画淡出开始。
///
/// DragonBones 4.5
/// zh_CN
public const string FADE_OUT = "fadeOut";
///
/// - Animation fade out complete.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画淡出完成。
///
/// DragonBones 4.5
/// zh_CN
public const string FADE_OUT_COMPLETE = "fadeOutComplete";
///
/// - Animation frame event.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画帧事件。
///
/// DragonBones 4.5
/// zh_CN
public const string FRAME_EVENT = "frameEvent";
///
/// - Animation frame sound event.
///
/// DragonBones 4.5
/// en_US
///
/// - 动画帧声音事件。
///
/// DragonBones 4.5
/// zh_CN
public const string SOUND_EVENT = "soundEvent";
///
///
///
/// - The armature that dispatch the event.
///
///
/// DragonBones 4.5
/// en_US
///
/// - 发出该事件的骨架。
///
///
/// DragonBones 4.5
/// zh_CN
///
/// - The custom data.
///
///
///
/// DragonBones 5.0
/// en_US
///
/// - 自定义数据。
///
///
///
/// DragonBones 5.0
/// zh_CN
public static void ActionDataToInstance(ActionData data, EventObject instance, Armature armature)
{
if (data.type == ActionType.Play)
{
instance.type = EventObject.FRAME_EVENT;
}
else
{
instance.type = data.type == ActionType.Frame ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT;
}
instance.name = data.name;
instance.armature = armature;
instance.actionData = data;
instance.data = data.data;
if (data.bone != null)
{
instance.bone = armature.GetBone(data.bone.name);
}
if (data.slot != null)
{
instance.slot = armature.GetSlot(data.slot.name);
}
}
///
/// - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds)
///
/// DragonBones 4.5
/// en_US
///
/// - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位)
///
/// DragonBones 4.5
/// zh_CN
public float time;
///
/// - The event type。
///
/// DragonBones 4.5
/// en_US
///
/// - 事件类型。
///
/// DragonBones 4.5
/// zh_CN
public string type;
///
/// - The event name. (The frame event name or the frame sound name)
///
/// DragonBones 4.5
/// en_US
///
/// - 事件名称。 (帧事件的名称或帧声音的名称)
///
/// DragonBones 4.5
/// zh_CN
public string name;
public Armature armature;
///
/// - The bone that dispatch the event.
///
///
/// DragonBones 4.5
/// en_US
///
/// - 发出该事件的骨骼。
///
///
/// DragonBones 4.5
/// zh_CN
public Bone bone;
///
/// - The slot that dispatch the event.
///
///
/// DragonBones 4.5
/// en_US
///
/// - 发出该事件的插槽。
///
///
/// DragonBones 4.5
/// zh_CN
public Slot slot;
///
/// - The animation state that dispatch the event.
///
///
/// DragonBones 4.5
/// en_US
///
/// - 发出该事件的动画状态。
///
///
/// DragonBones 4.5
/// zh_CN
public AnimationState animationState;
///
public ActionData actionData;
public UserData data;
///
protected override void _OnClear()
{
this.time = 0.0f;
this.type = string.Empty;
this.name = string.Empty;
this.armature = null;
this.bone = null;
this.slot = null;
this.animationState = null;
this.actionData = null;
this.data = null;
}
}
}