public static SkillAssetData MakeSkillAssetData(JSequencer sequenceer)
        {
            SkillAssetData    skillart       = new SkillAssetData();
            Transform         AffectedObject = sequenceer.TimelineContainers[0].AffectedObject;
            string            ModelName      = AffectedObject.name;
            List <GameObject> plist          = AssetUtility.GetAllFBXWithType(ModelTargetType.Player);
            List <GameObject> nlist          = AssetUtility.GetAllFBXWithType(ModelTargetType.NPC);

            skillart.skillArt.modelType = ModelTargetType.Player;
            bool findtype = false;

            for (int i = 0; i < plist.Count && !findtype; i++)
            {
                if (plist[i].name == ModelName)
                {
                    skillart.skillArt.modelType = ModelTargetType.Player;
                    findtype = true;
                }
            }
            for (int i = 0; i < nlist.Count && !findtype; i++)
            {
                if (nlist[i].name == ModelName)
                {
                    skillart.skillArt.modelType = ModelTargetType.NPC;
                    findtype = true;
                }
            }
            skillart.skillArt.modelName = ModelName;
            skillart.skillArt.model     = AssetUtility.GetFBXWithName(ModelName);
            Animator Animator = AffectedObject.GetComponent <Animator>();

            skillart.skillArt.animationController = Animator.runtimeAnimatorController.name;
            skillart.skillArt.id = EditorDataContainer.GetSkillIdByString(AffectedObject.parent.name.Split('_')[1]);
            if (sequenceer.TimelineContainers.Length > 0)
            {
                JTimelineBase[] lines = sequenceer.TimelineContainers[0].Timelines;
                for (int i = 0; i < lines.Length; i++)
                {
                    JTimelineBase line = lines[i];
                    //动作时间线 guideaction

                    /* if (line.LineType() == TimeLineType.Animation)
                     * {
                     *   JTimelineAnimation aniline = (JTimelineAnimation)line;
                     *   foreach (var track in aniline.AnimationTracks)
                     *   {
                     *       if (track.name == SkillNames.ActionNames[(int)SkillNames.GuideAction.GuideAction])
                     *       {
                     *           if (track.TrackClips.Count > 0)
                     *           {
                     *               skillart.skillArt.guideAction = track.TrackClips[0].StateName;
                     *           }
                     *       }
                     *       else if (track.name == SkillNames.ActionNames[(int)SkillNames.GuideAction.GuidingAction])
                     *       {
                     *           if (track.TrackClips.Count > 0)
                     *           {
                     *               skillart.skillArt.guidingAction = track.TrackClips[0].StateName;
                     *           }
                     *       }
                     *       else if (track.name == SkillNames.ActionNames[(int)SkillNames.GuideAction.EndAction])
                     *       {
                     *           if (track.TrackClips.Count > 0)
                     *           {
                     *               skillart.skillArt.endAction = track.TrackClips[0].StateName;
                     *           }
                     *       }
                     *   }
                     * }*/
                    //特效时间线 begineffect
                    if (line.LineType() == TimeLineType.Effect)
                    {
                        JTimelineEffect aniline = (JTimelineEffect)line;
                        foreach (var track in aniline.EffectTracks)
                        {
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.GuideAction])
                            {
                                if (track.TrackClips.Count > 0)
                                {
                                    skillart.skillArt.guideAction = track.TrackClips[0].StateName;
                                }
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.GuidingAction])
                            {
                                if (track.TrackClips.Count > 0)
                                {
                                    skillart.skillArt.guidingAction = track.TrackClips[0].StateName;
                                }
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.EndAction])
                            {
                                if (track.TrackClips.Count > 0)
                                {
                                    skillart.skillArt.endAction = track.TrackClips[0].StateName;
                                }
                            }

                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect0] || track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect1])
                            {
                                if (skillart.skillArt.beginEffect == null)
                                {
                                    skillart.skillArt.beginEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.beginEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }


                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.EndEffect])
                            {
                                if (skillart.skillArt.endEffect == null)
                                {
                                    skillart.skillArt.endEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.endEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.UnitEffect])
                            {
                                if (skillart.skillArt.unitEffect == null)
                                {
                                    skillart.skillArt.unitEffect = new List <SkillEffectUnit>();
                                }
                                if (skillart.skillUnit == null)
                                {
                                    skillart.skillUnit = new JSkillUnit();
                                }
                                skillart.skillArt.unitEffect.Add(track.TrackClips[0].effectunit.Copy());
                                skillart.skillUnit = track.TrackClips[0].skillunit.Copy();
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.HitEffect])
                            {
                                if (skillart.skillArt.hitEffect == null)
                                {
                                    skillart.skillArt.hitEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.hitEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.TipEffect])
                            {
                                if (skillart.skillArt.tipEffect == null)
                                {
                                    skillart.skillArt.tipEffect = new List <SkillEffectUnit>();
                                }
                                skillart.skillArt.tipEffect.Add(track.TrackClips[0].effectunit.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginCameraAction])
                            {
                                if (skillart.skillArt.beginCameraAction == null)
                                {
                                    skillart.skillArt.beginCameraAction = new List <SkillCameraAction>();
                                }
                                skillart.skillArt.beginCameraAction.Add(track.TrackClips[0].cameraAction.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.MoveCameraAction])
                            {
                                if (skillart.skillArt.moveCameraAction == null)
                                {
                                    skillart.skillArt.moveCameraAction = new List <SkillCameraAction>();
                                }
                                skillart.skillArt.moveCameraAction.Add(track.TrackClips[0].cameraAction.Copy());
                            }
                            if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.HitCameraAction])
                            {
                                if (skillart.skillArt.hitCameraAction == null)
                                {
                                    skillart.skillArt.hitCameraAction = new List <SkillCameraAction>();
                                }
                                skillart.skillArt.hitCameraAction.Add(track.TrackClips[0].cameraAction.Copy());
                            }
                        }
                    }
                    if (skillart.skillArt.beginEffect != null)
                    {
                        skillart.skillArt.beginEffect.Sort(delegate(SkillEffectUnit x, SkillEffectUnit y)
                        {
                            return(x.artEffect.beginTime.CompareTo(y.artEffect.beginTime));
                        });
                    }


                    /*
                     *  if (line.LineType() == TimeLineType.Particle)
                     *  {
                     *      JTimelineParticle aniline = (JTimelineParticle)line;
                     *      foreach (var track in aniline.ParticleTracks)
                     *      {
                     *          if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect0]|| track.name == SkillNames.EffectNames[(int)SkillNames.Effect.BeginEffect1]|| track.name == SkillNames.EffectNames[(int)SkillNames.Effect.EndEffect])
                     *          {
                     *              if (track.TrackClips.Count > 0)
                     *              {
                     *                  SkillEffectUnit unit = new SkillEffectUnit();
                     *                  unit.configure = track.TrackClips[0].EffectConfig.Copy();
                     *                  unit.artEffect.beginTime = (int)(track.TrackClips[0].StartTime*1000f);
                     *                  unit.artEffect.phaseTime = (int)(track.TrackClips[0].PlaybackDuration * 1000f);
                     *                  unit.artEffect.effectObj = track.TrackClips[0].Effect;
                     *                  unit.artEffect.effect = EditorDataContainer.GetIdByString(track.TrackClips[0].ParticleName);
                     *                  begineffect.Insert(0, unit);
                     *              }
                     *          }
                     *
                     *      }
                     *  }
                     *  //弹道时间线
                     *  if (skillart.skillArt.unitEffect == null)
                     *      skillart.skillArt.unitEffect = new List<SkillEffectUnit>();
                     *  List<SkillEffectUnit> unitEffect = skillart.skillArt.unitEffect;
                     *  unitEffect.Clear();
                     *  if (line.LineType() == TimeLineType.Trajectory)
                     *  {
                     *      JTimelineTrajectory aniline = (JTimelineTrajectory)line;
                     *
                     *      foreach (var track in aniline.TrajectoryTracks)
                     *      {
                     *          if (track.name == SkillNames.EffectNames[(int)SkillNames.Effect.UnitEffect])
                     *          {
                     *              if (track.TrackClips.Count > 0)
                     *              {
                     *                  skillart.skillUnit = track.TrackClips[0].skillunit.Copy();
                     *                  unitEffect.Add(track.TrackClips[0].effectunit.Copy());
                     *              }
                     *          }
                     *      }
                     *  }
                     */
                }
            }
            Debug.Log(skillart.skillArt.beginEffect.Count);

            return(skillart);
        }
Example #2
0
        public void OnTransformSceneGUI(JTimelineBase timeline)
        {
            if (timeline == null)
            {
                return;
            }
            if (timeline.LineType() == TimeLineType.Transform)
            {
                JTimelineTransform ObjectPathTimeline = (JTimelineTransform)timeline;
                if (ObjectPathTimeline.Tracks == null)
                {
                    return;
                }

                for (int i = 0; i < ObjectPathTimeline.Tracks.Count; i++)
                {
                    JTransformTrack tTrack = ObjectPathTimeline.Tracks[i];
                    if (SelectedNodeIndex >= 0)
                    {
                        if (UnityEngine.Event.current.isKey && (UnityEngine.Event.current.keyCode == KeyCode.Delete || UnityEngine.Event.current.keyCode == KeyCode.Backspace))
                        {
                            UnityEngine.Event.current.Use();
                            RemoveKeyFrameWithKeyframe(SelectedNodeIndex);
                            SelectedNodeIndex = -1;
                        }
                    }

                    if (UnityEngine.Event.current.type == EventType.mouseDown)
                    {
                        var nearestIndex = GetNearestNodeForMousePosition(tTrack, UnityEngine.Event.current.mousePosition);

                        if (nearestIndex != -1)
                        {
                            SelectedNodeIndex = nearestIndex;
                            if (UnityEngine.Event.current.clickCount == 1 && UnityEngine.Event.current.button == 0)
                            {
                                ResetSelection();
                                Selection.activeObject = tTrack.Keyframes[SelectedNodeIndex];
                                OnSelectedObjects(new List <Object> {
                                    tTrack.Keyframes[SelectedNodeIndex]
                                });
                            }
                            if (UnityEngine.Event.current.clickCount > 1)
                            {
                                var cameraTransform = UnityEditor.SceneView.currentDrawingSceneView.camera.transform;
                                var keyframe        = tTrack.Keyframes[SelectedNodeIndex];
                                int next            = SelectedNodeIndex == (tTrack.Keyframes.Count - 1) ? (SelectedNodeIndex - 1) : (SelectedNodeIndex + 1);

                                var   nextKeyframe = tTrack.Keyframes[next];
                                float newtime      = (keyframe.StartTime + nextKeyframe.StartTime) * 0.5f;

                                AddNewKeyFrame(tTrack, newtime, SelectedNodeIndex);

                                GUI.changed = true;
                            }
                        }
                    }

                    if (tTrack.Keyframes.Count >= 2)
                    {
                        if (Vector3.Distance(tTrack.Keyframes[0].Position, tTrack.Keyframes[tTrack.Keyframes.Count - 1].Position) == 0)
                        {
                            Handles.Label(tTrack.Keyframes[0].Position, "Start and End");
                        }
                        else
                        {
                            Handles.Label(tTrack.Keyframes[0].Position, "Start");
                            Handles.Label(tTrack.Keyframes[tTrack.Keyframes.Count - 1].Position, "End");
                        }
                    }
                    for (int nodeIndex = 0; nodeIndex < tTrack.Keyframes.Count; nodeIndex++)
                    {
                        var node = tTrack.Keyframes[nodeIndex];

                        if (node && nodeIndex > 0 && nodeIndex < tTrack.Keyframes.Count - 1)
                        {
                            float handleSize = HandlesUtility.GetHandleSize(node.Position);
                            Handles.Label(node.Position + new Vector3(0.25f * handleSize, 0.0f * handleSize, 0.0f * handleSize), nodeIndex.ToString());
                        }
                        var        existingKeyframe = tTrack.Keyframes[nodeIndex];
                        Quaternion oldrotation      = Quaternion.Euler(existingKeyframe.Rotation);
                        Vector3    oldpos           = existingKeyframe.Position;
                        Vector3    oldtang          = existingKeyframe.Tangent;
                        Vector3    oldnormal        = existingKeyframe.Normal;
                        Vector3    newPosition      = HandlesUtility.PositionHandle(existingKeyframe.Position, oldrotation);
                        Vector3    newtangent       = HandlesUtility.TangentHandle(existingKeyframe.Position + existingKeyframe.Tangent) - existingKeyframe.Position;
                        if (oldpos != newPosition || oldtang != newtangent)
                        {
                            tTrack.AlterKeyframe(newPosition, oldrotation.eulerAngles, newtangent, oldnormal, nodeIndex);
                            EditorUtility.SetDirty(tTrack);
                        }
                    }
                }
            }
        }
 public static int Comparer(JTimelineBase a, JTimelineBase b)
 {
     return(a.LineType().CompareTo(b.LineType()));
 }