Beispiel #1
0
        public void DeleteKeyframe(HitboxKeyframe keyframe)
        {
            if (!Keyframes.Contains(keyframe))
            {
                return;
            }
#if UNITY_EDITOR
            Undo.RecordObject(this, "Delete Keyframe");
#endif
            Keyframes.Remove(keyframe);
            InternalOnChange();
        }
Beispiel #2
0
        /// <summary> Adds a new HitboxKeyfram at the a specified time. </summary>
        /// <param name="time"> the time to add the keyframe at </param>
        /// <param name="defaultType"> the default type to use for every hitbox if no keyframes are currently present </param>
        /// <returns> the created keyframe </returns>
        /// <exception cref="ArgumentNullException"> </exception>
        public HitboxKeyframe AddKeyframe(float time = 0f, Hitbox.Type defaultType = Hitbox.Type.Inactive)
        {
            time = Mathf.Clamp01(time);
#if UNITY_EDITOR
            Undo.RecordObject(this, "Add Keyframe");
#endif
            HitboxKeyframe prevKeyframe = PrevKeyframe(time);
            var            keyframe     = new HitboxKeyframe {
                Time = time,
            };
            if (prevKeyframe != null)
            {
                keyframe.States = new List <Hitbox.Type>(prevKeyframe.States);
            }
            else
            {
                keyframe.States = Enumerable.Repeat(defaultType, IDs.Count).ToList();
            }
            Keyframes.Add(keyframe);
            InternalOnChange();
            return(keyframe);
        }
Beispiel #3
0
 /// <summary> Gets the previous keyframe before a certain time. Returns null if no such keyframe exists. </summary>
 /// <param name="keyframe"> they keyframe to search before </param>
 /// <returns> the first keyframe before said time. </returns>
 /// <exception cref="ArgumentNullException"> <paramref name="keyframe" /> is null </exception>
 public HitboxKeyframe PrevKeyframe(HitboxKeyframe keyframe)
 {
     return(PrevKeyframe(Argument.NotNull(keyframe).Time));
 }
Beispiel #4
0
 /// <summary> Gets the next keyframe after a certain time. Returns null if no such keyframe exists. </summary>
 /// <param name="keyframe"> they keyframe to search after </param>
 /// <returns> the first keyframe after said time. </returns>
 /// <exception cref="ArgumentNullException"> <paramref name="keyframe" /> is null </exception>
 public HitboxKeyframe NextKeyframe(HitboxKeyframe keyframe)
 {
     return(NextKeyframe(Argument.NotNull(keyframe).Time));
 }