IEnumerator <object> GetUserAnimationCoroutine(asd.DrawnObject2D object2D, UserAnimationElement userAnimation) { for (int i = 1; i <= userAnimation.frame; i++) { userAnimation.easingFunc(userAnimation.easing, i, userAnimation.frame, object2D); yield return(null); } }
IEnumerator <object> GetMoveCoroutine(asd.DrawnObject2D object2D, MoveAnimationElement move) { asd.Vector2DF start = move.isRequireFrom ? move.from : object2D.Position; for (int i = 1; i <= move.frame; i++) { object2D.Position = new asd.Vector2DF(GetEasing(move.easing, i, start.X, move.to.X, move.frame), GetEasing(move.easing, i, start.Y, move.to.Y, move.frame)); yield return(null); } }
IEnumerator <object> GetScaleCoroutine(asd.DrawnObject2D object2D, ScaleAnimationElement scale) { asd.Vector2DF start = scale.isRequireFrom ? scale.from : object2D.Scale; for (int i = 1; i <= scale.frame; i++) { object2D.Scale = new asd.Vector2DF(GetEasing(scale.easing, i, start.X, scale.to.X, scale.frame), GetEasing(scale.easing, i, start.Y, scale.to.Y, scale.frame)); yield return(null); } }
IEnumerator <object> GetRotateCoroutine(asd.DrawnObject2D object2D, RotateAnimationElement rotate) { float start = rotate.isRequireFrom ? rotate.from : object2D.Angle; for (int i = 1; i <= rotate.frame; i++) { object2D.Angle = GetEasing(rotate.easing, i, start, rotate.to, rotate.frame); yield return(null); } }
IEnumerator <object> GetAlphaCoroutine(asd.DrawnObject2D object2D, AlphaAnimationElement alpha) { Byte start = alpha.isRequireFrom ? alpha.from : object2D.Color.A; for (int i = 1; i <= alpha.frame; i++) { var color = object2D.Color; color.A = (byte)GetEasing(alpha.easing, i, start, alpha.to, alpha.frame); object2D.Color = color; yield return(null); } }
/// <summary> /// 描画に関する色以外の全ての同期設定を有効にして、指定した2Dオブジェクトを子オブジェクトとしてこのインスタンスに登録する。 /// </summary> public static void AddDrawnChildWithoutColor(this asd.DrawnObject2D obj, asd.DrawnObject2D child) { obj.AddDrawnChild( child, asd.ChildManagementMode.RegistrationToLayer | asd.ChildManagementMode.Disposal | asd.ChildManagementMode.IsUpdated | asd.ChildManagementMode.IsDrawn, asd.ChildTransformingMode.All, asd.ChildDrawingMode.DrawingPriority ); }
public IEnumerator <object> GetAnimationCoroutine(asd.DrawnObject2D object2D) { foreach (var item in animationElements) { switch (item) { case MoveAnimationElement move: { var coroutine = GetMoveCoroutine(object2D, move); while (coroutine.MoveNext()) { yield return(null); } } break; case ScaleAnimationElement scale: { var coroutine = GetScaleCoroutine(object2D, scale); while (coroutine.MoveNext()) { yield return(null); } } break; case RotateAnimationElement rotate: { var coroutine = GetRotateCoroutine(object2D, rotate); while (coroutine.MoveNext()) { yield return(null); } } break; case AlphaAnimationElement alpha: { var coroutine = GetAlphaCoroutine(object2D, alpha); while (coroutine.MoveNext()) { yield return(null); } } break; case SleepAnimationElement sleep: for (int i = 0; i < sleep.frame; i++) { yield return(null); } break; case UserAnimationElement user: { var coroutine = GetUserAnimationCoroutine(object2D, user); while (coroutine.MoveNext()) { yield return(null); } } break; default: break; } } }
/// <summary> /// アニメーションを追加する /// </summary> /// <param name="object2D">アニメーションするオブジェクト</param> /// <param name="animation">アニメーション</param> /// <param name="slot">スロット</param> public void AddAnimation(asd.DrawnObject2D object2D, Animation animation, int slot = 0) { animations[slot] = animation.GetAnimationCoroutine(object2D); }